From patchwork Fri Aug 25 15:09:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13366064 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 C36F3C3DA66 for ; Fri, 25 Aug 2023 15:10:55 +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 7013584A; Fri, 25 Aug 2023 17:10:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7013584A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692976252; bh=eTsyzlBbfmq/Le+3Cn1cevyPu84zu+E34+QvDFlJUsE=; h=From:To:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=V90Db9x7W+HPZVFCAb+pC0yOiGxF+VkAHhOogLG0ISfi4697gu+utyc+mEv6G8zgy Xn5yZOOEjUTSf7bRHVjfA2wF6ykbDcyjjLXnx7LnzPO4ouRpTlsQE0Of6/yxB1F6Xj 9vCoylFvFtXoMtzl7lBGvk5Cj4dQTzxAhtl97PSI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 74229F804F3; Fri, 25 Aug 2023 17:09:32 +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 E8B22F800F5; Fri, 25 Aug 2023 17:09:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B3E09F800F5; Fri, 25 Aug 2023 17:09:27 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 53D75F800AE for ; Fri, 25 Aug 2023 17:09:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 53D75F800AE Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=GNZ+mY4G; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FT2YJp0P 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 9613322468; Fri, 25 Aug 2023 15:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692976157; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tJ0qi/i3EYD8R2ZCtEHMhMZUc4PDdZLJPb/tuIgjrl8=; b=GNZ+mY4GfoaFh+OaqZ+4MFDcokZP2K5ANql9ySx8yc9HSX1PfgN53GvlHowgEpSEJOyXib Mf1V5lXvXdKCZVvjXlvbOSnjI4NI86eXAfEe/kSgmR9DOy+5UlGChXOHQppSbQ8akCqW2h JHQ4RZRbelb8wDgs3L80uKR9Eck/adw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692976157; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tJ0qi/i3EYD8R2ZCtEHMhMZUc4PDdZLJPb/tuIgjrl8=; b=FT2YJp0P+kwpWPg5gAFIgg97NUY79k+iQYFIn504XLRv8SF+/wjmzn/J8b/Zgqb/YWw2nF BRSLOFp/Zpj4B3AQ== 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 790581340A; Fri, 25 Aug 2023 15:09:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 60g8Gx3E6GT0KgAAMHmgww (envelope-from ); Fri, 25 Aug 2023 15:09:17 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH] ALSA: ump: Fix -Wformat-truncation warnings Date: Fri, 25 Aug 2023 17:09:15 +0200 Message-Id: <20230825150915.1595-1-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Message-ID-Hash: 67SKJCKZPQBFO4S62GSTTTTC3ODSK7KF X-Message-ID-Hash: 67SKJCKZPQBFO4S62GSTTTTC3ODSK7KF X-MailFrom: tiwai@suse.de 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: Filling the rawmidi name and substream name can be truncated, and this leads to spurious compiler warnings due to -Wformat-truncation. Although the truncation is the expected behavior, it'd be better to truncate the string within "(...)" This patch puts the precision specifies to each %s for fitting the words within the size-limited strings. Fixes: 5f11dd938fe7 ("ALSA: usb-audio: Attach legacy rawmidi after probing all UMP EPs") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202308251844.1FuQYsql-lkp@intel.com/ Signed-off-by: Takashi Iwai --- sound/core/ump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/core/ump.c b/sound/core/ump.c index 9d6e3e748f7e..a2f91fe7905a 100644 --- a/sound/core/ump.c +++ b/sound/core/ump.c @@ -1157,7 +1157,7 @@ static void fill_substream_names(struct snd_ump_endpoint *ump, struct snd_rawmidi_substream *s; list_for_each_entry(s, &rmidi->streams[dir].substreams, list) - snprintf(s->name, sizeof(s->name), "Group %d (%s)", + snprintf(s->name, sizeof(s->name), "Group %d (%.16s)", ump->legacy_mapping[s->number] + 1, ump->info.name); } @@ -1191,7 +1191,7 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump, if (output) snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_ump_legacy_output_ops); - snprintf(rmidi->name, sizeof(rmidi->name), "%s (MIDI 1.0)", + snprintf(rmidi->name, sizeof(rmidi->name), "%.69s (MIDI 1.0)", ump->info.name); rmidi->info_flags = ump->core.info_flags & ~SNDRV_RAWMIDI_INFO_UMP; rmidi->ops = &snd_ump_legacy_ops;