hw/usb/dev-mtp.c:1616: bad test ?
Public bug reported:
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)) {** Affects: qemu
Importance: Undecided
Status: New
Signature · 26 lines
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1798780
Title:
hw/usb/dev-mtp.c:1616: bad test ?
Status in QEMU:
New
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)) {
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1798780/+subscriptionsQuoted 5 lines · dcb
hw/usb/dev-mtp.c:1616:52: warning: logical ‘or’ of collectively exhaustive tests is always true [-Wlogical-op]Source code is
Quoted 7 lines
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
Quoted 18 lines · Peter Maydell
Quoted 5 lines · dcb
hw/usb/dev-mtp.c:1616:52: warning: logical ‘or’ of collectively exhaustive tests is always true [-Wlogical-op]Source code is
Quoted 7 lines
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.cis still unfixed.
Quoted 7 lines
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 usingqemu_write_full()instead of open-coding the retry loop ?
Thanks for the suggestion, Peter. I agree, this isn't non-blocking and qemu_write_full() can be used. Following up with a patch.
Bandan
Quoted 2 lines
thanks
-- PMM
PATCH 1/1 usb-mtp: replace the homebrew write with qemu_write_full
qemu_write_full takes care of partial blocking writes, as in cases of larger file sizes
--- hw/usb/dev-mtp.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
hw/usb/dev-mtp.c +3 -11
@@ -1630,25 +1630,16 @@ static char *utf16_to_str(uint8_t len, uint16_t *arr)/* Wrapper around write, returns 0 on failure */ static uint64_t write_retry (int fd,void *buf,uint64_t size,off_t offset) { -uint64_t bytes_left = size, ret; +uint64_t ret =0 ;if (lseek (fd, offset,SEEK_SET ) <0 ) { goto done; } -while (bytes_left >0 ) { - ret =write (fd, buf, bytes_left); -if ((ret ==-1 ) && (errno !=EINTR || errno !=EAGAIN || - errno !=EWOULDBLOCK )) { -break ; - } - bytes_left -= ret; - buf += ret; - } + ret =qemu_write_full (fd, buf, size); done: -return size - bytes_left; +return ret; }static void usb_mtp_update_object (MTPObject *parent,char *name)
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH] usb-mtp: replace the homebrew write with qemu_write_full
Quoted 6 lines · Bandan Das
qemu_write_fulltakes care of partial blocking writes, as in cases of larger file sizesSuggested-by Peter Maydell <[email protected]>Signed-off-by Bandan <[email protected]>
Hmm, doesn't apply, and git fails to do a 3way merge too due to unknown sha1.
cheers,
Gerd
Re: [Qemu-devel] [PATCH] usb-mtp: replace the homebrew write with qemu_write_full
Quoted 11 lines · Gerd Hoffmann
Quoted 6 lines · Bandan Das
qemu_write_fulltakes care of partial blocking writes, as in cases of larger file sizesSuggested-by Peter Maydell <[email protected]>Signed-off-by Bandan <[email protected]>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.
Should I resend a v2 on top of master and send a v3 for the write buffer breakup patches ?
Quoted 2 lines
cheers,
Gerd
Re: [Qemu-devel] [PATCH] usb-mtp: replace the homebrew write with qemu_write_full
Quoted 7 lines · Bandan Das
Quoted 5 lines · Gerd Hoffmann
Quoted 4 lines · Bandan Das
qemu_write_fulltakes care of partial blocking writes, as in cases of larger file sizes
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Suggested-by Peter Maydell <[email protected]>Signed-off-by Bandan <[email protected]>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.
Quoted 2 lines
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
** Changed in: qemu
Status: Fix Committed => Fix Released
Signature · 26 lines
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1798780
Title:
hw/usb/dev-mtp.c:1616: bad test ?
Status in QEMU:
Fix Released
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)) {
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1798780/+subscriptions