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: =?utf-8?q?P=C3=A9ter_Ujfalusi?= X-Patchwork-Id: 138315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp538508vqx; Tue, 12 Sep 2023 09:45:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+8zV+Ob3b+9tuchaYyVYFwbbtD+ZH3j8/r/wgK3NJGwngiqWTrtC/AbS3BTgSAKoEWYB6 X-Received: by 2002:a17:903:2282:b0:1c3:9aaf:97be with SMTP id b2-20020a170903228200b001c39aaf97bemr283012plh.56.1694537126090; Tue, 12 Sep 2023 09:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694537126; cv=none; d=google.com; s=arc-20160816; b=IfwxWyrubG1Cc1YYvdeRJWDOKvxM3c+VsiEVMkZBfjUnGtJt3msQlBBs0QxUSnmA+w L4IVfZb8WICF7yUS2B1QzduhNiu8Ve/xSRWdKink0b1TwIZW8SsSRTJGVRNEV/cC8J4u ubzyD5qH+yBnIc1LCwNA310l42cPsKi3oYXXG9riYHJDeyboSTcfiOfjnLErK1zfDtXT 4rK3Nog8KSnredilToKvSn/0UNXjX3EWwOoJ8ypDvHSAj4xWtSawzOFNSj618Bfh2AX3 wb2V8WHxLC123KwW7V9+fh00kjCFgEzKII/I9+xFyQoof7vM4BkpFvuVKhlQ2TeXSNj7 fEpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Ib58dpjLCfx/Cg9xXuDgBPttu6JZLsTbCWNIgKrwLiU=; fh=Jqr+JeskaNFex1OVazMrVGzuZ4j2mA28HoOiDheey8k=; b=D7rYkUeNqAY9CGP+EgoY7bAKDpmbkQ855tig/QF2ugp0m+c6F/hReEqj4Bb41i+Fvr /Rau462XOic/cb/KPsOT3QPr+SWVzmGbQf5RFtfttFpws7ZMYwOpg8rfiNOoTUe13nQp U38XIuGsYfeK7UG5O9bUeccrClpDuCdJ5H5JkIxi2b1wdsWWRT6iab6t0PJcQiSbsKu7 0vZIELmqavHrn0aFsTzCnOW3d/mXf11kQ8hPKmN0tNPMovpUUQBUxqdMN8RAMQRcK4ah cIsZ28jG0bLccIQTgmTgEKstbtTct7SZQ3GWp60f/A47NKfAPzVH4tCGKgw7PquBsehU uNDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PxOFMl6k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e2-20020a17090301c200b001bda57935fasi8476208plh.64.2023.09.12.09.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 09:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PxOFMl6k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6586C80BEB3D; Tue, 12 Sep 2023 04:02:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234512AbjILLBz (ORCPT + 37 others); Tue, 12 Sep 2023 07:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234590AbjILLBd (ORCPT ); Tue, 12 Sep 2023 07:01:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986D59F for ; Tue, 12 Sep 2023 04:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694516489; x=1726052489; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=QwVU5oOHgWjfPmqwrEV3ZqF19Xp1vFXf2zAbfRKHkrA=; b=PxOFMl6kkPoRw5+xcbWyDBUhlhFzb1h1fJX49oXkLN62/PjBj6IGrd3Y 2NjGaaKS0dxoigfGZntOP+B5fBTI7ntwdfQiJ7U9H570PpW/VwsW2ZyWf eMXSu9TvMPe7tDkW+G9jGBB3zsCpT7GoEsScyMPjsOnaIxr9okp3Z0E1+ B+SsA6P6XF8Cggp5VPkPP8mapwoNneY5CWnXN2euiYQQQ7RiWfuUfFvxY F1MuaW8gYLd1NkS4bqKtDmBR7cPemCNgRGm2skHkitHa41cFPd3zamOMH rYrmeSzPLfrvFhXP+6Mm5JjHjzrNelr4AIgMjl3Xk6OcdOQIlnA/5SZeV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="381041274" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="381041274" 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Sep 2023 04:02:16 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776850961327980823 X-GMAIL-MSGID: 1776850961327980823 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;