qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] usb-mtp: fix return status of delete


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] usb-mtp: fix return status of delete
Date: Sat, 9 Mar 2019 14:13:18 +0000

On Fri, 8 Mar 2019 at 22:14, Bandan Das <address@hidden> wrote:
>
>
> Spotted by Coverity: CID 1399414
>
> mtp delete allows the a return status of delete succeeded,
> partial_delete or readonly - when none of the objects could be
> deleted.
>
> Some initiators recurse over the objects themselves. In that case,
> only READ_ONLY can be returned.
>
> Signed-off-by: Bandan Das <address@hidden>
> ---
>  hw/usb/dev-mtp.c | 25 +++++++++----------------
>  1 file changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
> index 06e376bcd2..e3401aad75 100644
> --- a/hw/usb/dev-mtp.c
> +++ b/hw/usb/dev-mtp.c
> @@ -1137,9 +1137,9 @@ static MTPData *usb_mtp_get_object_prop_value(MTPState 
> *s, MTPControl *c,
>
>  /* Return correct return code for a delete event */
>  enum {
> -    ALL_DELETE,
> -    PARTIAL_DELETE,
> +    ALL_DELETE = 1,
>      READ_ONLY,
> +    PARTIAL_DELETE,

This is an enum, ie a set of incrementing values, but you're
using them as bit positions you're ORing together. If they're
really bit flags you should define them properly that way,
so it's clear what you're doing.

At the moment PARTIAL_DELETE is "ALL_DELETE | READ_ONLY", which
doesn't seem like it makes much sense.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]