From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8857C29CA for ; Mon, 4 Oct 2021 09:22:52 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 461DB22207; Mon, 4 Oct 2021 09:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1633339365; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6TkKi6hy7vvYkLmG2gjPBwv/cUmkzXYzYFWaAQ5WO7c=; b=nwSyrOSht7o81kAxWVu0bZi3YEt1z6jE14a2qlOePHmS8nlgi2jytlROY1WAo7axH5Xn61 Yfpic9IwlxFSsLiAI6aF27221e+oaJYzEngc0GWlzjcJwluKBQKu2GbgOoobd95wW/4FSN CPkPeDtUbjwUaxZSiBL1N5+rnP9MqGU= Received: from suse.cz (unknown [10.100.224.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id AFBD1A3B8C; Mon, 4 Oct 2021 09:22:44 +0000 (UTC) Date: Mon, 4 Oct 2021 11:22:44 +0200 From: Petr Mladek To: Chris Down Cc: Arnd Bergmann , Sergey Senozhatsky , Arnd Bergmann , Steven Rostedt , John Ogness , Nathan Chancellor , Nick Desaulniers , YueHaibing , Jessica Yu , Andy Shevchenko , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] [v2] printk: avoid -Wsometimes-uninitialized warning Message-ID: References: <20210928093456.2438109-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue 2021-09-28 11:17:26, Chris Down wrote: > Arnd Bergmann writes: > > From: Arnd Bergmann > > > > clang notices that the pi_get_entry() function would use > > uninitialized data if it was called with a non-NULL module > > pointer on a kernel that does not support modules: > > > > kernel/printk/index.c:32:6: error: variable 'nr_entries' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] > > if (!mod) { > > ^~~~ > > kernel/printk/index.c:38:13: note: uninitialized use occurs here > > if (pos >= nr_entries) > > ^~~~~~~~~~ > > kernel/printk/index.c:32:2: note: remove the 'if' if its condition is always true > > if (!mod) { > > > > Rework the condition to make it clear to the compiler that we are always > > in the second case. Unfortunately the #ifdef is still required as the > > definition of 'struct module' is hidden when modules are disabled. > > > > Fixes: 337015573718 ("printk: Userspace format indexing support") > > This changelog should make it clear that this is theoretical and will never > actually happen, which is salient information for people who are considering > whether it should go in stable or similar. IMHO, the sentence "Rework the condition to make it clear that this is theoretical and will never actually happen" is rather clear. Well, I am not a native speaker. Anyway, I have pushed the patch into printk/linux.git, branch for-5.16. Best Regards, Petr