From nobody Thu Dec 18 20:16:15 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16C28CA0ECA for ; Tue, 12 Sep 2023 08:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232830AbjILIjP (ORCPT ); Tue, 12 Sep 2023 04:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232812AbjILIjN (ORCPT ); Tue, 12 Sep 2023 04:39:13 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01002AA for ; Tue, 12 Sep 2023 01:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694507950; x=1726043950; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4ejql24HEMpBoTtiKSAXpLvVWBPjkQdUnHC8bPFBtto=; b=JmOg+9KDitB72NMXe9IMI7A30BP/mx/8jZXQs8BXlu9+wdCOTES5NYQI h4ZQzTiiY64gpEcXjw2Vdaj6WNc/wjbjn13Y1kmoE2lCXNxsBklPqpzLd /XZSwZluw5j3+xB1jhcgMJPdWNWqFVXFERoua3787e7Vo36LMOq5Jm5Ob N4LOEU/oCMwrKMc603UkVWxal2ft1vtEN3WcV/N21NwquQNWOM5/lqYJP PBSM4asWmXxT9tBUrvIJZjMFrQ9bTR5mqyL0xEbSn1AUwYxmX9v31gKoD JswkfG3ER4ALtbJFbsMQUb7zbBMLCWtvjgLFr/wON6k3cqJhiSE9DyZ+S Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="381015223" X-IronPort-AV: E=Sophos;i="6.02,245,1688454000"; d="scan'208";a="381015223" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 01:39:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="833826778" X-IronPort-AV: E=Sophos;i="6.02,245,1688454000"; d="scan'208";a="833826778" Received: from mkidd-mobl.ger.corp.intel.com (HELO pujfalus-desk.ger.corp.intel.com) ([10.251.217.72]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 01:39:06 -0700 From: Peter Ujfalusi To: tiwai@suse.com, perex@perex.cz, arnd@arndb.de Cc: masahiroy@kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH] ALSA: core: Increase the name array size for debugfs directory name Date: Tue, 12 Sep 2023 11:39:10 +0300 Message-ID: <20230912083910.15994-1-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The idx is guarantied to be less than SNDRV_CARDS (max 256 or 8) by the code in snd_card_init(), however the compiler does not see that. Compiling with W=3D1 results: sound/core/init.c: In function =E2=80=98snd_card_init=E2=80=99: sound/core/init.c:367:28: error: =E2=80=98%d=E2=80=99 directive writing bet= ween 1 and 10 bytes into a region of size 4 [-Werror=3Dformat-overflow=3D] 367 | sprintf(name, "card%d", idx); | ^~ sound/core/init.c:367:23: note: directive argument in the range [0, 2147483= 646] 367 | sprintf(name, "card%d", idx); | ^~~~~~~~ sound/core/init.c:367:9: note: =E2=80=98sprintf=E2=80=99 output between 6 a= nd 15 bytes into a destination of size 8 367 | sprintf(name, "card%d", idx); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors While the code is correct, we need to silence the compiler somehow. It could be done by limiting the range in sprintf like sprintf(name, "card%d", idx % SNDRV_CARDS); sprintf(name, "card%hhd", idx); etc These are too workaroundish. Increase the name array to 15 instead which looks better and only adds 7 bytes on stack. The warnings got brought to light by a recent patch upstream: commit 6d4ab2e97dcf ("extrawarn: enable format and stringop overflow warnin= gs in W=3D1") Signed-off-by: Peter Ujfalusi --- Hi, The mentioned commit causes other build failures with W=3D1 at least in sound/usb/mixer_scarlett_gen2.c sound/usb/mixer.c sound/soc/codecs/hdac_hdmi.c sound/hda/intel-sdw-acpi.c Some of them are also false and we need to find a workaround, but I think the scarlett case might be valid. Regards, Peter sound/core/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/init.c b/sound/core/init.c index d61bde1225f2..d8a13a76d241 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -279,7 +279,7 @@ static int snd_card_init(struct snd_card *card, struct = device *parent, { int err; #ifdef CONFIG_SND_DEBUG - char name[8]; + char name[15]; #endif =20 if (extra_size > 0) --=20 2.42.0