package/which: fix getopt implicit prototype conflicting with system headers
PATCH v2 1/2 package/which: fix getopt implicit prototype conflicting with system headers
Older C standards allowed empty parentheses in function declarations, but modern C (C23) treats extern int getopt() as equivalent to extern int getopt(void), which conflicts with the typed prototype provided by system headers (e.g. musl's unistd.h).
Fix by providing the full prototype in the non-GNU fallback branch, matching the standard getopt() signature.
---
Changes in v2:
- Correct commit message title and body
- Use git format-patch format
--- package/which/0001-fix-getopt-prototype.patch | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 package/which/0001-fix-getopt-prototype.patch
package/which/0001-fix-getopt-prototype.patch new file +15 -0
@@ -0,0 +1,15 @@ +diff --git a/getopt.h b/getopt.h +index f080053..f080054 100644 +--- a/getopt.h ++++ b/getopt.h +@@ -102,7 +102,7 @@ + errors, only prototype getopt for the GNU C library. */ + extern int getopt(int argc, char *const *argv, const char *shortopts); + #else /* not __GNU_LIBRARY__ */ +-extern int getopt(); ++extern int getopt(int argc, char *const *argv, const char *shortopts); + #endif /* __GNU_LIBRARY__ */ + extern int getopt_long(int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); + extern int getopt_long_only(int argc, char *const *argv, const char *shortopts, const struct option *longopts, +-- +2.43.0
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 2/2 DEVELOPERS: add Shubham Chakraborty as maintainer of package/which
---
Changes in v2:
- Fix indentation to use tabs instead of spaces
- Add trailing slash to package/which/
--- DEVELOPERS | 3 +++ 1 file changed, 3 insertions(+)
DEVELOPERS +3 -0
@@ -3058,6 +3058,9 @@ F: package/tunctl/ F: package/ubus/ F: package/wolfssl/ +N: Shubham Chakraborty <[email protected]> +F: package/which/ + N: Simon Dawson <[email protected]> F: boot/at91bootstrap3/ F: package/cppzmq/
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello,
Quoted 9 lines · Shubham Chakraborty
Older C standards allowed empty parentheses in function declarations, but modern C (C23) treats extern int
getopt()as equivalent to extern int getopt(void), which conflicts with the typed prototype provided by system headers (e.g. musl'sunistd.h).Fix by providing the full prototype in the non-GNU fallback branch, matching the standard
getopt()signature.Signed-off-by Shubham Chakraborty <[email protected]>
Which gcc version broke this?
package/which/0001-fix-getopt-prototype.patch
Quoted 5 lines
package/which/0001-fix-getopt-prototype.patch new file +0
-0
You didn't take into account my comments on the patch formatting.
Thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Thomas,
Thank you for the feedback. I have sent v3 of the patch, which addresses both issues:
- Identified GCC 15 as the version that introduced this issue.
- Fixed the patch file format to include a proper description and Signed-off-by line.
Best regards,
Shubham
Quoted 24 lines · Thomas Petazzoni
Hello,
Quoted 9 lines · Shubham Chakraborty
Older C standards allowed empty parentheses in function declarations, but modern C (C23) treats extern int
getopt()as equivalent to extern int getopt(void), which conflicts with the typed prototype provided by system headers (e.g. musl'sunistd.h).Fix by providing the full prototype in the non-GNU fallback branch, matching the standard
getopt()signature.Signed-off-by Shubham Chakraborty <[email protected]>Which gcc version broke this?
Review
Quoted 1 line
(quoted diff) +0
-0
b/package/which/0001-fix-getopt-prototype.patchpackage/which/0001-fix-getopt-prototype.patch
Quoted 4 lines
new file mode 100644
index 0000000000..af9597242fpackage/which/0001-fix-getopt-prototype.patch new file +0
-0You didn't take into account my comments on the patch formatting.
Quoted 8 lines
Thanks!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot