From nobody Wed Apr 8 07:38:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE84730BBBF for ; Wed, 29 Oct 2025 11:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761736364; cv=none; b=t5LvozzHE64wIcZmYXBNMQnOd/yJwF4C7KlNjuCDF/0a8FPtrV8Xt7vSYRV+kEPCDE+V8lj7kvYyLWlK8ePp3HqcxgJo4cwlGJVWz2ClH49djfO37dMh0g/xR+IU86803hu7mRtVVAeRaXNdjh9wLUR8iInww2+B3D84Gb9tsFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761736364; c=relaxed/simple; bh=q0veARx378rGN5WON51OKxYONBEe2s6rA5tw/JasIt8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nnH+RqaDXacEwlVg5xCsHAltB7YQwpzCxNrBB2q1YcwF2rkFRGgOLAIZKL02aMHyn2ZkMNIXcM1pqIoWHMHc0q1v4t+jMT/NSPGDVsz0p+slNPRsU+1zWz+kXTuxe4EN6KidSGuz4s7K8g+/khx9fO1YoQs/zMrBCC8HuuhdfA0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ewCEd5nL; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ewCEd5nL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761736362; x=1793272362; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q0veARx378rGN5WON51OKxYONBEe2s6rA5tw/JasIt8=; b=ewCEd5nLxythStFTs58ewNAQIFJW6umZKetwDGowYGKn//pW9BzJ/iDu BBiFICo3Fq/N4A7oN/J6p7Ku65Hp4IKrcTlV7v1SRWb8rJ7k3uYTQJBzS zY5KUAWFntQDIP4CPimQCtL4Yicfu19J/iTVCNOUzBubZfOqQPcOex6Qh b3VRNtSiV8mCDyNkPn5VDmRo0HydIb4D/X+BdiO71TEUJmZ2lZ6uxVP1Q i9IjMlMxiWsPRhsEESA6v0UoOmnBVq0hePls/JxNaAZp7O0l49RjU3i2I fMFLQZ9izIDgEPIB7x3DeDt6r79FpKd4wgN864wcaKKxWWiYhzs9b9Ux8 g==; X-CSE-ConnectionGUID: gQNwjKjmQlWgYwZohFGlow== X-CSE-MsgGUID: j1LRkY1NSCyK7oc67NSEOA== X-IronPort-AV: E=McAfee;i="6800,10657,11596"; a="75198538" X-IronPort-AV: E=Sophos;i="6.19,263,1754982000"; d="scan'208";a="75198538" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2025 04:12:42 -0700 X-CSE-ConnectionGUID: mwqmJZN9Q9S7wmvx+WBu9A== X-CSE-MsgGUID: UFVVf9TdSW2edw5NEa+JsA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,263,1754982000"; d="scan'208";a="216286110" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa002.jf.intel.com with ESMTP; 29 Oct 2025 04:12:41 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id E946499; Wed, 29 Oct 2025 12:12:39 +0100 (CET) From: Andy Shevchenko To: Feng Tang , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Andrew Morton , Petr Mladek Subject: [PATCH v2 4/6] panic: sys_info: Rewrite a fix for a compilation error (`make W=1`) Date: Wed, 29 Oct 2025 12:07:39 +0100 Message-ID: <20251029111202.3217870-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029111202.3217870-2-andriy.shevchenko@linux.intel.com> References: <20251029111202.3217870-2-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Compiler was not happy about dead variable in use: lib/sys_info.c:52:19: error: variable 'sys_info_avail' is not needed and wi= ll not be emitted [-Werror,-Wunneeded-internal-declaration] 52 | static const char sys_info_avail[] =3D "tasks,mem,timers,locks,ftra= ce,all_bt,blocked_tasks"; | ^~~~~~~~~~~~~~ This was fixed by adding __maybe_unused attribute that just hides the issue and didn't actually fix the root cause. Rewrite the fix by moving the local variable from stack to a heap. As a side effect this drops unneeded "synchronisation" of duplicative info and also makes code ready for the further refactoring. Signed-off-by: Andy Shevchenko --- lib/sys_info.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/sys_info.c b/lib/sys_info.c index 5aecf4b6025f..027b2c432d07 100644 --- a/lib/sys_info.c +++ b/lib/sys_info.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only +#include #include +#include #include #include #include @@ -11,10 +13,6 @@ =20 #include =20 -/* - * When 'si_names' gets updated, please make sure the 'sys_info_avail' - * below is updated accordingly. - */ static const char * const si_names[] =3D { [ilog2(SYS_INFO_TASKS)] =3D "tasks", [ilog2(SYS_INFO_MEM)] =3D "mem", @@ -45,25 +43,32 @@ unsigned long sys_info_parse_param(char *str) =20 #ifdef CONFIG_SYSCTL =20 -static const char sys_info_avail[] __maybe_unused =3D "tasks,mem,timers,lo= cks,ftrace,all_bt,blocked_tasks"; - int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write, void *buffer, size_t *lenp, loff_t *ppos) { - char names[sizeof(sys_info_avail)]; struct ctl_table table; unsigned long *si_bits_global; unsigned long si_bits; + unsigned int i; + size_t maxlen; =20 si_bits_global =3D ro_table->data; =20 + maxlen =3D 0; + for (i =3D 0; i < ARRAY_SIZE(si_names); i++) + maxlen +=3D strlen(si_names[i]) + 1; + + char *names __free(kfree) =3D kzalloc(maxlen, GFP_KERNEL); + if (!names) + return -ENOMEM; + if (write) { int ret; =20 table =3D *ro_table; table.data =3D names; - table.maxlen =3D sizeof(names); + table.maxlen =3D maxlen; ret =3D proc_dostring(&table, write, buffer, lenp, ppos); if (ret) return ret; @@ -74,22 +79,21 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_= table, int write, return 0; } else { /* for 'read' operation */ + unsigned int len =3D 0; char *delim =3D ""; - int i, len =3D 0; =20 /* The access to the global value is not synchronized. */ si_bits =3D READ_ONCE(*si_bits_global); =20 - names[0] =3D '\0'; for_each_set_bit(i, &si_bits, ARRAY_SIZE(si_names)) { - len +=3D scnprintf(names + len, sizeof(names) - len, + len +=3D scnprintf(names + len, maxlen - len, "%s%s", delim, si_names[i]); delim =3D ","; } =20 table =3D *ro_table; table.data =3D names; - table.maxlen =3D sizeof(names); + table.maxlen =3D maxlen; return proc_dostring(&table, write, buffer, lenp, ppos); } } --=20 2.50.1