Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3448493pxb; Mon, 4 Oct 2021 02:32:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyi5AXEw5dixdq2lzbw/SlZaqZHARzWOJ6MTRKFm2i980ZUEINMENrJdmyzyiNHQKtpCJNY X-Received: by 2002:a05:6a00:1a50:b0:44c:4a14:ffaa with SMTP id h16-20020a056a001a5000b0044c4a14ffaamr9630347pfv.75.1633339929407; Mon, 04 Oct 2021 02:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633339929; cv=none; d=google.com; s=arc-20160816; b=pljuHw0UWGP8agd0qkQCyS3qIKGn6XFsMVMzhp38/pboIHM6AzmRbShVcyHQVjF3XN ghhnM45ChXGoPHXdUdu376n/tRS4wRLia9+Z/gEZm62J2cSQvfmTqio7Sg4PO+63F/DA PdjGjsc/eQZzQjt+QqeGBy76kOx+Tt4TFASklutGwFZo3EpxscwIg1TV/srzreuw7mWl Kaiv1gKyPrpd+Xb2cndE5MAHnHSe9ATnZrH64XThuquw5a1qk1KuPkirLWUKWHZtNR+l 5uOvs1wX5EB6v65NiLQMei9SsV+HoGnaZpusCz2iryH1tLMTdiMUoUw5jLlqlVn6Ayee fYpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6TkKi6hy7vvYkLmG2gjPBwv/cUmkzXYzYFWaAQ5WO7c=; b=NITWb3q3fR5QeJtX8behTy8u50aB51o09XHOT0gzV5fn8ySofpPobKqsWjQA44c29Y 8HQR/ZvOOhr7BOVfQ9hUuo6CPUmZy7/DHkNXERbfIxl/5fEtrPtI/0iIXRgKpSNvOIhT cp18GYW+QFFX/ieh40Dw4z0XM86szHgSYRFEeELz3THKcYqjpJoZIHfgvW8dV6CrYOBI DERN9Buf1Jl5u8lxm29ZEVRTTjdL20YyYlHmjsBsuyLbSMRztQpXUgL1bYCmY1uNlQNA YFLSFwbw/henKGk5PxMZBHByOHbcVcFy88xoCtJMr8JSjjokMQullo7jMPjYCqNcu3/R 7N8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=nwSyrOSh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id on16si4902839pjb.91.2021.10.04.02.31.55; Mon, 04 Oct 2021 02:32:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=nwSyrOSh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbhJDJYf (ORCPT + 99 others); Mon, 4 Oct 2021 05:24:35 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:44856 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbhJDJYe (ORCPT ); Mon, 4 Oct 2021 05:24:34 -0400 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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