Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp5143620pjo; Tue, 11 Feb 2020 04:49:41 -0800 (PST) X-Google-Smtp-Source: APXvYqwPF0i2nGjBQ1QxracNFezYgIAznk3iYJDGsJpAAU4zRzccTkdJhq/sNnsawUbsKEYBuvji X-Received: by 2002:a05:6808:8d5:: with SMTP id k21mr2775116oij.121.1581425381367; Tue, 11 Feb 2020 04:49:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581425381; cv=none; d=google.com; s=arc-20160816; b=B812Th29B8tLOawMMRgjQcdkJZRxUmF3vvJx8b85cUeLMrPU/OEq3ldeTbg0Rvo7nB TO8uWE1L9n5KxbenQjtlYeQzHeNhRbCXv4WiZsQk4Zt3EJQIxsfSXHYW/PbR2TFJeVui qI+f5vjaEuG4SJTNCj4xIBpT72xZe3IYs5kNjXV+bmY9v/EfIyxV0JlNwGaDPcyWPpT1 miyzNX4Md4/pr6LE5YbmwytAckHQ62thdW5jYf6gVQMShP4dXT0t5RamZppfR8TWEpgc zEOq1kyhCvks77z9bhuFfmjbglYEgTFZKHhisU2Upj3XAap+F1wojkEJ+GswPJWNouft By/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=AnDf/Sn1aNty8VdgQyDs8w2h6uVQU8L92XdUe/+ta4Q=; b=mP5ISytVNYsfecLNQOqzAp/H5FqqweEZ0Ct/uvQD6cLV15ZD2zxrMhNNsDG1lCZvZT J5dkTIwMpFQAV9RHLrE2KrJD1G5aIeQZwz+A+gDfV/dOYZv1GT+WA/FjZ6Hh42TSTfaT PdgHjEBPOeMFeSiK/WcRw0g/JC4mKSrSJb6XNx6zv2QQzFYOOShCJe+b62zxZZA2eJA8 h+c2uJ7bq6ee/iZS3Ry4XVZJGBovi97KAvzQU1m+tdxk8F3FwZK53BcAnLW8dSeaAwJ3 jpeDwQlJgBS3CxqHl/1ZWpSQAOXztb1hZusXzGxpdz6yMbz3v8FGqDDjUHxcMV3DZrwd rXAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h203si1693625oif.3.2020.02.11.04.49.29; Tue, 11 Feb 2020 04:49:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727936AbgBKMnU (ORCPT + 99 others); Tue, 11 Feb 2020 07:43:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:54410 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727556AbgBKMnU (ORCPT ); Tue, 11 Feb 2020 07:43:20 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 84F0FBC13; Tue, 11 Feb 2020 12:43:18 +0000 (UTC) Date: Tue, 11 Feb 2020 13:43:17 +0100 From: Petr Mladek To: Andy Shevchenko Cc: Sergey Senozhatsky , linux-kernel@vger.kernel.org, Steven Rostedt Subject: Re: [PATCH v1] printk: Declare log_wait as external variable Message-ID: <20200211124317.x5erhl7kvxj2nq6a@pathway.suse.cz> References: <20200203131528.52825-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200203131528.52825-1-andriy.shevchenko@linux.intel.com> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 2020-02-03 15:15:28, Andy Shevchenko wrote: > Static analyzer is not happy: > > kernel/printk/printk.c:421:1: warning: symbol 'log_wait' was not declared. Should it be static? > > This is due to usage of log_wait in the other module without announcing > its declaration to the world. I wasn't able to dug into deep history of > reasons why it is so, and thus decide to make less invasive change, i.e. > declaring log_wait as external variable to make static analyzer happy. > > Note the above is done if and only if the CONFIG_PROC_FS is enabled, > otherwise we fallback to static variable. > > Signed-off-by: Andy Shevchenko > --- > kernel/printk/printk.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index 633f41a11d75..43b5cb88c607 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -418,7 +418,14 @@ DEFINE_RAW_SPINLOCK(logbuf_lock); > } while (0) > > #ifdef CONFIG_PRINTK > + > +#ifdef CONFIG_PROC_FS > +extern wait_queue_head_t log_wait; /* Used in fs/proc/kmsg.c */ > DECLARE_WAIT_QUEUE_HEAD(log_wait); > +#else > +static DECLARE_WAIT_QUEUE_HEAD(log_wait); > +#endif /* CONFIG_PROC_FS */ This looks too complicated as a workaround for a warning. I got really confused. Probably also because the macro DECLARE_*() does a definition instead of a declaration. As a minimal fix, I suggest to rename log_wait -> printk_log_wait and declare it in include/linux/printk.h. Even better solution might be to move fs/proc/kmsg.c to kernel/printk/proc_kmsg.c and declare printk_log_wait only in kernel/printk/internal.h. I think that this is what Sergey suggested. Another great thing would be to extract devkmsg stuff from kernel/printk/printk.c and put it into kernel/printk/dev_kmsg.c. I am not sure but it might help people to realize that there are actually two different interfaces (old in /proc dmesg-like, and in /dev new for systemd). Sigh. I am not sure how deep and far you would like to go ;-) Best Regards, Petr