[v2,06/24] Replace inefficient C-style initialization with C++-style

Submitted by Christophe de Dinechin on Feb. 21, 2018, 5:46 p.m.

Details

Message ID 20180221174636.37758-7-christophe@dinechin.org
State New
Headers show
Series "WIP: Refactor the streaming agent towards a more standard C++ style" ( rev: 2 ) in Spice

Not browsing as part of any series.

Commit Message

Christophe de Dinechin Feb. 21, 2018, 5:46 p.m.
From: Christophe de Dinechin <dinechin@redhat.com>

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
---
 src/spice-streaming-agent.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 8508f9b..b743204 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -290,9 +290,7 @@  static void handle_interrupt(int intr)
 
 static void register_interrupts(void)
 {
-    struct sigaction sa;
-
-    memset(&sa, 0, sizeof(sa));
+    struct sigaction sa = { };
     sa.sa_handler = handle_interrupt;
     if ((sigaction(SIGINT, &sa, NULL) != 0) &&
         (sigaction(SIGTERM, &sa, NULL) != 0)) {

Comments

> 
> From: Christophe de Dinechin <dinechin@redhat.com>
> 
> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
> ---
>  src/spice-streaming-agent.cpp | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> index 8508f9b..b743204 100644
> --- a/src/spice-streaming-agent.cpp
> +++ b/src/spice-streaming-agent.cpp
> @@ -290,9 +290,7 @@ static void handle_interrupt(int intr)
>  
>  static void register_interrupts(void)
>  {
> -    struct sigaction sa;
> -
> -    memset(&sa, 0, sizeof(sa));
> +    struct sigaction sa = { };
>      sa.sa_handler = handle_interrupt;
>      if ((sigaction(SIGINT, &sa, NULL) != 0) &&
>          (sigaction(SIGTERM, &sa, NULL) != 0)) {

As discussed previously on the ML efficiency related patches should
be supported by some measurement which are not in the commit message.
If this is just a style change instead please state so in the commit
message.

Frediano
> > 
> > From: Christophe de Dinechin <dinechin@redhat.com>
> > 
> > Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
> > ---
> >  src/spice-streaming-agent.cpp | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> > index 8508f9b..b743204 100644
> > --- a/src/spice-streaming-agent.cpp
> > +++ b/src/spice-streaming-agent.cpp
> > @@ -290,9 +290,7 @@ static void handle_interrupt(int intr)
> >  
> >  static void register_interrupts(void)
> >  {
> > -    struct sigaction sa;
> > -
> > -    memset(&sa, 0, sizeof(sa));
> > +    struct sigaction sa = { };
> >      sa.sa_handler = handle_interrupt;
> >      if ((sigaction(SIGINT, &sa, NULL) != 0) &&
> >          (sigaction(SIGTERM, &sa, NULL) != 0)) {
> 
> As discussed previously on the ML efficiency related patches should
> be supported by some measurement which are not in the commit message.
> If this is just a style change instead please state so in the commit
> message.
> 

Why not a:

"Replace memset style initialization with language initialization

Language initialization is more short and less error prone."

?

Frediano
> On Feb 23, 2018, at 8:20 AM, Frediano Ziglio <fziglio@redhat.com> wrote:
> 
>>> 
>>> From: Christophe de Dinechin <dinechin@redhat.com>
>>> 
>>> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
>>> ---
>>> src/spice-streaming-agent.cpp | 4 +---
>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>> 
>>> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
>>> index 8508f9b..b743204 100644
>>> --- a/src/spice-streaming-agent.cpp
>>> +++ b/src/spice-streaming-agent.cpp
>>> @@ -290,9 +290,7 @@ static void handle_interrupt(int intr)
>>> 
>>> static void register_interrupts(void)
>>> {
>>> -    struct sigaction sa;
>>> -
>>> -    memset(&sa, 0, sizeof(sa));
>>> +    struct sigaction sa = { };
>>>     sa.sa_handler = handle_interrupt;
>>>     if ((sigaction(SIGINT, &sa, NULL) != 0) &&
>>>         (sigaction(SIGTERM, &sa, NULL) != 0)) {
>> 
>> As discussed previously on the ML efficiency related patches should
>> be supported by some measurement which are not in the commit message.
>> If this is just a style change instead please state so in the commit
>> message.
>> 
> 
> Why not a:
> 
> "Replace memset style initialization with language initialization
> 
> Language initialization is more short and less error prone.”

I see, you interpreted “more efficient” as run-time efficiency. Now I understand your comment.

I was really comparing the code length and error checking. Will change the wording.

> 
> ?
> 
> Frediano