From patchwork Wed Jun 20 16:55:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 10477961 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 78483601D7 for ; Wed, 20 Jun 2018 16:58:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63DF128437 for ; Wed, 20 Jun 2018 16:58:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5853B28462; Wed, 20 Jun 2018 16:58:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 000F428437 for ; Wed, 20 Jun 2018 16:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932368AbeFTQ6s (ORCPT ); Wed, 20 Jun 2018 12:58:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:42147 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932153AbeFTQ6s (ORCPT ); Wed, 20 Jun 2018 12:58:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E64B1ACA3; Wed, 20 Jun 2018 16:58:46 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id E4E5ADAC2D; Wed, 20 Jun 2018 18:55:56 +0200 (CEST) Date: Wed, 20 Jun 2018 18:55:56 +0200 From: David Sterba To: Bart Van Assche Cc: "dsterba@suse.cz" , "nborisov@suse.com" , "dsterba@suse.com" , "clm@fb.com" , "jeffm@suse.com" , "jbacik@fb.com" , "linux-btrfs@vger.kernel.org" Subject: Re: [PATCH] btrfs: Fix a C compliance issue Message-ID: <20180620165556.GF24375@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Bart Van Assche , "nborisov@suse.com" , "dsterba@suse.com" , "clm@fb.com" , "jeffm@suse.com" , "jbacik@fb.com" , "linux-btrfs@vger.kernel.org" References: <20180615223659.32420-1-bart.vanassche@wdc.com> <838e73e8-e9b8-6075-1d69-79bc65c15b0c@suse.com> <20180618092633.GH24375@twin.jikos.cz> <14645aca-930b-2d7d-a7d6-6893f7cfcbbd@suse.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Jun 20, 2018 at 04:44:54PM +0000, Bart Van Assche wrote: > On Mon, 2018-06-18 at 12:31 +0300, Nikolay Borisov wrote: > > On 18.06.2018 12:26, David Sterba wrote: > > > On Sat, Jun 16, 2018 at 01:28:13PM +0300, Nikolay Borisov wrote: > > > > I'd rather not see more printk being added. Nothing prevents from having > > > > the fmt string being passed to pr_info. > > > > > > So you mean to do > > > > > > + static const char fmt[] = "Btrfs loaded, crc32c=%s" > > > + pr_info(fmt); > > > > Pretty much, something along the lines of > > > > pr_info(fmt, crc32c_impl). > > > > printk requires having the KERN_INFO in the format string, which I see > > no point in doing, correct me if I'm wrong? > > You should know that what you proposed doesn't compile because pr_info() > relies on string concatenation and hence requires that its first argument is > a string constant instead of a const char pointer. Anyway, I will rework this > patch such that it uses pr_info() instead of printk(). Right, the pr_info(fmt,...) does not compile. The closest version I got to is below. It does not look pretty, but I can't think of a better version right now. --- 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 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2369,7 +2369,8 @@ static __cold void btrfs_interface_exit(void) static void __init btrfs_print_mod_info(void) { - static const char fmt[] = KERN_INFO "Btrfs loaded, crc32c=%s" + static const char fmt1[] = "Btrfs loaded, crc32c="; + static const char fmt2[] = #ifdef CONFIG_BTRFS_DEBUG ", debug=on" #endif @@ -2383,7 +2384,7 @@ static void __init btrfs_print_mod_info(void) ", ref-verify=on" #endif "\n"; - printk(fmt, crc32c_impl()); + pr_info("%s%s%s", fmt1, crc32c_impl(), fmt2); } static int __init init_btrfs_fs(void)