From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaAc3-0006zH-NZ for qemu-devel@nongnu.org; Mon, 12 Dec 2011 13:28:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaAc2-0005zC-LG for qemu-devel@nongnu.org; Mon, 12 Dec 2011 13:28:31 -0500 Received: from mail-qw0-f45.google.com ([209.85.216.45]:39083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaAc2-0005xs-IE for qemu-devel@nongnu.org; Mon, 12 Dec 2011 13:28:30 -0500 Received: by qadc10 with SMTP id c10so895865qad.4 for ; Mon, 12 Dec 2011 10:28:30 -0800 (PST) Message-ID: <4EE647CA.5060909@codemonkey.ws> Date: Mon, 12 Dec 2011 12:28:26 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1320872963-10402-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1320872963-10402-1-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] hw/usb-net.c: Fix precedence bug when checking rndis_state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: patches@linaro.org, qemu-devel@nongnu.org, Gerd Hoffmann On 11/09/2011 03:09 PM, Peter Maydell wrote: > "!X == 2" is always false (spotted by Coverity), so the checks > for whether rndis is in the correct state would never fire. > > Signed-off-by: Peter Maydell Applied. Thanks. Regards, Anthony Liguori > --- > NB that although I tested that this doesn't break non-rndis > usb-net, I don't have a test image that uses rndis usb-net, > so treat this patch with the appropriate degree of caution. > (Probably safer not putting it into 1.0 unless tested.) > > hw/usb-net.c | 5 +++-- > 1 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/hw/usb-net.c b/hw/usb-net.c > index a8b7c8d..f91fa32 100644 > --- a/hw/usb-net.c > +++ b/hw/usb-net.c > @@ -1268,8 +1268,9 @@ static ssize_t usbnet_receive(VLANClientState *nc, const uint8_t *buf, size_t si > > if (is_rndis(s)) { > msg = (struct rndis_packet_msg_type *) s->in_buf; > - if (!s->rndis_state == RNDIS_DATA_INITIALIZED) > + if (s->rndis_state != RNDIS_DATA_INITIALIZED) { > return -1; > + } > if (size + sizeof(struct rndis_packet_msg_type)> sizeof(s->in_buf)) > return -1; > > @@ -1302,7 +1303,7 @@ static int usbnet_can_receive(VLANClientState *nc) > { > USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque; > > - if (is_rndis(s)&& !s->rndis_state == RNDIS_DATA_INITIALIZED) { > + if (is_rndis(s)&& s->rndis_state != RNDIS_DATA_INITIALIZED) { > return 1; > } >