linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/block_dev: Add prototype and __printf verification to __vfs_msg
@ 2017-04-27 23:01 Joe Perches
  0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2017-04-27 23:01 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel

__vfs_msg currently has no prototype and takes a format and arguments.

Add a prototype to include/linux/blkdev.h with __printf verification
and fix fallout.

Miscellanea:

o Rename prefix argument to level as that's the common usage for
  KERN_<LEVEL> uses
o Remove the unnecessary __vfs_msg call in the #ifndef CONFIG_PRINTK
  vfs_msg macro and just call no_printk
o Surround the __vfs_msg function with #ifdef CONFIG_PRINTK to reduce
  object size when CONFIG_PRINTK is not used

Signed-off-by: Joe Perches <joe@perches.com>
---

vfs_msg is currently used only by fs/block_dev.c and could be marked
as a static function instead without any prototype

vfs_msg is also only used with KERN_ERR so perhaps it'd be more sensible
to just remove the KERN_ERR and call it vfs_err

Perhaps also it'd be simpler to make vfs_err/vfs_msg a single macro
without the __vfs_err indirection.

 fs/block_dev.c         |  8 +++++---
 include/linux/blkdev.h | 11 +++++------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index f625dcebcf13..9ed962fd66de 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -54,7 +54,8 @@ struct block_device *I_BDEV(struct inode *inode)
 }
 EXPORT_SYMBOL(I_BDEV);
 
-void __vfs_msg(struct super_block *sb, const char *prefix, const char *fmt, ...)
+#ifdef CONFIG_PRINTK
+void __vfs_msg(struct super_block *sb, const char *level, const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
@@ -62,9 +63,10 @@ void __vfs_msg(struct super_block *sb, const char *prefix, const char *fmt, ...)
 	va_start(args, fmt);
 	vaf.fmt = fmt;
 	vaf.va = &args;
-	printk_ratelimited("%sVFS (%s): %pV\n", prefix, sb->s_id, &vaf);
+	printk_ratelimited("%sVFS (%s): %pV\n", level, sb->s_id, &vaf);
 	va_end(args);
 }
+#endif
 
 static void bdev_write_inode(struct block_device *bdev)
 {
@@ -775,7 +777,7 @@ int bdev_dax_supported(struct super_block *sb, int blocksize)
 
 	if (len < 1) {
 		vfs_msg(sb, KERN_ERR,
-				"error: dax access failed (%d)", len);
+				"error: dax access failed (%ld)", len);
 		return len < 0 ? len : -EIO;
 	}
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b94df4eed785..657a30aa52d6 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -912,14 +912,13 @@ static inline void rq_flush_dcache_pages(struct request *rq)
 #endif
 
 #ifdef CONFIG_PRINTK
-#define vfs_msg(sb, level, fmt, ...)				\
+__printf(3, 4)
+void __vfs_msg(struct super_block *sb, const char *level, const char *fmt, ...);
+#define vfs_msg(sb, level, fmt, ...)					\
 	__vfs_msg(sb, level, fmt, ##__VA_ARGS__)
 #else
-#define vfs_msg(sb, level, fmt, ...)				\
-do {								\
-	no_printk(fmt, ##__VA_ARGS__);				\
-	__vfs_msg(sb, "", " ");					\
-} while (0)
+#define vfs_msg(sb, level, fmt, ...)					\
+	no_printk(level fmt, ##__VA_ARGS__)
 #endif
 
 extern int blk_register_queue(struct gendisk *disk);
-- 
2.10.0.rc2.1.g053435c

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-27 23:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-27 23:01 [PATCH] fs/block_dev: Add prototype and __printf verification to __vfs_msg Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).