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 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 C60B2C77B7A for ; Thu, 25 May 2023 08:31:49 +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 9DB5A1E4; Thu, 25 May 2023 10:30:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9DB5A1E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685003506; bh=Fn8NgvJqj1KC/mby+9lw7DFvcbqnPv3J/V/JEbRylHU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=TVF/aDsNHQ5pvmeNcfVtUxyI0Du7uplGNTQ5mCxfpJbZbEpmFH9WjP5ZC0Z6wz7dr EN1UP9KUOQL4lKbMm/PG8HWjxhONYbPSCHEnEw7NSVpepL+hUP5swrdSbP1gUg8Umd WyYoVYRnFKoyI2JEEY6T5J+aEASr+XUS8BEVtnZE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73472F80425; Thu, 25 May 2023 10:30:28 +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 B055EF80249; Thu, 25 May 2023 10:30:27 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CDF21F80249; Thu, 25 May 2023 10:29:18 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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 6881EF800DF for ; Thu, 25 May 2023 10:29:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6881EF800DF 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=a8iy/tJs; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=CkA5Xks4 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-out2.suse.de (Postfix) with ESMTPS id 540A81F890; Thu, 25 May 2023 08:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1685003350; 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=8fZiQFElqJdXLdgPPGanRTiB1x221Q3vu1zvFvnjky0=; b=a8iy/tJsvOXd3Gxi+S11+hN9RqS14GxTJ4E6trbIKXxb61GiWFd4pgQ2tgMht+QcsY6dpj LpD9/Sfcwz0X9xAPgauKPoojQt4RKXO0HcIytWPA/l7qMvhCWEcFwqd9PKft/Rd1K8jZFU zWkRcX51OEAcrcSrMhOUxgqedRwCpXU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1685003350; 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=8fZiQFElqJdXLdgPPGanRTiB1x221Q3vu1zvFvnjky0=; b=CkA5Xks4DEkN4J185U5V+miaB9C3ghAc7FIUvneMrkOZgyLKyOT2J6pFYBaA3JnkG5eE5Q C4x7XN9ylHB4j+CA== 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 3306713356; Thu, 25 May 2023 08:29:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id DgDkClYcb2Q3OgAAMHmgww (envelope-from ); Thu, 25 May 2023 08:29:10 +0000 Date: Thu, 25 May 2023 10:29:09 +0200 Message-ID: <87bki8ddbe.wl-tiwai@suse.de> From: Takashi Iwai To: Dan Carpenter Cc: alsa-devel@alsa-project.org Subject: Re: [bug report] ALSA: ump: Add legacy raw MIDI support In-Reply-To: <4683198a-84f6-4238-9e87-c70667d84523@kili.mountain> References: <4683198a-84f6-4238-9e87-c70667d84523@kili.mountain> 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 Message-ID-Hash: 4ZER4IXD6QVHFVVUF3T6QHZA3HM7NOHN X-Message-ID-Hash: 4ZER4IXD6QVHFVVUF3T6QHZA3HM7NOHN 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: On Thu, 25 May 2023 09:57:47 +0200, Dan Carpenter wrote: > > Hello Takashi Iwai, > > The patch 0b5288f5fe63: "ALSA: ump: Add legacy raw MIDI support" from > May 23, 2023, leads to the following Smatch static checker warning: > > sound/core/ump_convert.c:343 cvt_legacy_cmd_to_ump() > warn: duplicate check 'buf[2]' (previous on line 333) > > sound/core/ump_convert.c > 305 static int cvt_legacy_cmd_to_ump(struct snd_ump_endpoint *ump, > 306 struct ump_cvt_to_ump *cvt, > 307 unsigned char group, u32 *data, > 308 unsigned char bytes) > 309 { > 310 const unsigned char *buf = cvt->buf; > 311 struct ump_cvt_to_ump_bank *cc; > 312 union snd_ump_midi2_msg *midi2 = (union snd_ump_midi2_msg *)data; > 313 unsigned char status, channel; > 314 > 315 BUILD_BUG_ON(sizeof(union snd_ump_midi1_msg) != 4); > 316 BUILD_BUG_ON(sizeof(union snd_ump_midi2_msg) != 8); > 317 > 318 /* for MIDI 1.0 UMP, it's easy, just pack it into UMP */ > 319 if (ump->info.protocol & SNDRV_UMP_EP_INFO_PROTO_MIDI1) { > 320 data[0] = ump_compose(UMP_MSG_TYPE_MIDI1_CHANNEL_VOICE, > 321 group, 0, buf[0]); > 322 data[0] |= buf[1] << 8; > 323 if (bytes > 2) > 324 data[0] |= buf[2]; > 325 return 4; > 326 } > 327 > 328 status = *buf >> 4; > 329 channel = *buf & 0x0f; > 330 cc = &cvt->bank[channel]; > 331 > 332 /* special handling: treat note-on with 0 velocity as note-off */ > 333 if (status == UMP_MSG_STATUS_NOTE_ON && !buf[2]) > 334 status = UMP_MSG_STATUS_NOTE_OFF; > > This if statment > > 335 > 336 /* initialize the packet */ > 337 data[0] = ump_compose(UMP_MSG_TYPE_MIDI2_CHANNEL_VOICE, > 338 group, status, channel); > 339 data[1] = 0; > 340 > 341 switch (status) { > 342 case UMP_MSG_STATUS_NOTE_ON: > --> 343 if (!buf[2]) > 344 status = UMP_MSG_STATUS_NOTE_OFF; > > and this one are the same. One could be deleted. Correct. I'll submit a fix patch. Thanks! Takashi