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

j1939acd: fix uclibc compile (const char* program_invocation_name) #549

Closed

Conversation

pseiderer
Copy link
Contributor

@pseiderer pseiderer commented Jul 16, 2024

  • disable command line option '-p' in case of uclibc

Fixes:

  j1939acd.c: In function 'main': j1939acd.c:489:38: error: passing argument 1 of 'asprintf' from incompatible pointer type [-Wincompatible-pointer-types]
    489 |                         if (asprintf(&program_invocation_name, "%s.%s",
        |                                      ^~~~~~~~~~~~~~~~~~~~~~~~
        |                                      |
        |                                      const char **

- disable command line option '-p' in case of uclibc

Fixes:

  j1939acd.c: In function 'main':
  j1939acd.c:489:38: error: passing argument 1 of 'asprintf' from incompatible pointer type [-Wincompatible-pointer-types]
    489 |                         if (asprintf(&program_invocation_name, "%s.%s",
        |                                      ^~~~~~~~~~~~~~~~~~~~~~~~
        |                                      |
        |                                      const char **

Signed-off-by: Peter Seiderer <[email protected]>
Copy link
Contributor

@olerem olerem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to actually replace this function. But this patch just extending existing exception. So, I'm ok with it. @marckleinebudde , haw about you?

@marckleinebudde
Copy link
Member

What about removing the -P to set the program_invocation_name functionality from all programs?

@olerem
Copy link
Contributor

olerem commented Jul 21, 2024

Hm, I have nothing against it.

@pseiderer
Copy link
Contributor Author

Fine with me too ;-), specially as the following test program

define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <err.h>

int main(int argc, char* argv[]) {
        program_invocation_name = program_invocation_short_name;
        asprintf(&program_invocation_name, "bla");
        asprintf(&program_invocation_short_name, "blub");
        warn("warn-test");
        err(1, "err-test");
        return 0;
}

produces the following output:

blub: warn-test: Success
blub: err-test: Success

Seems asprintf of j1939acd.c overwrites the wrong variable (at least for my local system)...

Will provide an alternative pull-request removing the program_invocation_name overwrite funcionality...

@olerem
Copy link
Contributor

olerem commented Jul 24, 2024

Close it in favor of #552

@olerem olerem closed this Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants