From 0bbe8a700708ca6cf2b5112e5d4eed9a8800a8c6 Mon Sep 17 00:00:00 2001 From: Avinash Sonawane Date: Mon, 16 Oct 2023 07:56:14 +0530 Subject: [PATCH] Wrap macros in do-while(0) To fix the warnings of stray `;`. PR #4374 Signed-off-by: Romain Vimont --- app/src/server.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/server.c b/app/src/server.c index 4d787ea9..e49831fd 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -86,14 +86,15 @@ sc_server_params_copy(struct sc_server_params *dst, // The params reference user-allocated memory, so we must copy them to // handle them from another thread -#define COPY(FIELD) \ +#define COPY(FIELD) do { \ dst->FIELD = NULL; \ if (src->FIELD) { \ dst->FIELD = strdup(src->FIELD); \ if (!dst->FIELD) { \ goto error; \ } \ - } + } \ +} while(0) COPY(req_serial); COPY(crop); @@ -215,13 +216,13 @@ execute_server(struct sc_server *server, cmd[count++] = SCRCPY_VERSION; unsigned dyn_idx = count; // from there, the strings are allocated -#define ADD_PARAM(fmt, ...) { \ +#define ADD_PARAM(fmt, ...) do { \ char *p; \ if (asprintf(&p, fmt, ## __VA_ARGS__) == -1) { \ goto end; \ } \ cmd[count++] = p; \ - } + } while(0) ADD_PARAM("scid=%08x", params->scid); ADD_PARAM("log_level=%s", log_level_to_server_string(params->log_level));