Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers
@ 2026-03-09  7:07 Shubham Chakraborty
  2026-03-09  7:07 ` [Buildroot] [PATCH v2 2/2] DEVELOPERS: add Shubham Chakraborty as maintainer of package/which Shubham Chakraborty
  2026-03-09  9:14 ` [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Thomas Petazzoni via buildroot
  0 siblings, 2 replies; 4+ messages in thread
From: Shubham Chakraborty @ 2026-03-09  7:07 UTC (permalink / raw)
  To: buildroot; +Cc: Thomas Petazzoni, 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's unistd.h).

Fix by providing the full prototype in the non-GNU fallback branch,
matching the standard getopt() signature.

Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
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

diff --git a/package/which/0001-fix-getopt-prototype.patch b/package/which/0001-fix-getopt-prototype.patch
new file mode 100644
index 0000000000..af9597242f
--- /dev/null
+++ b/package/which/0001-fix-getopt-prototype.patch
@@ -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
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH v2 2/2] DEVELOPERS: add Shubham Chakraborty as maintainer of package/which
  2026-03-09  7:07 [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Shubham Chakraborty
@ 2026-03-09  7:07 ` Shubham Chakraborty
  2026-03-09  9:14 ` [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Thomas Petazzoni via buildroot
  1 sibling, 0 replies; 4+ messages in thread
From: Shubham Chakraborty @ 2026-03-09  7:07 UTC (permalink / raw)
  To: buildroot; +Cc: Thomas Petazzoni, Shubham Chakraborty

Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
Changes in v2:
- Fix indentation to use tabs instead of spaces
- Add trailing slash to package/which/
---
 DEVELOPERS | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/DEVELOPERS b/DEVELOPERS
index 835be1f6a3..51d9f8a4be 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -3058,6 +3058,9 @@ F:	package/tunctl/
 F:	package/ubus/
 F:	package/wolfssl/
 
+N:	Shubham Chakraborty <chakrabortyshubham66@gmail.com>
+F:	package/which/
+
 N:	Simon Dawson <spdawson@gmail.com>
 F:	boot/at91bootstrap3/
 F:	package/cppzmq/
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers
  2026-03-09  7:07 [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Shubham Chakraborty
  2026-03-09  7:07 ` [Buildroot] [PATCH v2 2/2] DEVELOPERS: add Shubham Chakraborty as maintainer of package/which Shubham Chakraborty
@ 2026-03-09  9:14 ` Thomas Petazzoni via buildroot
  2026-03-09 16:43   ` Shubham Chakraborty
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-03-09  9:14 UTC (permalink / raw)
  To: Shubham Chakraborty; +Cc: buildroot

Hello,

On Mon, Mar 09, 2026 at 12:37:40PM +0530, Shubham Chakraborty wrote:
> 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.
> 
> Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>

Which gcc version broke this?

> diff --git a/package/which/0001-fix-getopt-prototype.patch b/package/which/0001-fix-getopt-prototype.patch
> new file mode 100644
> index 0000000000..af9597242f
> --- /dev/null
> +++ b/package/which/0001-fix-getopt-prototype.patch

You didn't take into account my comments on the patch formatting.

Thanks!

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers
  2026-03-09  9:14 ` [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Thomas Petazzoni via buildroot
@ 2026-03-09 16:43   ` Shubham Chakraborty
  0 siblings, 0 replies; 4+ messages in thread
From: Shubham Chakraborty @ 2026-03-09 16:43 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: buildroot


[-- Attachment #1.1: Type: text/plain, Size: 1459 bytes --]

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

On Mon, Mar 9, 2026 at 2:53 PM Thomas Petazzoni <
thomas.petazzoni@bootlin.com> wrote:

> Hello,
>
> On Mon, Mar 09, 2026 at 12:37:40PM +0530, Shubham Chakraborty wrote:
> > 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.
> >
> > Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
>
> Which gcc version broke this?
>
> > diff --git a/package/which/0001-fix-getopt-prototype.patch
> b/package/which/0001-fix-getopt-prototype.patch
> > new file mode 100644
> > index 0000000000..af9597242f
> > --- /dev/null
> > +++ b/package/which/0001-fix-getopt-prototype.patch
>
> You didn't take into account my comments on the patch formatting.
>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering and training
> https://bootlin.com
>

[-- Attachment #1.2: Type: text/html, Size: 2127 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-09 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09  7:07 [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Shubham Chakraborty
2026-03-09  7:07 ` [Buildroot] [PATCH v2 2/2] DEVELOPERS: add Shubham Chakraborty as maintainer of package/which Shubham Chakraborty
2026-03-09  9:14 ` [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Thomas Petazzoni via buildroot
2026-03-09 16:43   ` Shubham Chakraborty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox