Skip to content

Commit b9075fa

Browse files
JoePerchestorvalds
authored andcommitted
treewide: use __printf not __attribute__((format(printf,...)))
Standardize the style for compiler based printf format verification. Standardized the location of __printf too. Done via script and a little typing. $ grep -rPl --include=*.[ch] -w "__attribute__" * | \ grep -vP "^(tools|scripts|include/linux/compiler-gcc.h)" | \ xargs perl -n -i -e 'local $/; while (<>) { s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.+)\s*,\s*(.+)\s*\)\s*\)\s*\)/__printf($1, $2)/g ; print; }' [akpm@linux-foundation.org: revert arch bits] Signed-off-by: Joe Perches <joe@perches.com> Cc: "Kirill A. Shutemov" <kirill@shutemov.name> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ae29bc9 commit b9075fa

61 files changed

Lines changed: 324 additions & 350 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/isdn/hisax/callc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ hisax_findcard(int driverid)
6565
return (struct IsdnCardState *) 0;
6666
}
6767

68-
static __attribute__((format(printf, 3, 4))) void
68+
static __printf(3, 4) void
6969
link_debug(struct Channel *chanp, int direction, char *fmt, ...)
7070
{
7171
va_list args;
@@ -1068,7 +1068,7 @@ init_d_st(struct Channel *chanp)
10681068
return 0;
10691069
}
10701070

1071-
static __attribute__((format(printf, 2, 3))) void
1071+
static __printf(2, 3) void
10721072
callc_debug(struct FsmInst *fi, char *fmt, ...)
10731073
{
10741074
va_list args;

‎drivers/isdn/hisax/hisax.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,9 +1287,9 @@ int jiftime(char *s, long mark);
12871287

12881288
int HiSax_command(isdn_ctrl * ic);
12891289
int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb);
1290-
__attribute__((format(printf, 3, 4)))
1290+
__printf(3, 4)
12911291
void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...);
1292-
__attribute__((format(printf, 3, 0)))
1292+
__printf(3, 0)
12931293
void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args);
12941294
void HiSax_reportcard(int cardnr, int sel);
12951295
int QuickHex(char *txt, u_char * p, int cnt);

‎drivers/isdn/hisax/isdnl1.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define B_XMTBUFREADY 1
2222
#define B_ACKPENDING 2
2323

24-
__attribute__((format(printf, 2, 3)))
24+
__printf(2, 3)
2525
void debugl1(struct IsdnCardState *cs, char *fmt, ...);
2626
void DChannel_proc_xmt(struct IsdnCardState *cs);
2727
void DChannel_proc_rcv(struct IsdnCardState *cs);

‎drivers/isdn/hisax/isdnl3.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static char *strL3Event[] =
6666
"EV_TIMEOUT",
6767
};
6868

69-
static __attribute__((format(printf, 2, 3))) void
69+
static __printf(2, 3) void
7070
l3m_debug(struct FsmInst *fi, char *fmt, ...)
7171
{
7272
va_list args;

‎drivers/isdn/hisax/st5481_d.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static struct FsmNode L1FnList[] __initdata =
167167
{ST_L1_F8, EV_IND_RSY, l1_ignore},
168168
};
169169

170-
static __attribute__((format(printf, 2, 3)))
170+
static __printf(2, 3)
171171
void l1m_debug(struct FsmInst *fi, char *fmt, ...)
172172
{
173173
va_list args;
@@ -270,7 +270,7 @@ static char *strDoutEvent[] =
270270
"EV_DOUT_UNDERRUN",
271271
};
272272

273-
static __attribute__((format(printf, 2, 3)))
273+
static __printf(2, 3)
274274
void dout_debug(struct FsmInst *fi, char *fmt, ...)
275275
{
276276
va_list args;

‎drivers/net/ethernet/mellanox/mlx4/mlx4_en.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,9 @@ extern const struct ethtool_ops mlx4_en_ethtool_ops;
581581
* printk / logging functions
582582
*/
583583

584+
__printf(3, 4)
584585
int en_print(const char *level, const struct mlx4_en_priv *priv,
585-
const char *format, ...) __attribute__ ((format (printf, 3, 4)));
586+
const char *format, ...);
586587

587588
#define en_dbg(mlevel, priv, format, arg...) \
588589
do { \

‎drivers/net/wireless/ath/ath.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ bool ath_hw_keyreset(struct ath_common *common, u16 entry);
173173
void ath_hw_cycle_counters_update(struct ath_common *common);
174174
int32_t ath_hw_get_listen_time(struct ath_common *common);
175175

176-
extern __attribute__((format (printf, 2, 3)))
177-
void ath_printk(const char *level, const char *fmt, ...);
176+
extern __printf(2, 3) void ath_printk(const char *level, const char *fmt, ...);
178177

179178
#define _ath_printk(level, common, fmt, ...) \
180179
do { \
@@ -258,7 +257,7 @@ do { \
258257

259258
#else
260259

261-
static inline __attribute__((format (printf, 3, 4)))
260+
static inline __attribute__ ((format (printf, 3, 4)))
262261
void ath_dbg(struct ath_common *common, enum ATH_DEBUG dbg_mask,
263262
const char *fmt, ...)
264263
{

‎drivers/net/wireless/ath/ath5k/debug.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf);
141141

142142
#include <linux/compiler.h>
143143

144-
static inline void __attribute__ ((format (printf, 3, 4)))
144+
static inline __printf(3, 4) void
145145
ATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {}
146146

147-
static inline void __attribute__ ((format (printf, 3, 4)))
147+
static inline __printf(3, 4) void
148148
ATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...)
149149
{}
150150

‎drivers/net/wireless/ath/ath6kl/debug.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ enum ATH6K_DEBUG_MASK {
4444
};
4545

4646
extern unsigned int debug_mask;
47-
extern int ath6kl_printk(const char *level, const char *fmt, ...)
48-
__attribute__ ((format (printf, 2, 3)));
47+
extern __printf(2, 3)
48+
int ath6kl_printk(const char *level, const char *fmt, ...);
4949

5050
#define ath6kl_info(fmt, ...) \
5151
ath6kl_printk(KERN_INFO, fmt, ##__VA_ARGS__)

‎drivers/net/wireless/b43/b43.h‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,14 +1011,10 @@ static inline bool b43_using_pio_transfers(struct b43_wldev *dev)
10111011
}
10121012

10131013
/* Message printing */
1014-
void b43info(struct b43_wl *wl, const char *fmt, ...)
1015-
__attribute__ ((format(printf, 2, 3)));
1016-
void b43err(struct b43_wl *wl, const char *fmt, ...)
1017-
__attribute__ ((format(printf, 2, 3)));
1018-
void b43warn(struct b43_wl *wl, const char *fmt, ...)
1019-
__attribute__ ((format(printf, 2, 3)));
1020-
void b43dbg(struct b43_wl *wl, const char *fmt, ...)
1021-
__attribute__ ((format(printf, 2, 3)));
1014+
__printf(2, 3) void b43info(struct b43_wl *wl, const char *fmt, ...);
1015+
__printf(2, 3) void b43err(struct b43_wl *wl, const char *fmt, ...);
1016+
__printf(2, 3) void b43warn(struct b43_wl *wl, const char *fmt, ...);
1017+
__printf(2, 3) void b43dbg(struct b43_wl *wl, const char *fmt, ...);
10221018

10231019

10241020
/* A WARN_ON variant that vanishes when b43 debugging is disabled.

0 commit comments

Comments
 (0)