Skip to content

Conversation

@markyang92
Copy link

In the original code, write() was declared as 'extern int write();', which is interpreted as a function taking no parameters. This caused errors when actually calling it with 3 parameters. The current fix to declare it as 'extern int write(int, const void *, unsigned);' is the correct solution.
This properly defines the write function to accept 3 parameters.

../git/getopt.c: In function 'x_getopt':
../git/getopt.c:51:16: error: too many arguments to function 'write'; expected 0, have 3
51 | (void) write(2, argv[0], (unsigned)strlen(argv[0]));
| ^~~~~ ~
../git/getopt.c:78:17: note: in expansion of macro 'ERR'
78 | ERR(": illegal option -- ", c);
| ^~~
../git/getopt.c:48:20: note: declared here
48 | extern int write();
| ^~~~~

In the original code, write() was declared as 'extern int write();',
which is interpreted as a function taking no parameters.
This caused errors when actually calling it with 3 parameters.
The current fix to declare it as 'extern int write(int, const void *, unsigned);'
is the correct solution.
This properly defines the write function to accept 3 parameters.

../git/getopt.c: In function 'x_getopt':
../git/getopt.c:51:16: error: too many arguments to function 'write'; expected 0, have 3
   51 |         (void) write(2, argv[0], (unsigned)strlen(argv[0]));\
      |                ^~~~~ ~
../git/getopt.c:78:17: note: in expansion of macro 'ERR'
   78 |                 ERR(": illegal option -- ", c);
      |                 ^~~
../git/getopt.c:48:20: note: declared here
   48 |         extern int write();\
      |                    ^~~~~

Signed-off-by: mark.yang <mark.yang@lge.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Mar 27, 2025
* fix build with gcc-15.0.1
  submitted to upstream: bmc/daemonize#37

  following error:
../git/getopt.c: In function 'x_getopt':
../git/getopt.c:51:16: error: too many arguments to function 'write'; expected 0, have 3
51 | (void) write(2, argv[0], (unsigned)strlen(argv[0]));
| ^~~~~ ~
../git/getopt.c:78:17: note: in expansion of macro 'ERR'
78 | ERR(": illegal option -- ", c);
| ^~~
../git/getopt.c:48:20: note: declared here
48 | extern int write();
| ^~~~~

Signed-off-by: mark.yang <mark.yang@lge.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Mar 27, 2025
* fix build with gcc-15.0.1
  submitted to upstream: bmc/daemonize#37

  following error:
../git/getopt.c: In function 'x_getopt':
../git/getopt.c:51:16: error: too many arguments to function 'write'; expected 0, have 3
51 | (void) write(2, argv[0], (unsigned)strlen(argv[0]));
| ^~~~~ ~
../git/getopt.c:78:17: note: in expansion of macro 'ERR'
78 | ERR(": illegal option -- ", c);
| ^~~
../git/getopt.c:48:20: note: declared here
48 | extern int write();
| ^~~~~

Signed-off-by: mark.yang <mark.yang@lge.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Mar 28, 2025
* fix build with gcc-15.0.1
  submitted to upstream: bmc/daemonize#37

  following error:
../git/getopt.c: In function 'x_getopt':
../git/getopt.c:51:16: error: too many arguments to function 'write'; expected 0, have 3
51 | (void) write(2, argv[0], (unsigned)strlen(argv[0]));
| ^~~~~ ~
../git/getopt.c:78:17: note: in expansion of macro 'ERR'
78 | ERR(": illegal option -- ", c);
| ^~~
../git/getopt.c:48:20: note: declared here
48 | extern int write();
| ^~~~~

Signed-off-by: mark.yang <mark.yang@lge.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
@bmc bmc merged commit 5823762 into bmc:master Mar 28, 2025
@dottorblaster
Copy link

@bmc it would be amazing to have a new release with this patch, so all the distros can remove the downstream patch ❤️

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