Re: [PATCH 11/14] Replace inefficient C-style initialization with C++-style

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> From: Christophe de Dinechin <dinechin@xxxxxxxxxx>
> 
> Signed-off-by: Christophe de Dinechin <dinechin@xxxxxxxxxx>
> ---
>  src/spice-streaming-agent.cpp | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> index e9ef310..9a5c4fa 100644
> --- a/src/spice-streaming-agent.cpp
> +++ b/src/spice-streaming-agent.cpp
> @@ -280,10 +280,7 @@ static void handle_interrupt(int intr)
>  
>  static void register_interrupts(void)
>  {
> -    struct sigaction sa;
> -
> -    memset(&sa, 0, sizeof(sa));
> -    sa.sa_handler = handle_interrupt;
> +    struct sigaction sa = { .sa_handler = handle_interrupt };
>      if ((sigaction(SIGINT, &sa, NULL) != 0) &&
>          (sigaction(SIGTERM, &sa, NULL) != 0)) {
>          syslog(LOG_WARNING, "failed to register signal handler %m");

This syntax is C++20, we decided to limit to C++11, this is supported
by some gcc/clang version for C compatibility.
This specifically is also not even C++20, sa_handler is not a direct sigaction
field in different cases (this is a case where config.h flags can change
APIs but not ABIs) but is a nested field into an union and there's something
like:
  #define sa_handler union_field_name.sa_handler
(nested field are not supported by aggregated initializer in C++).
This patch does not compile for me.

I think also that with RHEL 7 compiler these initializations are a bit
different with compiler throwing warning about missing field initialization.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]