Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751494AbdIEH5f (ORCPT ); Tue, 5 Sep 2017 03:57:35 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:52527 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750704AbdIEH5c (ORCPT ); Tue, 5 Sep 2017 03:57:32 -0400 From: Arnd Bergmann To: Felipe Balbi , Greg Kroah-Hartman Cc: Arnd Bergmann , Tatyana Brokhman , Felipe Balbi , Alan Stern , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: gadget: dummy: fix nonsensical comparisons Date: Tue, 5 Sep 2017 09:56:55 +0200 Message-Id: <20170905075720.771242-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:3GhXN3AbPuGYwkrnHLfCHvuq64e5Aipx8Mvtyd981Qxcw54KsPK XRkaSGrTge4OIJB+qkrSs/EmLNIiTjIkHtjgT9JmWz/MLNqdwUpTbmUDIciVa5K4gGvOYvH FUqR+lgpl9N+ttqJMPbeIPS3ih4RE4HFoiTFoZSqVNEQFXL7x71YlIyyUfGGYr7RoV0T1Gd w3P2K9AU4iMRyCwAErvAQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:MOdVDQZkn7g=:ani1d+2PIy9TTPi2Slbsgn PP8xhq7H1Kqej1ncYrgUu4BpzEsmUDRwR0mkF7YHHNTzJ2ScAPY1bnV/DfUvzxGTStYJ9OhEf P4Hv/b8AKEowQrDKNDWLPsWkKg5Bg6ONuLFVbld6y7ANREdxewkA9s09aeQrqlpKrNKwLWcSP ZFzRroJife84tyf3BqqvV58qq3w78pkNpC/BQ2QHYo1OfiGn5KB8tQITLWWYZS5fFMkXFCjj4 Z0JVxrY+5HP54fS8kZYw69xTAsoT5agGbr/s2ajJ6+bgJIWH/2bbNoi1rXiTVECSB0R6H0YNl lLdpmtUNuLoAM9HODaU96Akna1wgqu9iBLz7H4Qjs7FXGXYDo4kP+ZhG+SFu1Y08A1fPepYSE wDCnuvE4MYnttsEN9QgVP7T9zlZwA6it9wbyIIZUo7IDEKkNqt7OIpct34CP9SZHvRkgj4gpY YMEM8ay7ycU/bprR7+Tp4Sm+YIek2fvmB3DE3BQcFz6aX5YenRbCIuv5acnKNIY9O1n/dgDET yEJ0aZ4i3M2cnDWPbaFlbxXNOkHgJ4DLaeRVp3qBj0vKmdM0oaKNTCG8c0ATahpr0wSerW991 0s1PnEL/Kx2NNqgm3dSMg12LUdjmBhaRDADJS6VeiyXwOwCM9/fhZCDxDZDDW5DauxkEkB62n EidNu8mt8kGAr5tv471EasNGAuRiwDXx448rhsu07MEqCqNoPpcGrthsA/mugrO9ExzguSkfN /Z1LX0w7l1bqJkx/IiBWQFnm2sE0Js+xkOpxeg== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2127 Lines: 49 gcc-8 points out two comparisons that are clearly bogus and almost certainly not what the author intended to write: drivers/usb/gadget/udc/dummy_hcd.c: In function 'set_link_state_by_speed': drivers/usb/gadget/udc/dummy_hcd.c:379:31: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] USB_PORT_STAT_ENABLE) == 1 && ^~ drivers/usb/gadget/udc/dummy_hcd.c:381:25: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] USB_SS_PORT_LS_U0) == 1 && ^~ I looked at the code for a bit and came up with a change that makes it look like what the author probably meant here. This makes it look reasonable to me and to gcc, shutting up the warning. It does of course change behavior as the two conditions are actually evaluated rather than being hardcoded to false, and I have made no attempt at verifying that the changed logic makes sense in the context of a USB HCD, so that part needs to be reviewed carefully. Fixes: 1cd8fd2887e1 ("usb: gadget: dummy_hcd: add SuperSpeed support") Cc: Tatyana Brokhman Cc: Felipe Balbi Signed-off-by: Arnd Bergmann --- drivers/usb/gadget/udc/dummy_hcd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index a030d7923d7d..54e8e37d2bc8 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -376,10 +376,10 @@ static void set_link_state_by_speed(struct dummy_hcd *dum_hcd) dum_hcd->port_status |= (USB_PORT_STAT_C_CONNECTION << 16); if ((dum_hcd->port_status & - USB_PORT_STAT_ENABLE) == 1 && - (dum_hcd->port_status & - USB_SS_PORT_LS_U0) == 1 && - dum_hcd->rh_state != DUMMY_RH_SUSPENDED) + USB_PORT_STAT_ENABLE) == USB_PORT_STAT_ENABLE && + (dum_hcd->port_status & + USB_PORT_STAT_LINK_STATE) == USB_SS_PORT_LS_U0 && + dum_hcd->rh_state != DUMMY_RH_SUSPENDED) dum_hcd->active = 1; } } else { -- 2.9.0