From: David Disseldorp <ddiss@suse.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] usb: gadget: f_mass_storage: remove unnecessary open check
Date: Wed, 7 Jun 2023 10:15:03 +0200 [thread overview]
Message-ID: <20230607101503.1e5a6ef6@echidna.fritz.box> (raw)
In-Reply-To: <cc56d8bf-a634-46bb-b874-5847bd4b3bf3@rowland.harvard.edu>
Thanks for the feedback, Alan...
On Tue, 6 Jun 2023 18:33:22 -0400, Alan Stern wrote:
> On Wed, Jun 07, 2023 at 12:15:18AM +0200, David Disseldorp wrote:
> > fsg_lun_is_open() will always and only be true after a successful
> > fsg_lun_open() call, so drop the unnecessary conditional.
>
> I don't follow the reasoning. The relevant code is:
>
> if (cfg->filename) {
> rc = fsg_lun_open(lun, cfg->filename);
> if (rc)
> goto error_lun;
> }
> ...
> if (fsg_lun_is_open(lun)) {
>
> So at this point, the fsg_lun_is_open() condition is true iff
> cfg->filename was set upon entry. What makes this test unnecessary?
The fsg_lun_is_open() test is unnecessary as it will always be true
following a successful fsg_lun_open() call and will always be false if
cfg->filename is unset. This means that the logic from the
fsg_lun_is_open() conditional block can be appended directly after the
error_lun goto. pathbuf allocation ('...' above) is only needed for
the open case, so can also be wrapped into the conditional block.
I'd be happy to update the commit message if the explanation above
makes things clearer. I should probably also mention that I've tested
this using dummy-hcd.
Cheers, David
next prev parent reply other threads:[~2023-06-07 8:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-06 22:15 [PATCH] usb: gadget: f_mass_storage: remove unnecessary open check David Disseldorp
2023-06-06 22:33 ` Alan Stern
2023-06-07 8:15 ` David Disseldorp [this message]
2023-06-07 14:11 ` Alan Stern
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=20230607101503.1e5a6ef6@echidna.fritz.box \
--to=ddiss@suse.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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