From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 5/9] treewide: specify __printf attribute directly on static definition
Date: Tue, 27 May 2025 22:13:55 +0200 [thread overview]
Message-ID: <20250527201359.889550-5-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250527201359.889550-1-a.fatoum@pengutronix.de>
On a declaration, __printf can come at the end, but for a definition, it
is not accepted after argument list and before the curly brace, so
instead of having a declaration with the attribute as well as a
definition, just have a single definition and move the __printf to the
start.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
efi/devicepath.c | 6 ++----
include/linux/printk.h | 11 ++++-------
include/printf.h | 3 +--
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/efi/devicepath.c b/efi/devicepath.c
index ecb3e7b64cc1..342422ea1a11 100644
--- a/efi/devicepath.c
+++ b/efi/devicepath.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <common.h>
+#include <linux/compiler.h>
#include <efi.h>
#include <efi/efi-util.h>
#include <malloc.h>
@@ -15,10 +16,7 @@ struct string {
unsigned used;
};
-char *cprintf(struct string *str, const char *fmt, ...)
- __attribute__ ((format(__printf__, 2, 3)));
-
-char *cprintf(struct string *str, const char *fmt, ...)
+static __printf(2, 3) char *cprintf(struct string *str, const char *fmt, ...)
{
void *buf = str->str;
unsigned bufsize = 0;
diff --git a/include/linux/printk.h b/include/linux/printk.h
index d4aafc84e2dd..f1f76fb71859 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -3,6 +3,7 @@
#define __LINUX_PRINTK_H
#include <linux/list.h>
+#include <linux/compiler.h>
#include <linux/err.h>
#include <printf.h>
#include <stdarg.h>
@@ -40,9 +41,7 @@ int dev_printf(int level, const struct device *dev, const char *format, ...)
int pr_print(int level, const char *format, ...)
__attribute__ ((format(__printf__, 2, 3)));
#else
-static int pr_print(int level, const char *format, ...)
- __attribute__ ((format(__printf__, 2, 3)));
-static inline int pr_print(int level, const char *format, ...)
+static inline __printf(2, 3) int pr_print(int level, const char *format, ...)
{
return 0;
}
@@ -104,10 +103,8 @@ static inline int pr_print(int level, const char *format, ...)
int dev_err_probe(struct device *dev, int err, const char *fmt, ...)
__attribute__ ((format(__printf__, 3, 4)));
#elif !defined(dev_err_probe)
-static int dev_err_probe(struct device *dev, int err, const char *fmt, ...)
- __attribute__ ((format(__printf__, 3, 4)));
-static inline int dev_err_probe(struct device *dev, int err, const char *fmt,
- ...)
+static inline __printf(3, 4) int dev_err_probe(struct device *dev,
+ int err, const char *fmt, ...)
{
return err;
}
diff --git a/include/printf.h b/include/printf.h
index 9a84850d02bf..eac78aec92c1 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -20,8 +20,7 @@ struct device;
(IN_PBL && defined(CONFIG_PBL_CONSOLE))
int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
#else
-static int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
-static inline int printf(const char *fmt, ...)
+static inline __printf(1, 2) int printf(const char *fmt, ...)
{
return 0;
}
--
2.39.5
next prev 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 ` Ahmad Fatoum [this message]
2025-05-27 20:13 ` [PATCH 6/9] treewide: replace attribute with shorter __printf macro Ahmad Fatoum
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-5-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