Skip to content

Commit 12fdff3

Browse files
dhowellstorvalds
authored andcommitted
Add a dummy printk function for the maintenance of unused printks
Add a dummy printk function for the maintenance of unused printks through gcc format checking, and also so that side-effect checking is maintained too. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 1490cf5 commit 12fdff3

8 files changed

Lines changed: 22 additions & 54 deletions

File tree

‎arch/mn10300/kernel/mn10300-serial.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ static const char serial_revdate[] = "2007-11-06";
4444
#include <unit/timex.h>
4545
#include "mn10300-serial.h"
4646

47-
static inline __attribute__((format(printf, 1, 2)))
48-
void no_printk(const char *fmt, ...)
49-
{
50-
}
51-
5247
#define kenter(FMT, ...) \
5348
printk(KERN_DEBUG "-->%s(" FMT ")\n", __func__, ##__VA_ARGS__)
5449
#define _enter(FMT, ...) \

‎fs/afs/internal.h‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,6 @@ extern unsigned afs_debug;
752752
#define dbgprintk(FMT,...) \
753753
printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
754754

755-
/* make sure we maintain the format strings, even when debugging is disabled */
756-
static inline __attribute__((format(printf,1,2)))
757-
void _dbprintk(const char *fmt, ...)
758-
{
759-
}
760-
761755
#define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
762756
#define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
763757
#define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
@@ -792,9 +786,9 @@ do { \
792786
} while (0)
793787

794788
#else
795-
#define _enter(FMT,...) _dbprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
796-
#define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
797-
#define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__)
789+
#define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
790+
#define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
791+
#define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__)
798792
#endif
799793

800794
/*

‎fs/cachefiles/internal.h‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,6 @@ do { \
267267
#define dbgprintk(FMT, ...) \
268268
printk(KERN_DEBUG "[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__)
269269

270-
/* make sure we maintain the format strings, even when debugging is disabled */
271-
static inline void _dbprintk(const char *fmt, ...)
272-
__attribute__((format(printf, 1, 2)));
273-
static inline void _dbprintk(const char *fmt, ...)
274-
{
275-
}
276-
277270
#define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__)
278271
#define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
279272
#define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__)
@@ -304,9 +297,9 @@ do { \
304297
} while (0)
305298

306299
#else
307-
#define _enter(FMT, ...) _dbprintk("==> %s("FMT")", __func__, ##__VA_ARGS__)
308-
#define _leave(FMT, ...) _dbprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
309-
#define _debug(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__)
300+
#define _enter(FMT, ...) no_printk("==> %s("FMT")", __func__, ##__VA_ARGS__)
301+
#define _leave(FMT, ...) no_printk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
302+
#define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
310303
#endif
311304

312305
#if 1 /* defined(__KDEBUGALL) */

‎fs/fscache/internal.h‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,11 @@ void fscache_put_context(struct fscache_cookie *cookie, void *context)
321321
#define dbgprintk(FMT, ...) \
322322
printk(KERN_DEBUG "[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__)
323323

324-
/* make sure we maintain the format strings, even when debugging is disabled */
325-
static inline __attribute__((format(printf, 1, 2)))
326-
void _dbprintk(const char *fmt, ...)
327-
{
328-
}
329-
330324
#define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__)
331325
#define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
332326
#define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__)
333327

334-
#define kjournal(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__)
328+
#define kjournal(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
335329

336330
#ifdef __KDEBUG
337331
#define _enter(FMT, ...) kenter(FMT, ##__VA_ARGS__)
@@ -358,9 +352,9 @@ do { \
358352
} while (0)
359353

360354
#else
361-
#define _enter(FMT, ...) _dbprintk("==> %s("FMT")", __func__, ##__VA_ARGS__)
362-
#define _leave(FMT, ...) _dbprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
363-
#define _debug(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__)
355+
#define _enter(FMT, ...) no_printk("==> %s("FMT")", __func__, ##__VA_ARGS__)
356+
#define _leave(FMT, ...) no_printk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
357+
#define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
364358
#endif
365359

366360
/*

‎include/linux/kernel.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,13 @@ static inline void log_buf_kexec_setup(void)
306306
}
307307
#endif
308308

309+
/*
310+
* Dummy printk for disabled debugging statements to use whilst maintaining
311+
* gcc's format and side-effect checking.
312+
*/
313+
static inline __attribute__ ((format (printf, 1, 2)))
314+
int no_printk(const char *s, ...) { return 0; }
315+
309316
extern int printk_needs_cpu(int cpu);
310317
extern void printk_tick(void);
311318

‎kernel/cred.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
#define kdebug(FMT, ...) \
2323
printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__)
2424
#else
25-
static inline __attribute__((format(printf, 1, 2)))
26-
void no_printk(const char *fmt, ...)
27-
{
28-
}
2925
#define kdebug(FMT, ...) \
3026
no_printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__)
3127
#endif

‎net/rxrpc/ar-internal.h‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,6 @@ extern unsigned rxrpc_debug;
597597
#define dbgprintk(FMT,...) \
598598
printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
599599

600-
/* make sure we maintain the format strings, even when debugging is disabled */
601-
static inline __attribute__((format(printf,1,2)))
602-
void _dbprintk(const char *fmt, ...)
603-
{
604-
}
605-
606600
#define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
607601
#define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
608602
#define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
@@ -655,11 +649,11 @@ do { \
655649
} while (0)
656650

657651
#else
658-
#define _enter(FMT,...) _dbprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
659-
#define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
660-
#define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__)
661-
#define _proto(FMT,...) _dbprintk("### "FMT ,##__VA_ARGS__)
662-
#define _net(FMT,...) _dbprintk("@@@ "FMT ,##__VA_ARGS__)
652+
#define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
653+
#define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
654+
#define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__)
655+
#define _proto(FMT,...) no_printk("### "FMT ,##__VA_ARGS__)
656+
#define _net(FMT,...) no_printk("@@@ "FMT ,##__VA_ARGS__)
663657
#endif
664658

665659
/*

‎security/keys/internal.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
#include <linux/sched.h>
1616
#include <linux/key-type.h>
1717

18-
static inline __attribute__((format(printf, 1, 2)))
19-
void no_printk(const char *fmt, ...)
20-
{
21-
}
22-
2318
#ifdef __KDEBUG
2419
#define kenter(FMT, ...) \
2520
printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)

0 commit comments

Comments
 (0)