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
Fix a few minor compiler/standards issues (clang-16 porting) (for main branch) #767
Fix a few minor compiler/standards issues (clang-16 porting) (for main branch) #767
Conversation
On Linux, thpool.c uses syscall() from unistd.h, but that function is not defined without _GNU_SOURCE: c-thread-pool/thpool.c: In function 'jobqueue_pull': c-thread-pool/thpool.c:474:105: error: implicit declaration of function 'syscall' [-Werror=implicit-function-declaration] In general that's not great, because it hinders some compiler diagnostics, but it will also cause problems down the road if (for example) clang-16 decides to enable -Werror=implicit-function-declaration by default. This commit changes the _POSIX_C_SOURCE definition at the top of thpool.c to _GNU_SOURCE, as in the syscall(2) man page.
Prototypes (or the declarations themselves, if there is no
corresponding prototype) for functions that take no arguments are
required by the C standard to specify (void) as their argument list;
for example,
regex_pcre.h:79:1: error: function declaration isn't a prototype
[-Werror=strict-prototypes]
79 | cl_error_t cli_pcre_init_internal();
Future versions of clang may become strict about this, and there's no
harm in conforming to the standard right now, so we fix all such
instances in this commit.
|
This pull request introduces 2 alerts and fixes 1 when merging 74f65ed into 39fbbef - view on LGTM.com new alerts:
fixed alerts:
Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. It looks like GitHub code scanning with CodeQL is already set up for this repo, so no further action is needed |
74f65ed
to
b142a17
Compare
|
@ragusaa I just removed that commit which did this: As discussed, we can figure out how to add this in our CI instead, to prevent introducing new warnings. |
The change to define _GNU_SOURCE means that the compiler knows that syscall returns a long, not an int -- so then it warns about the wrong format characters for printing that value.
|
This pull request fixes 1 alert when merging c3855e2 into 39fbbef - view on LGTM.com fixed alerts:
Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. It looks like GitHub code scanning with CodeQL is already set up for this repo, so no further action is needed |
|
This fails to build when running those warnings as errors with clang-14. The two suggestions I have are
|
Building with these will fail for Clang because _GNU_SOURCE is not
defined.
-Werror=implicit-function-declaration
-Werror=implicit-int
-Werror=strict-prototypes
Also added fix to use "MATCHES" instead of "EQUALS" in FindLLVM where
the same sort of logic is used.
I went with a variation on the second option. I think it is fixed now. |
|
This pull request fixes 1 alert when merging 9ab74bd into 6ea6ee5 - view on LGTM.com fixed alerts:
Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. It looks like GitHub code scanning with CodeQL is already set up for this repo, so no further action is needed |
Copy of #747 forward-ported for
mainbranch.In addition, this PR:
The description from #747 is as follows...
The next major version of clang has threatened to enable some strictness flags by default:
https://bugs.gentoo.org/show_bug.cgi?id=clang-16-porting
Specifically,
Whether or not they all wind up on by default, the problems they catch are easy to fix and usually beneficial for e.g. further compiler diagnostics. Here I've fixed what I had to in order to build v0.103.7.
For the autotools build system, the following autoconf fix (and an
autoreconf -fi) is also required:https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commit;h=8b5e2016c7ed2d67f31b03a3d2e361858ff5299b
Otherwise, the checks that are emitted will unduly fail.