Skip to content
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

proc_loadavg.c: Fix incompatible integer to pointer conversion #610

Merged
merged 1 commit into from
Sep 15, 2023

Conversation

listout
Copy link
Contributor

@listout listout commented Sep 5, 2023

Newer compiler like Clang 16 and GCC 14 have certain error enabled by default, namely -Werror=incompatible-function-pointer-types. Which resutls in build error such as:

proc_loadavg.c:606:10: error: incompatible integer to pointer conversion returning int from a function with result type pthread_t

My patch supresses the error for now, but a proper fix would be better. Fist discovered on Gentoo linux (bug #894348).

Bug: https://bugs.gentoo.org/894348
Closes: #561

Newer compiler like Clang 16 and GCC 14 have certain error enabled by
default, namely -Werror=incompatible-function-pointer-types. Which
resutls in build error such as:

proc_loadavg.c:606:10: error: incompatible integer to pointer conversion returning int from a function with result type pthread_t

My patch supresses the error for now, but a proper fix would be better.
Fist discovered on Gentoo linux (bug #894348).

Bug: https://bugs.gentoo.org/894348
Closes: lxc#561
Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
@stgraber
Copy link
Member

stgraber commented Sep 8, 2023

@brauner @mihalicyn what do you think we should do to clean that up properly?

@mihalicyn
Copy link
Member

Ugh, strictly speaking we can't rely on the fact that pthread_t is a numeric type. In some pthreads implementations it can be a structure type.

IMHO this fix is good enough to be merged to make our Gentoo friends happy. But I have to rework that and add and export a new liblxcfs function like int load_daemon_v2(pthread_t *threadid, int load_use) (direct analogy with pthread_create).

Christian?

@listout
Copy link
Contributor Author

listout commented Sep 8, 2023

Gentoo friends happy.

Hey! Just wanted to note that it's not just Gentoo, rather all new compiler (as I mentioned GCC14 and Clang 16). :)

@mihalicyn
Copy link
Member

Hey! Just wanted to note that it's not just Gentoo, rather all new compiler (as I mentioned GCC14 and Clang 16). :)

haha, sure! But Gentoo of course the first in the line of distros in terms of having a new versions of compilers and stuff (and Fedora?) ;-)

@stgraber stgraber merged commit a6069df into lxc:main Sep 15, 2023
10 checks passed
mihalicyn added a commit to mihalicyn/lxcfs that referenced this pull request Sep 29, 2023
Cleanup start_loadavg code:
- add a new external symbol load_daemon_v2 with the pthread_create-like signature
- make hacky casts of pthread_t to int (and reverse) unnecessary for new API users

Related to: lxc#610

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants