diff mbox

[v2,3/3] btrfs: Fix a C compliance issue

Message ID 20180620170333.29182-4-bart.vanassche@wdc.com (mailing list archive)
State Accepted
Headers show

Commit Message

Bart Van Assche June 20, 2018, 5:03 p.m. UTC
The C programming language does not allow to use preprocessor statements
inside macro arguments (pr_info() is defined as a macro). Hence rework
the pr_info() statement in btrfs_print_mod_info() such that it becomes
compliant. This patch allows tools like sparse to analyze the BTRFS
source code.

Fixes: 62e855771dac ("btrfs: convert printk(KERN_* to use pr_* calls")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/super.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

kernel test robot June 20, 2018, 9:16 p.m. UTC | #1
Hi Bart,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.18-rc1]
[also build test ERROR on next-20180620]
[cannot apply to btrfs/next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Bart-Van-Assche/Three-patches-that-address-static-analyzer-reports/20180621-041247
config: m68k-sun3_defconfig (attached as .config)
compiler: m68k-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=m68k 

All errors (new ones prefixed by >>):

   fs//btrfs/super.c: In function 'btrfs_print_mod_info':
>> fs//btrfs/super.c:2386:4: error: expected expression before ';' token
       ;
       ^

vim +2386 fs//btrfs/super.c

  2370	
  2371	static void __init btrfs_print_mod_info(void)
  2372	{
  2373		static const char options[] =
  2374	#ifdef CONFIG_BTRFS_DEBUG
  2375				", debug=on"
  2376	#endif
  2377	#ifdef CONFIG_BTRFS_ASSERT
  2378				", assert=on"
  2379	#endif
  2380	#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
  2381				", integrity-checker=on"
  2382	#endif
  2383	#ifdef CONFIG_BTRFS_FS_REF_VERIFY
  2384				", ref-verify=on"
  2385	#endif
> 2386				;
  2387		pr_info("Btrfs loaded, crc32c=%s%s\n", crc32c_impl(), options);
  2388	}
  2389	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
David Sterba June 20, 2018, 10:25 p.m. UTC | #2
On Thu, Jun 21, 2018 at 05:16:06AM +0800, kbuild test robot wrote:
> Hi Bart,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on v4.18-rc1]
> [also build test ERROR on next-20180620]
> [cannot apply to btrfs/next]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Bart-Van-Assche/Three-patches-that-address-static-analyzer-reports/20180621-041247
> config: m68k-sun3_defconfig (attached as .config)
> compiler: m68k-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         GCC_VERSION=7.2.0 make.cross ARCH=m68k 
> 
> All errors (new ones prefixed by >>):
> 
>    fs//btrfs/super.c: In function 'btrfs_print_mod_info':
> >> fs//btrfs/super.c:2386:4: error: expected expression before ';' token
>        ;
>        ^

That's probably because none of the config option is turned on and this
results to

	const char options[] = ;

but a "" should fix it.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 3e298f26a383..972d9fbd7e96 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2370,7 +2370,7 @@  static __cold void btrfs_interface_exit(void)
 
 static void __init btrfs_print_mod_info(void)
 {
-	pr_info("Btrfs loaded, crc32c=%s"
+	static const char options[] =
 #ifdef CONFIG_BTRFS_DEBUG
 			", debug=on"
 #endif
@@ -2383,8 +2383,8 @@  static void __init btrfs_print_mod_info(void)
 #ifdef CONFIG_BTRFS_FS_REF_VERIFY
 			", ref-verify=on"
 #endif
-			"\n",
-			crc32c_impl());
+			;
+	pr_info("Btrfs loaded, crc32c=%s%s\n", crc32c_impl(), options);
 }
 
 static int __init init_btrfs_fs(void)