Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/libmpeg2: fix build with GCC 15
@ 2026-02-21  8:14 Shubham Chakraborty
  2026-05-31 12:10 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Shubham Chakraborty @ 2026-02-21  8:14 UTC (permalink / raw)
  To: buildroot; +Cc: Shubham Chakraborty

GCC 15 defaults to C23, which no longer allows K&R-style empty parameter
list declarations. Fix getopt(), getopt_long(), getopt_long_only(), and
_getopt_internal() in src/getopt.h and src/getopt.c to use explicit
typed prototypes. Also convert K&R-style function definitions to modern
prototype style and replace the bare getenv() declaration with a proper

Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
 .../libmpeg2/0005-fix-getopt-modern-c.patch   | 108 ++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 package/libmpeg2/0005-fix-getopt-modern-c.patch

diff --git a/package/libmpeg2/0005-fix-getopt-modern-c.patch b/package/libmpeg2/0005-fix-getopt-modern-c.patch
new file mode 100644
index 0000000000..a95e443df2
--- /dev/null
+++ b/package/libmpeg2/0005-fix-getopt-modern-c.patch
@@ -0,0 +1,108 @@
+--- a/src/getopt.h
++++ b/src/getopt.h
+@@ -133,7 +133,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__ */
+ 
+ # ifndef __need_getopt
+@@ -150,12 +150,12 @@
+ 			     int __long_only);
+ # endif
+ #else /* not __STDC__ */
+-extern int getopt ();
++extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
+ # ifndef __need_getopt
+-extern int getopt_long ();
+-extern int getopt_long_only ();
++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, int *__longind);
+ 
+-extern int _getopt_internal ();
++extern int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only);
+ # endif
+ #endif /* __STDC__ */
+ 
+--- a/src/getopt.c
++++ b/src/getopt.c
+@@ -207,24 +207,19 @@
+ /* Avoid depending on library functions or files
+    whose names are inconsistent.  */
+ 
+-#ifndef getenv
+-extern char *getenv ();
+-#endif
++#include <stdlib.h>
+ 
+ static char *
+-my_index (str, chr)
+-     const char *str;
+-     int chr;
++my_index (const char *str, int chr)
+ {
+   while (*str)
+     {
+       if (*str == chr)
+-	return (char *) str;
++        return (char *) str;
+       str++;
+     }
+   return 0;
+ }
+-
+ /* If using GCC, we can safely declare strlen this way.
+    If not using GCC, it is ok not to declare it.  */
+ #ifdef __GNUC__
+@@ -302,8 +297,7 @@
+ #endif
+ 
+ static void
+-exchange (argv)
+-     char **argv;
++exchange (char **argv)
+ {
+   int bottom = first_nonopt;
+   int middle = last_nonopt;
+@@ -387,10 +381,7 @@
+ static const char *_getopt_initialize (int, char *const *, const char *);
+ #endif
+ static const char *
+-_getopt_initialize (argc, argv, optstring)
+-     int argc;
+-     char *const *argv;
+-     const char *optstring;
++_getopt_initialize (int argc, char *const *argv, const char *optstring)
+ {
+   /* Start processing options with ARGV-element 1 (since ARGV-element 0
+      is the program name); the sequence of previously skipped
+@@ -509,13 +500,8 @@
+    long-named options.  */
+ 
+ int
+-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
+-     int argc;
+-     char *const *argv;
+-     const char *optstring;
+-     const struct option *longopts;
+-     int *longind;
+-     int long_only;
++_getopt_internal (int argc, char *const *argv, const char *optstring,
++                  const struct option *longopts, int *longind, int long_only)
+ {
+   int print_errors = opterr;
+   if (optstring[0] == ':')
+@@ -969,10 +955,7 @@
+ }
+ 
+ int
+-getopt (argc, argv, optstring)
+-     int argc;
+-     char *const *argv;
+-     const char *optstring;
++getopt (int argc, char *const *argv, const char *optstring)
+ {
+   return _getopt_internal (argc, argv, optstring,
+ 			   (const struct option *) 0,
-- 
2.53.0

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

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

* Re: [Buildroot] [PATCH] package/libmpeg2: fix build with GCC 15
  2026-02-21  8:14 [Buildroot] [PATCH] package/libmpeg2: fix build with GCC 15 Shubham Chakraborty
@ 2026-05-31 12:10 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-05-31 12:10 UTC (permalink / raw)
  To: Shubham Chakraborty; +Cc: buildroot

On Sat, Feb 21, 2026 at 01:44:58PM +0530, Shubham Chakraborty wrote:
> GCC 15 defaults to C23, which no longer allows K&R-style empty parameter
> list declarations. Fix getopt(), getopt_long(), getopt_long_only(), and
> _getopt_internal() in src/getopt.h and src/getopt.c to use explicit
> typed prototypes. Also convert K&R-style function definitions to modern
> prototype style and replace the bare getenv() declaration with a proper
> 
> Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>

When fixing build issues, please either a reference to an autobuilder
failure being fixed (for example in this case
https://autobuild.buildroot.net/results/53d/53daf0b4bd8b476252ca219e53a966405ece7e51/build-end.log)
or if none is available, a defconfig that exhibits the issue.

> diff --git a/package/libmpeg2/0005-fix-getopt-modern-c.patch b/package/libmpeg2/0005-fix-getopt-modern-c.patch
> new file mode 100644
> index 0000000000..a95e443df2
> --- /dev/null
> +++ b/package/libmpeg2/0005-fix-getopt-modern-c.patch
> @@ -0,0 +1,108 @@
> +--- a/src/getopt.h
> ++++ b/src/getopt.h

Patches must have a commit log, a Signed-off-by line, and an Upstream:
tag showing that they have been submitted upstream.

The Git repository is at https://code.videolan.org/videolan/libmpeg2.

Best regards,

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] 2+ messages in thread

end of thread, other threads:[~2026-05-31 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-21  8:14 [Buildroot] [PATCH] package/libmpeg2: fix build with GCC 15 Shubham Chakraborty
2026-05-31 12:10 ` Thomas Petazzoni via buildroot

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