From patchwork Tue Sep 12 11:01:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 13381431 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7AB1DCA0ECA for ; Tue, 12 Sep 2023 11:05:58 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 38791E88; Tue, 12 Sep 2023 13:05:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 38791E88 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694516756; bh=QwVU5oOHgWjfPmqwrEV3ZqF19Xp1vFXf2zAbfRKHkrA=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=gY5fOhvOxfNcXYus6NM/a0EA6G+nmIDPGgMawjW9LX/sNFHSB35JW0lRtXh8DWmjC 8ORGzwIvbZsw7pt+pI0pQtpxaVrdtIchEcCULKMgAYm0xgdqRw9qVNNtTdXRpY82Zl Ai59tG/ZClVUnklcSoNUWlRIQdQ1Fji3va3pgGEs= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 91511F80537; Tue, 12 Sep 2023 13:04:38 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 51C89F80431; Tue, 12 Sep 2023 13:04:25 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8AED9F80431; Tue, 12 Sep 2023 13:02:17 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2360AF800AA for ; Tue, 12 Sep 2023 13:01:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2360AF800AA Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=msp3JdlP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694516495; x=1726052495; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=QwVU5oOHgWjfPmqwrEV3ZqF19Xp1vFXf2zAbfRKHkrA=; b=msp3JdlPMAv324MdrL7N1+pbuxNrP9o4lUSuUdClju+GqUjGJbEj3X88 s5IaqGsWuCdWlQIdmr39+iYIbAAK1n7D83i06Jeo5B7LPHRn/LG24bp1h lTmwwgSEr/lRaw4rKnesRYpA5kXGs7XpQ65ibEBe6QORR63Yw1efBfL/s W7lvWeS7rdz6EwukgkvMsUd0/6jpwuM0XWmn21LhEuIrUeyO0l56ottg5 z5WyR8BPwYODtTcvGBOBwcoylC+bYLMN7u4mz9/tEiYb+6iPX81u1tIEX 5TCAryKRap1w2tFJd7GU++m/jtYVbSz65LyIOh71g0c9HkgzCu8e1N3Bl Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="381041272" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="381041272" 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 04:01:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="833868062" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="833868062" 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 04:01:10 -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: Use dev_name of card_dev as debugfs directory name Date: Tue, 12 Sep 2023 14:01:13 +0300 Message-ID: <20230912110113.3166-1-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Message-ID-Hash: 4PNVQXJ7GMZ2H5V2MJEQEGZFFT2GEP27 X-Message-ID-Hash: 4PNVQXJ7GMZ2H5V2MJEQEGZFFT2GEP27 X-MailFrom: peter.ujfalusi@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: <> List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: There is no need to use temporary string for the debugfs directory name as we can use the device name of the card. This change will also fixes the following compiler warning/error (W=1): sound/core/init.c: In function ‘snd_card_init’: sound/core/init.c:367:28: error: ‘%d’ directive writing between 1 and 10 bytes into a region of size 4 [-Werror=format-overflow=] 367 | sprintf(name, "card%d", idx); | ^~ sound/core/init.c:367:23: note: directive argument in the range [0, 2147483646] 367 | sprintf(name, "card%d", idx); | ^~~~~~~~ sound/core/init.c:367:9: note: ‘sprintf’ output between 6 and 15 bytes into a destination of size 8 367 | sprintf(name, "card%d", idx); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors 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. The warnings got brought to light by a recent patch upstream: commit 6d4ab2e97dcf ("extrawarn: enable format and stringop overflow warnings in W=1") Suggested-by: Arnd Bergmann Suggested-by: Takashi Iwai Signed-off-by: Peter Ujfalusi --- sound/core/init.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sound/core/init.c b/sound/core/init.c index d61bde1225f2..22c0d217b860 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -278,9 +278,6 @@ static int snd_card_init(struct snd_card *card, struct device *parent, size_t extra_size) { int err; -#ifdef CONFIG_SND_DEBUG - char name[8]; -#endif if (extra_size > 0) card->private_data = (char *)card + sizeof(struct snd_card); @@ -364,8 +361,8 @@ static int snd_card_init(struct snd_card *card, struct device *parent, } #ifdef CONFIG_SND_DEBUG - sprintf(name, "card%d", idx); - card->debugfs_root = debugfs_create_dir(name, sound_debugfs_root); + card->debugfs_root = debugfs_create_dir(dev_name(&card->card_dev), + sound_debugfs_root); #endif return 0;