mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 6/9] treewide: replace attribute with shorter __printf macro
Date: Tue, 27 May 2025 22:13:56 +0200	[thread overview]
Message-ID: <20250527201359.889550-6-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250527201359.889550-1-a.fatoum@pengutronix.de>

This makes for more compact code, but doesn't introduce any functional
change.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/include/asm/psci.h |  5 +++--
 include/bbu.h               |  3 +--
 include/environment.h       |  5 ++---
 include/linux/printk.h      |  7 +++----
 include/of.h                |  2 +-
 include/printf.h            |  3 ++-
 include/stdio.h             | 12 ++++++------
 include/xfuncs.h            |  2 +-
 8 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
index b342eb85f5ec..8ffb85db0516 100644
--- a/arch/arm/include/asm/psci.h
+++ b/arch/arm/include/asm/psci.h
@@ -6,6 +6,8 @@
 #ifndef __ARM_PSCI_H__
 #define __ARM_PSCI_H__
 
+#include <linux/compiler.h>
+
 struct device_node;
 
 #define ARM_PSCI_VER(major, minor)	(((major) << 16) | (minor))
@@ -121,8 +123,7 @@ void psci_cpu_entry(void);
 void psci_set_putc(void (*putcf)(void *ctx, int c), void *ctx);
 void psci_putc(char c);
 int psci_puts(const char *str);
-int psci_printf(const char *fmt, ...)
-            __attribute__ ((format(__printf__, 1, 2)));
+int psci_printf(const char *fmt, ...) __printf(1, 2);
 #else
 
 static inline void psci_set_putc(void (*putcf)(void *ctx, int c), void *ctx)
diff --git a/include/bbu.h b/include/bbu.h
index 087d3ee8278f..bce138d95b37 100644
--- a/include/bbu.h
+++ b/include/bbu.h
@@ -37,8 +37,7 @@ struct bbu_handler {
 	const char *devicefile;
 };
 
-int bbu_force(struct bbu_data *, const char *fmt, ...)
-	__attribute__ ((format(__printf__, 2, 3)));
+int bbu_force(struct bbu_data *, const char *fmt, ...) __printf(2, 3);
 
 int bbu_confirm(struct bbu_data *);
 
diff --git a/include/environment.h b/include/environment.h
index c24796427675..585af53c0bfe 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -33,7 +33,7 @@ const char *var_name(struct variable_d *);
 const char *getenv(const char *);
 int envvar_for_each(int (*fn)(struct variable_d *v, void *data), void *data);
 int setenv(const char *, const char *);
-int pr_setenv(const char *, const char *fmt, ...)  __attribute__ ((format(__printf__, 2, 3)));
+int pr_setenv(const char *, const char *fmt, ...) __printf(2, 3);
 void export_env_ull(const char *name, unsigned long long val);
 int getenv_ull(const char *name, unsigned long long *val);
 int getenv_ullx(const char *name, unsigned long long *val);
@@ -58,8 +58,7 @@ static inline int setenv(const char *var, const char *val)
 	return 0;
 }
 
-static inline __attribute__ ((format(__printf__, 2, 3))) int pr_setenv(
-	const char *var, const char *fmt, ...)
+static inline __printf(2, 3) int pr_setenv(const char *var, const char *fmt, ...)
 {
 	return 0;
 }
diff --git a/include/linux/printk.h b/include/linux/printk.h
index f1f76fb71859..f39dcb69a9ec 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -31,15 +31,14 @@ struct device;
 
 #if !defined(CONFIG_CONSOLE_NONE) && IN_PROPER
 int dev_printf(int level, const struct device *dev, const char *format, ...)
-	__attribute__ ((format(__printf__, 3, 4)));
+	__printf(3, 4);
 #else
 #define dev_printf(level, dev, ...) pr_print(((void)dev, (level)), __VA_ARGS__)
 #endif
 
 #if (IN_PROPER && !defined(CONFIG_CONSOLE_NONE)) || \
 	(IN_PBL && defined(CONFIG_PBL_CONSOLE))
-int pr_print(int level, const char *format, ...)
-	__attribute__ ((format(__printf__, 2, 3)));
+int pr_print(int level, const char *format, ...) __printf(2, 3);
 #else
 static inline __printf(2, 3) int pr_print(int level, const char *format, ...)
 {
@@ -101,7 +100,7 @@ static inline __printf(2, 3) int pr_print(int level, const char *format, ...)
 
 #if LOGLEVEL >= MSG_ERR
 int dev_err_probe(struct device *dev, int err, const char *fmt, ...)
-	__attribute__ ((format(__printf__, 3, 4)));
+	__printf(3, 4);
 #elif !defined(dev_err_probe)
 static inline __printf(3, 4) int dev_err_probe(struct device *dev,
 			       int err, const char *fmt, ...)
diff --git a/include/of.h b/include/of.h
index fccb8ba7e9e1..e46d410d3651 100644
--- a/include/of.h
+++ b/include/of.h
@@ -293,7 +293,7 @@ extern int of_property_write_string(struct device_node *np, const char *propname
 extern int of_property_write_strings(struct device_node *np, const char *propname,
 				    ...) __attribute__((__sentinel__));
 int of_property_sprintf(struct device_node *np, const char *propname, const char *fmt, ...)
-	__attribute__ ((format(__printf__, 3, 4)));
+	__printf(3, 4);
 
 extern struct device_node *of_parse_phandle(const struct device_node *np,
 					    const char *phandle_name,
diff --git a/include/printf.h b/include/printf.h
index eac78aec92c1..0e5f79afb87e 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -3,6 +3,7 @@
 #define __PRINTF_H
 
 #include <linux/types.h>
+#include <linux/compiler.h>
 
 struct device;
 
@@ -18,7 +19,7 @@ struct device;
 
 #if (IN_PROPER && !defined(CONFIG_CONSOLE_NONE)) || \
 	(IN_PBL && defined(CONFIG_PBL_CONSOLE))
-int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
+int printf(const char *fmt, ...) __printf(1, 2);
 #else
 static inline __printf(1, 2) int printf(const char *fmt, ...)
 {
diff --git a/include/stdio.h b/include/stdio.h
index 0e01a0e63a46..f6f181941b4a 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -12,17 +12,17 @@
  */
 
 /* serial stuff */
-void serial_printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
+void serial_printf(const char *fmt, ...) __printf(1, 2);
 
-int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
-int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
-int scnprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
+int sprintf(char *buf, const char *fmt, ...) __printf(2, 3);
+int snprintf(char *buf, size_t size, const char *fmt, ...) __printf(3, 4);
+int scnprintf(char *buf, size_t size, const char *fmt, ...) __printf(3, 4);
 int vsprintf(char *buf, const char *fmt, va_list args);
 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
 int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
 
 #if IN_PROPER || defined(CONFIG_PBL_CONSOLE)
-int asprintf(char **strp, const char *fmt, ...)  __attribute__ ((format(__printf__, 2, 3)));
+int asprintf(char **strp, const char *fmt, ...) __printf(2, 3);
 char *bvasprintf(const char *fmt, va_list ap);
 int vasprintf(char **strp, const char *fmt, va_list ap);
 #else
@@ -143,7 +143,7 @@ static inline void putchar(char c)
 #define MAX_FILES	128
 
 int vdprintf(int fd, const char *fmt, va_list args) ;
-int dprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
+int dprintf(int file, const char *fmt, ...) __printf(2, 3);
 int dputs(int file, const char *s);
 int dputc(int file, const char c);
 
diff --git a/include/xfuncs.h b/include/xfuncs.h
index f0aca6de76b3..8dd88d6607d7 100644
--- a/include/xfuncs.h
+++ b/include/xfuncs.h
@@ -17,7 +17,7 @@ char *xstrdup(const char *s);
 char *xstrndup(const char *s, size_t size) __returns_nonnull;
 void* xmemalign(size_t alignment, size_t bytes) __xalloc_size(2);
 void* xmemdup(const void *orig, size_t size) __returns_nonnull;
-char *xasprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))) __returns_nonnull;
+char *xasprintf(const char *fmt, ...) __printf(1, 2) __returns_nonnull;
 char *xvasprintf(const char *fmt, va_list ap) __returns_nonnull;
 
 wchar_t *xstrdup_wchar(const wchar_t *src);
-- 
2.39.5




  parent reply	other threads:[~2025-05-27 20:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-27 20:13 [PATCH 1/9] lib: stackprot: fix type for %pS Ahmad Fatoum
2025-05-27 20:13 ` [PATCH 2/9] fastboot: use correct format specifier for size_t Ahmad Fatoum
2025-05-27 20:13 ` [PATCH 3/9] Makefile: don't warn over zero-size format string Ahmad Fatoum
2025-05-27 20:13 ` [PATCH 4/9] scripts: define __printf attribute macro Ahmad Fatoum
2025-05-27 20:13 ` [PATCH 5/9] treewide: specify __printf attribute directly on static definition Ahmad Fatoum
2025-05-27 20:13 ` Ahmad Fatoum [this message]
2025-05-27 20:13 ` [PATCH 7/9] treewide: add missing __printf attributes Ahmad Fatoum
2025-05-27 20:13 ` [PATCH 8/9] vsprintf: add %ps format specifier for symbols without offset Ahmad Fatoum
2025-05-27 20:13 ` [PATCH 9/9] lib: random: print get_crypto_bytes caller when no HWRNG is registered Ahmad Fatoum

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=20250527201359.889550-6-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox