-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src/mjson.c: unused variable suspected by clang #51
Comments
this has raised just few days ago because is was detected by Fedora Rawhide which has switched to clang-15. |
I stumbled also about this issue:
|
haproxy-mirror
pushed a commit
to haproxy/haproxy
that referenced
this issue
May 11, 2023
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: cesanta/mjson#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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Clang creates a warning about unused variables which was discovered by HAPoxy community haproxy/haproxy#1868
One suggestion is to create a pragma for clang haproxy/haproxy#1868 (comment)
Another option is to add a new option like
-D MJSON_DEBUG=1
and change the code accordingly.Something like the code below instead of this block https://github.com/cesanta/mjson/blob/master/src/mjson.c#L186-L192.
As I would like to create a Pull Request to mjson and then add the new version to HAProxy please let me know what's your preferred way is to solve the clang warning.
The text was updated successfully, but these errors were encountered: