diff options
author | Christopher Faulet <cfaulet@haproxy.com> | 2023-05-10 18:41:54 +0200 |
---|---|---|
committer | Christopher Faulet <cfaulet@haproxy.com> | 2023-05-11 09:22:46 +0200 |
commit | 16e314150aca771d6509ca79897006f78fd9441c (patch) | |
tree | 5341aba1072192cb1274f9a0a4b2a63259a5fd47 | |
parent | f0e8e79b3b6a6cb0b790b9892f0f654417297c7b (diff) | |
download | haproxy-16e314150aca771d6509ca79897006f78fd9441c.tar.gz |
BUILD: mjson: Fix warning about unused variables
clang 15 reports unused variables in src/mjson.c:
src/mjson.c:196:21: fatal error: expected ';' at end of declaration
int __maybe_unused n = 0;
and
src/mjson.c:727:17: fatal error: variable 'n' set but not used [-Wunused-but-set-variable]
int sign = 1, n = 0;
An issue was created on the project, but it was not fixed for now:
https://github.com/cesanta/mjson/issues/51
So for now, to fix the build issue, these variables are declared as unused.
Of course, if there is any update on this library, be careful to review this
patch first to be sure it is always required.
This patch should fix the issue #1868. It be backported as far as 2.4.
-rw-r--r-- | src/mjson.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/mjson.c b/src/mjson.c index 549b0d5b8..73b7a5797 100644 --- a/src/mjson.c +++ b/src/mjson.c @@ -192,7 +192,7 @@ static int plen1(const char *s) { } static int plen2(const char *s) { - int i = 0, n = 0; + int i = 0, __attribute__((unused)) n = 0; while (s[i] != '\0' && s[i] != '.' && s[i] != '[') n++, i += s[i] == '\\' ? 2 : 1; // printf("PLEN: s: [%s], [%.*s] => %d\n", s, i, s, n); @@ -724,7 +724,7 @@ static int is_digit(int c) { /* NOTE: strtod() implementation by Yasuhiro Matsumoto. */ static double mystrtod(const char *str, char **end) { double d = 0.0; - int sign = 1, n = 0; + int sign = 1, __attribute__((unused)) n = 0; const char *p = str, *a = str; /* decimal part */ |