diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-04-10 21:35:20 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-04-10 21:35:26 +0530 |
commit | f742dcd82123f180d04b5282402c3e06d3e8a3d1 (patch) | |
tree | 7f3acbca8eb10b2069d1ebfce6c44db108499c96 | |
parent | 0a5cf111b39710579dcdac609c9c1af6a1d19a69 (diff) |
c: wrap multi line macros inside do while
https://man.openbsd.org/style
-rw-r--r-- | include/util.h | 9 | ||||
-rw-r--r-- | src/libnpass/gpg.c | 12 |
2 files changed, 12 insertions, 9 deletions
diff --git a/include/util.h b/include/util.h index e19dbe8..8d735bb 100644 --- a/include/util.h +++ b/include/util.h @@ -1,6 +1,7 @@ #include <stdio.h> -#define err_ret(r, fmt, ...) {\ - fprintf(stderr, "[%s:%d] " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ - return r; \ -} +#define err_ret(r, fmt, ...) do { \ + fprintf(stderr, "[%s:%d] " fmt "\n", \ + __FILE__, __LINE__, ##__VA_ARGS__); \ + return r; \ +} while (0) diff --git a/src/libnpass/gpg.c b/src/libnpass/gpg.c index f193363..a729028 100644 --- a/src/libnpass/gpg.c +++ b/src/libnpass/gpg.c @@ -9,11 +9,13 @@ #include "util.h" -#define gpg_err_ret(err) \ - if (err) { \ - gpg_cleanup(); \ - err_ret(1, "%s: %s", gpgme_strsource(err), gpgme_strerror(err)); \ - } +#define gpg_err_ret(err) do { \ + if (err) { \ + gpg_cleanup(); \ + err_ret(1, "%s: %s", \ + gpgme_strsource(err), gpgme_strerror(err)); \ + } \ +} while (0) static gpgme_ctx_t ctx = NULL; static gpgme_key_t key = NULL; |