From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: "Paul Cercueil" <paul@crapouillou.net>,
"Simona Vetter" <simona.vetter@ffwll.ch>,
"Christian König" <christian.koenig@amd.com>,
"Michael Grzeschik" <m.grzeschik@pengutronix.de>,
linux-usb@vger.kernel.org,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: re: usb: gadget: Add support for USB MIDI 2.0 function driver
Date: Thu, 7 Nov 2024 12:30:12 +0000 [thread overview]
Message-ID: <5f54ffd0-b5fe-4203-a626-c166becad362@gmail.com> (raw)
Hi,
Static analysis has found a minor issue in the following commit:
commit 8b645922b22303cec4628dbbbf6c8553d1cdec87
Author: Takashi Iwai <tiwai@suse.de>
Date: Tue Jul 25 08:22:00 2023 +0200
usb: gadget: Add support for USB MIDI 2.0 function driver
The issue is in function f_midi2_set_alt in
drivers/usb/gadget/function/f_midi2.c as follows:
if (intf != midi2->midi_if || alt > 1)
return 0;
if (alt == 0)
op_mode = MIDI_OP_MODE_MIDI1;
else if (alt == 1)
op_mode = MIDI_OP_MODE_MIDI2;
else
op_mode = MIDI_OP_MODE_UNSET;
the first if statement will return if alt is 2 or more, so at the
following cascaded if/else if/else statement alt is either 0 or 1, hence
the final else that sets op_mode = MIDI_OP_MODE_UNSET can never be
reached.
Either the last else statement is redundant and can be removed, or the
first if statement needs to check for alt > 2 rather than > 1. I'm not
sure which one is the valid fix to make. Any ideas?
Colin
next reply other threads:[~2024-11-07 12:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 12:30 Colin King (gmail) [this message]
2024-11-07 13:04 ` 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=5f54ffd0-b5fe-4203-a626-c166becad362@gmail.com \
--to=colin.i.king@gmail.com \
--cc=christian.koenig@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.grzeschik@pengutronix.de \
--cc=paul@crapouillou.net \
--cc=simona.vetter@ffwll.ch \
--cc=tiwai@suse.de \
/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
all inboxes | Powered by JetHome®