hw/usb/dev-mtp.c:1616: bad test ?

Bug #1798780 reported by dcb
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QEMU
Fix Released
Undecided
Unassigned

Bug Description

hw/usb/dev-mtp.c:1616:52: warning: logical ‘or’ of collectively exhaustive tests is always true [-Wlogical-op]

Source code is

                if ((ret == -1) && (errno != EINTR || errno != EAGAIN ||
                                    errno != EWOULDBLOCK)) {

Maybe better code

                if ((ret == -1) && (errno != EINTR && errno != EAGAIN &&
                                    errno != EWOULDBLOCK)) {

Revision history for this message
Peter Maydell (pmaydell) wrote : Re: [Qemu-devel] [Bug 1798780] [NEW] hw/usb/dev-mtp.c:1616: bad test ?

On Fri, 19 Oct 2018 at 10:22, dcb <email address hidden> wrote:
> hw/usb/dev-mtp.c:1616:52: warning: logical ‘or’ of collectively
> exhaustive tests is always true [-Wlogical-op]
>
> Source code is
>
> if ((ret == -1) && (errno != EINTR || errno != EAGAIN ||
> errno != EWOULDBLOCK)) {
>
> Maybe better code
>
> if ((ret == -1) && (errno != EINTR && errno != EAGAIN &&
> errno != EWOULDBLOCK)) {

Hi Gerd, Bandan -- I was going through older launchpad bugs and
noticed that this one about a dubious conditional in dev-mtp.c is
still unfixed.

Is the file descriptor being used here one that's in non-blocking
mode? If so, then busy-waiting in a loop while the write() returns
EWOULDBLOCK is probably not what you wanted. If it's not then
there's no need to check for EAGAIN or EWOULDBLOCK, I think.
Consider using qemu_write_full() instead of open-coding
the retry loop ?

thanks
-- PMM

Revision history for this message
Gerd Hoffmann (kraxel-redhat) wrote : Re: [PATCH] usb-mtp: replace the homebrew write with qemu_write_full

On Tue, Jan 22, 2019 at 07:41:16AM -0500, Bandan Das wrote:
>
> qemu_write_full takes care of partial blocking writes,
> as in cases of larger file sizes
>
> Suggested-by: Peter Maydell <email address hidden>
> Signed-off-by: Bandan <email address hidden>

Hmm, doesn't apply, and git fails to do a 3way merge too due to unknown
sha1.

cheers,
  Gerd

Revision history for this message
Gerd Hoffmann (kraxel-redhat) wrote : Re: [Qemu-devel] [PATCH] usb-mtp: replace the homebrew write with qemu_write_full

On Thu, Jan 24, 2019 at 03:19:03AM -0500, Bandan Das wrote:
> Gerd Hoffmann <email address hidden> writes:
>
> > On Tue, Jan 22, 2019 at 07:41:16AM -0500, Bandan Das wrote:
> >>
> >> qemu_write_full takes care of partial blocking writes,
> >> as in cases of larger file sizes
> >>
> >> Suggested-by: Peter Maydell <email address hidden>
> >> Signed-off-by: Bandan <email address hidden>
> >
> > Hmm, doesn't apply, and git fails to do a 3way merge too due to unknown
> > sha1.
>
> Oops, sorry, I realize now this is on top of the write buffer breakup patches.

Hmm, they are queued up already, so that should have worked.

> Should I resend a v2 on top of master and send a v3 for the write buffer breakup
> patches ?

Can you just send a single series with both this fix and the breakup
patches, against latest master?

thanks,
  Gerd

Revision history for this message
Peter Maydell (pmaydell) wrote :

Fixed by commit 49f9e8d660d4 which will be in QEMU 4.0.

Changed in qemu:
status: New → Fix Committed
Thomas Huth (th-huth)
Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.