-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Quiet some warnings #2695
Quiet some warnings #2695
Conversation
@@ -1723,6 +1724,7 @@ gethex(struct dtoa_context* C, CONST char **sp, U *rvp, int rounding, int sign) | |||
case '-': | |||
esign = 1; | |||
/* no break */ | |||
JQ_FALLTHROUGH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer need no break
comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this isn't our code, and the no break
comments never had any effect as far as compilers and linters go, and I think leaving them there as a bread-crumb on what to look for in history might be useful. Though, yeah, they serve no purpose now and you can still find them in the history, so I could drop those. Your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe we shouldn't edit jv_dtoa.c for any purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is definitely an option, though it's been edited some -- first of all by @stedolan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find the original base code of dtoa.c when included into the repository, but I think the original diff was only jvp_
prefix and MALLOC
/FREE
definitions. The latest version is available at https://www.netlib.org/fp/ so I downloaded dtoa.c and g_fmt.c to compare against jv_dtoa.c, and there seems to be some bug fixes. I don't confirm jq will be affected by the fixes, but hopefully we could follow the upstream. Since it's just compiler warnings, it's better to avoid edits, report to the original author (maybe along with 6151f20), and then include the updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember finding the original and seeing that @stedolan made some modifications to the default representation of numbers. But it's been years since I looked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/jv.h
Outdated
# define JQ_FALLTHROUGH DISPATCH_FALLTHROUGH | ||
#else | ||
# if defined(__GNUC__) | ||
# if __GNUC__ >= 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just check __has_attribute(__fallthrough__)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'll update this PR tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicowilliams ping :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if defined(DISPATCH_FALLTHROUGH)
# define JQ_FALLTHROUGH DISPATCH_FALLTHROUGH
#else
# if defined __has_attribute
# if __has_attribute(__fallthrough__)
# define JQ_FALLTHROUGH __attribute__((fallthrough))
# endif
# else
# define JQ_FALLTHROUGH do {} while (0) /* fallthrough */
# endif
#endif
look ok?
src/jv.h
Outdated
# define JQ_FALLTHROUGH do {} while (0) /* fallthrough */ | ||
# endif | ||
# else | ||
# define JQ_FALLTHROUGH do {} while (0) /* fallthrough */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found fallthrough
macro in Linux code and the code using it looks nice, but should we use JQ_ prefix to avoid conflict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itchyny well, we need one that is portable to not-Linux, including BSDs, OS X, and Windows, as well as different compilers. I did struggle with: what header file to put this in, and what to call this macro.
It's very annoying that there isn't a universally available way to do this...
This seems ok, but this PR doesn't silence all warnings:
Since we are using I think either wrapping that |
I have updated the caption! :) |
2124a02
to
679edf2
Compare
I thought #if (defined(__GNUC__) && __GNUC__ >= 7 && !defined(__clang__) || \
defined(__clang__) && __clang_major__ >= 10)
# define JQ_FALLTHROUGH __attribute__((fallthrough))
#else
# define JQ_FALLTHROUGH
#endif What do you think? |
src/jv.h
Outdated
@@ -5,6 +5,18 @@ | |||
#include <stdint.h> | |||
#include <stdio.h> | |||
|
|||
#if defined(DISPATCH_FALLTHROUGH) | |||
# define JQ_FALLTHROUGH DISPATCH_FALLTHROUGH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Came from libdispatch? Are you sure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this from Heimdal :) The link is helpful. I'll update this.
Bummer. BTW, thank you for that research! I should have done that myself. |
679edf2
to
8ba22f6
Compare
@@ -2367,10 +2372,12 @@ jvp_strtod | |||
case '-': | |||
sign = 1; | |||
/* no break */ | |||
JQ_FALLTHROUGH; | |||
case '+': | |||
if (*++s) | |||
goto break2; | |||
/* no break */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant comment
@@ -3699,6 +3707,7 @@ jvp_dtoa | |||
case 2: | |||
leftright = 0; | |||
/* no break */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant comment
@@ -3707,6 +3716,7 @@ jvp_dtoa | |||
case 3: | |||
leftright = 0; | |||
/* no break */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant comment
@@ -2367,10 +2372,12 @@ jvp_strtod | |||
case '-': | |||
sign = 1; | |||
/* no break */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant comment
@@ -1723,6 +1724,7 @@ gethex(struct dtoa_context* C, CONST char **sp, U *rvp, int rounding, int sign) | |||
case '-': | |||
esign = 1; | |||
/* no break */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant comment
@emanuele6 I wanted to leave the original |
Ok, that's fine then |
Thanks! |
No description provided.