From: Takashi Iwai <tiwai@suse.de>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: alsa-devel@alsa-project.org
Subject: Re: [bug report] ALSA: ump: Add legacy raw MIDI support
Date: Thu, 25 May 2023 10:29:09 +0200 [thread overview]
Message-ID: <87bki8ddbe.wl-tiwai@suse.de> (raw)
In-Reply-To: <4683198a-84f6-4238-9e87-c70667d84523@kili.mountain>
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
next prev parent reply other threads:[~2023-05-25 8:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 7:57 [bug report] ALSA: ump: Add legacy raw MIDI support Dan Carpenter
2023-05-25 8:29 ` Takashi Iwai [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-05-25 8:00 Dan Carpenter
2023-05-25 8:29 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bki8ddbe.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=dan.carpenter@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox