[Spice-devel] [PATCH x11spice] Use C99 struct initializiers instead of memset for local structures.
Frediano Ziglio
fziglio at redhat.com
Wed Jul 24 09:52:25 UTC 2019
>
> Signed-off-by: Jeremy White <jwhite at codeweavers.com>
Acked
> ---
> src/gui.c | 3 +--
> src/listen.c | 3 +--
> src/main.c | 4 +---
> src/spice.c | 3 +--
> 4 files changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/src/gui.c b/src/gui.c
> index 6748f66e..88acf5c9 100644
> --- a/src/gui.c
> +++ b/src/gui.c
> @@ -147,10 +147,9 @@ void session_disconnect_client(session_t *session)
> int main(int argc, char *argv[])
> {
> gui_t gui;
> - session_t session;
> + session_t session = { 0 };
>
> setlocale(LC_ALL, "");
> - memset(&session, 0, sizeof(session));
> gui_create(&gui, &session, argc, argv);
> gui_run(&gui);
> gui_destroy(&gui);
> diff --git a/src/listen.c b/src/listen.c
> index 1bddf7ed..452fd81f 100644
> --- a/src/listen.c
> +++ b/src/listen.c
> @@ -117,11 +117,10 @@ int listen_parse(const char *listen_spec, char **addr,
> int *port_start, int *por
> static int try_port(const char *addr, int port)
> {
> static const int on = 1, off = 0;
> - struct addrinfo ai, *res, *e;
> + struct addrinfo ai = { 0 }, *res, *e;
> char portbuf[33];
> int sock, rc;
>
> - memset(&ai, 0, sizeof(ai));
> ai.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
> ai.ai_socktype = SOCK_STREAM;
> ai.ai_family = 0;
> diff --git a/src/main.c b/src/main.c
> index 7f321af9..f18311c9 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -55,7 +55,7 @@ int main(int argc, char *argv[])
> {
> int rc;
>
> - session_t session;
> + session_t session = { 0 };
>
> int display_opened = 0;
> int spice_started = 0;
> @@ -63,8 +63,6 @@ int main(int argc, char *argv[])
> int session_created = 0;
> int session_started = 0;
>
> - memset(&session, 0, sizeof(session));
> -
> /*------------------------------------------------------------------------
> ** Parse arguments
> **----------------------------------------------------------------------*/
> diff --git a/src/spice.c b/src/spice.c
> index d9666441..430df405 100644
> --- a/src/spice.c
> +++ b/src/spice.c
> @@ -474,9 +474,8 @@ static int send_monitors_config(spice_t *s, int w, int h)
>
> int spice_create_primary(spice_t *s, int w, int h, int bytes_per_line, void
> *shmaddr)
> {
> - QXLDevSurfaceCreate surface;
> + QXLDevSurfaceCreate surface = { 0 };
>
> - memset(&surface, 0, sizeof(surface));
> surface.height = h;
> surface.width = w;
>
More information about the Spice-devel
mailing list