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