From mboxrd@z Thu Jan 1 00:00:00 1970 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 23762CA0EC3 for ; Tue, 12 Sep 2023 10:42:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234265AbjILKmk (ORCPT ); Tue, 12 Sep 2023 06:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230223AbjILKmi (ORCPT ); Tue, 12 Sep 2023 06:42:38 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5291D9F for ; Tue, 12 Sep 2023 03:42:34 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 78AEB212AE; Tue, 12 Sep 2023 10:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1694515352; 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=/5wrFpvn+Sn3FLRgspQobsMn/iApsHJiZE1ii4FaPxk=; b=MvQSgm0kaxtWFRRmzM5zkkxDCXVpgCRBRlRhZ3+1NYv1TUuyF4y/1P47gIBi9uBh+Mmmpt VQOQ1eYLe7/NKHVYS2u5Uh06YjCGPcMLNYEduG5NNqVGCyT2YHxoVxrvW+WhAKRJDKe2KO xXubEm5yutZGpCWIN7EOnpXoUv/xRjw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1694515352; 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=/5wrFpvn+Sn3FLRgspQobsMn/iApsHJiZE1ii4FaPxk=; b=M4LqoX+dAZv9RRJ/UE16syo5NqxE6RilgKmrJNFek5MrztBtyd/Vpmp1tgKV1YO8ChdbWe CGEo9HFWKzcOwMBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3940613A39; Tue, 12 Sep 2023 10:42:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id l68DDZhAAGXeXAAAMHmgww (envelope-from ); Tue, 12 Sep 2023 10:42:32 +0000 Date: Tue, 12 Sep 2023 12:42:31 +0200 Message-ID: <87cyyn7jvs.wl-tiwai@suse.de> From: Takashi Iwai To: "Arnd Bergmann" Cc: "Peter Ujfalusi" , tiwai@suse.com, "Jaroslav Kysela" , "Masahiro Yamada" , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH] ALSA: core: Increase the name array size for debugfs directory name In-Reply-To: <96c5309d-bb06-486e-a1f8-e3d71b275f13@app.fastmail.com> References: <20230912083910.15994-1-peter.ujfalusi@linux.intel.com> <96c5309d-bb06-486e-a1f8-e3d71b275f13@app.fastmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Sep 2023 12:18:04 +0200, Arnd Bergmann wrote: > > On Tue, Sep 12, 2023, at 10:39, Peter Ujfalusi wrote: > > > 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. > > It looks like we use the same string for kobject_set_name(), so > maybe this would work as well: > > --- 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(kobject_name(&card->card_dev.kobj), > + sound_debugfs_root); The idea looks neat, but I suppose it's better with dev_name(&card->card_dev) instead? thanks, Takashi