Skip to contentSkip to conversation

package/mkpasswd: define _DEFAULT_SOURCE to suppress compiler warning

PATCH RESEND Applied Markus Mayer via buildroot 2 participants 2 messages Nov 24, 2021 – Dec 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 package/mkpasswd: define _DEFAULT_SOURCE to suppress compiler warning

We define _DEFAULT_SOURCE in mkpasswd.c to suppress a compiler warning.

In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,

                 from /usr/include/stdio.h:27,
                 from [...]/buildroot/output/arm64/build/host-mkpasswd/mkpasswd.c:24:
/usr/include/features.h:187:3:
  187 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
      |   ^~~~~~~

As per GLIBC 2.20 release notes[1]:

The _BSD_SOURCE and _SVID_SOURCE feature test macros are no longer supported; they now act the same as _DEFAULT_SOURCE (but generate a warning). Except for cases where _BSD_SOURCE enabled BSD interfaces that conflicted with POSIX (support for which was removed in 2.19), the interfaces those macros enabled remain available when compiling with _GNU_SOURCE defined, with _DEFAULT_SOURCE defined, or without any feature test macros defined.

[1] https://lwn.net/Articles/611162/

---

Originally sent about a month ago:
https://lists.buildroot.org/pipermail/buildroot/2021-October/627062.html

Would you mind pulling this in for 2021.11?

Thanks.

 package/mkpasswd/mkpasswd.c | 5 +++++
 1 file changed, 5 insertions(+)
package/mkpasswd/mkpasswd.c +5 -0
index fd16230468a4..ae8594061cf6 100644
@@ -18,6 +18,11 @@
 
 /* for crypt, snprintf and strcasecmp */
 #define _XOPEN_SOURCE
+/*
+ * _BSD_SOURCE is deprecated as of GLIBC 2.20; _DEFAULT_SOURCE should be used
+ * instead. (https://lwn.net/Articles/611162/)
+ */
+#define _DEFAULT_SOURCE
 #define _BSD_SOURCE
 
 /* System library */
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 19 lines · Markus Mayer via buildroot

We define _DEFAULT_SOURCE in mkpasswd.c to suppress a compiler warning.

In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,

                  from /usr/include/stdio.h:27,
                  from [...]/buildroot/output/arm64/build/host-mkpasswd/mkpasswd.c:24:
/usr/include/features.h:187:3:
   187 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
       |   ^~~~~~~

As per GLIBC 2.20 release notes[1]:

The _BSD_SOURCE and _SVID_SOURCE feature test macros are no longer supported; they now act the same as _DEFAULT_SOURCE (but generate a warning). Except for cases where _BSD_SOURCE enabled BSD interfaces that conflicted with POSIX (support for which was removed in 2.19), the interfaces those macros enabled remain available when compiling with _GNU_SOURCE defined, with _DEFAULT_SOURCE defined, or without any feature test macros defined.

Quoted 3 lines

[1] https://lwn.net/Articles/611162/

Applied to master, thanks.

Quoted 4 lines

---

Originally sent about a month ago:
https://lists.buildroot.org/pipermail/buildroot/2021-October/627062.html

You can slightly accelerate this by putting a fixes tag in the commit message.
E.g. you could have written:

The _BSD_SOURCE macro is deprecated in glibc 2.20. Use _DEFAULT_SOURCE. Keep _BSD_SOURCE for compatibility with older glibc.

[... the rest of your explanation ...]

Fixes:

In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,

                 from /usr/include/stdio.h:27,
                 from 

[...]/buildroot/output/arm64/build/host-mkpasswd/mkpasswd.c:24:
/usr/include/features.h:187:3:
187 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use
_DEFAULT_SOURCE"

      |   ^~~~~~~

Anyway, I left the commit message as is.

Regards,
Arnout

Quoted 15 lines

Would you mind pulling this in for 2021.11?

Thanks.

  package/mkpasswd/mkpasswd.c | 5 +++++
  1 file changed, 5 insertions(+)
package/mkpasswd/mkpasswd.c +0 -0
index fd16230468a4..ae8594061cf6 100644
@@ -18,6 +18,11 @@
 

package/mkpasswd/mkpasswd.c line 28

Quoted 10 lines
package/mkpasswd/mkpasswd.c +5 -0
  /* for crypt, snprintf and strcasecmp */
  #define _XOPEN_SOURCE
+/*
+ * _BSD_SOURCE is deprecated as of GLIBC 2.20; _DEFAULT_SOURCE should be used
+ * instead. (https://lwn.net/Articles/611162/)
+ */
+#define _DEFAULT_SOURCE
  #define _BSD_SOURCE
 
  /* System library */

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot