From: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> Date: Sat, 17 Jul 2021 07:58:10 +0000 (+0200) Subject: Fix Linux kernel coding style error X-Git-Tag: v8.20~89^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5093229ceaf5dcc336382bc4a7ceb39a33e7fa80;p=users%2Fdwmw2%2Fopenconnect.git Fix Linux kernel coding style error Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic defects Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> --- diff --git a/openconnect-internal.h b/openconnect-internal.h index 56cfbc7f..71188cff 100644 --- a/openconnect-internal.h +++ b/openconnect-internal.h @@ -1571,29 +1571,35 @@ static inline int strprefix_match(const char *str, int len, const char *match) } #define STRDUP(res, arg) \ - if (res != arg) { \ - free(res); \ - if (arg) { \ - res = strdup(arg); \ - if (res == NULL) return -ENOMEM; \ - } else res = NULL; \ + do { \ + if (res != arg) { \ + free(res); \ + if (arg) { \ + res = strdup(arg); \ + if (res == NULL) return -ENOMEM; \ + } else res = NULL; \ + } \ } while(0) #define UTF8CHECK(arg) \ - if ((arg) && buf_append_utf16le(NULL, (arg))) { \ - vpn_progress(vpninfo, PRG_ERR, \ - _("ERROR: %s() called with invalid UTF-8 for '%s' argument\n"),\ - __func__, #arg); \ - return -EILSEQ; \ - } + do { \ + if ((arg) && buf_append_utf16le(NULL, (arg))) { \ + vpn_progress(vpninfo, PRG_ERR, \ + _("ERROR: %s() called with invalid UTF-8 for '%s' argument\n"),\ + __func__, #arg); \ + return -EILSEQ; \ + } \ + } while(0) #define UTF8CHECK_VOID(arg) \ - if ((arg) && buf_append_utf16le(NULL, (arg))) { \ - vpn_progress(vpninfo, PRG_ERR, \ - _("ERROR: %s() called with invalid UTF-8 for '%s' argument\n"),\ - __func__, #arg); \ - return; \ - } + do { \ + if ((arg) && buf_append_utf16le(NULL, (arg))) { \ + vpn_progress(vpninfo, PRG_ERR, \ + _("ERROR: %s() called with invalid UTF-8 for '%s' argument\n"),\ + __func__, #arg); \ + return; \ + } \ + } while(0) /* Let's stop open-coding big-endian and little-endian loads/stores. *