From: Rosen Penev <rosenp@gmail.com>
To: linux-mtd@lists.infradead.org
Subject: [PATCH 5/5] mtd-utils: add GNU_SOURCE define to c files
Date: Sun, 26 Oct 2025 13:00:49 -0700 [thread overview]
Message-ID: <20251026200049.25152-5-rosenp@gmail.com> (raw)
In-Reply-To: <20251026200049.25152-1-rosenp@gmail.com>
Allows removing the global GNU_SOURCE define.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
jffsX-utils/mkfs.jffs2.c | 4 ++++
lib/libmtd.c | 6 +++++-
lib/libmtd_legacy.c | 5 ++++-
misc-utils/flash_erase.c | 6 +++++-
misc-utils/recv_image.c | 4 ++++
nand-utils/nandtest.c | 4 ++++
6 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c
index da07b69..b0e649c 100644
--- a/jffsX-utils/mkfs.jffs2.c
+++ b/jffsX-utils/mkfs.jffs2.c
@@ -49,6 +49,10 @@
#define PROGRAM_NAME "mkfs.jffs2"
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // needed for asprintf
+#endif
+
#include <sys/types.h>
#include <stdio.h>
#include <sys/stat.h>
diff --git a/lib/libmtd.c b/lib/libmtd.c
index f588e09..0489a15 100644
--- a/lib/libmtd.c
+++ b/lib/libmtd.c
@@ -22,12 +22,16 @@
* MTD library.
*/
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // needed for loff_t
+#endif
+
+#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
-#include <fcntl.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c
index e0ecf49..457f330 100644
--- a/lib/libmtd_legacy.c
+++ b/lib/libmtd_legacy.c
@@ -23,7 +23,10 @@
* not possible to get sub-page size.
*/
-#include <limits.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // needed for loff_t
+#endif
+
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
diff --git a/misc-utils/flash_erase.c b/misc-utils/flash_erase.c
index 36f8d57..98289f4 100644
--- a/misc-utils/flash_erase.c
+++ b/misc-utils/flash_erase.c
@@ -21,11 +21,15 @@
#define PROGRAM_NAME "flash_erase"
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // needed for loff_t
+#endif
+
+#include <fcntl.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
-#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
diff --git a/misc-utils/recv_image.c b/misc-utils/recv_image.c
index eeaa2e2..157e240 100644
--- a/misc-utils/recv_image.c
+++ b/misc-utils/recv_image.c
@@ -4,6 +4,10 @@
#define _BSD_SOURCE /* struct ip_mreq */
#define _DEFAULT_SOURCE
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // needed for loff_t
+#endif
+
#include <errno.h>
#include <stdio.h>
#include <netdb.h>
diff --git a/nand-utils/nandtest.c b/nand-utils/nandtest.c
index cac0dde..58542e5 100644
--- a/nand-utils/nandtest.c
+++ b/nand-utils/nandtest.c
@@ -1,5 +1,9 @@
#define PROGRAM_NAME "nandtest"
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // needed for loff_t
+#endif
+
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
--
2.51.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2025-10-26 20:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-26 20:00 [PATCH 1/5] mtd-utils: don't include features.h Rosen Penev
2025-10-26 20:00 ` [PATCH 2/5] mtd-utils: rbtree: just include stddef.h Rosen Penev
2025-10-26 20:00 ` [PATCH 3/5] mtd-utils: reduce linux/types.h usage Rosen Penev
2025-10-26 20:00 ` [PATCH 4/5] mtd-utils: serve_image: fix _POSIX_C_SOURCE Rosen Penev
2025-10-26 20:00 ` Rosen Penev [this message]
2025-11-28 20:43 ` [PATCH 5/5] mtd-utils: add GNU_SOURCE define to c files David Oberhollenzer
2025-11-28 20:50 ` Rosen Penev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251026200049.25152-5-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.