Message ID | 1464861516-8928-1-git-send-email-nikunj@linux.vnet.ibm.com |
---|---|
State | Superseded |
Headers | show |
On 02/06/2016 11:58, Nikunj A Dadhania wrote: > Static analysis tool reported: > > file lib/libusb/usb-xhci.c > line 1022 > uninitialized `field4' > > file lib/libusb/usb-xhci.c > line 1036 > uninitialized `field4' > > Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> > --- > lib/libusb/usb-xhci.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c > index 3bbc9af..f8b1996 100644 > --- a/lib/libusb/usb-xhci.c > +++ b/lib/libusb/usb-xhci.c > @@ -1012,7 +1012,7 @@ static void fill_setup_trb(struct xhci_command_trb *cmd, struct usb_dev_req *req > static void fill_setup_data(struct xhci_command_trb *cmd, void *data, > uint32_t size, uint32_t dir) > { > - uint32_t field1, field2, field3, field4; > + uint32_t field1, field2, field3, field4 = 0; > > field1 = TRB_ADDR_LOW(data); > field2 = TRB_ADDR_HIGH(data); Perhaps you can do instead: field4 = TRB_CMD_TYPE(TRB_DATA_STAGE); if (dir) field4 |= TRB_DIR_IN; > @@ -1025,7 +1025,7 @@ static void fill_setup_data(struct xhci_command_trb *cmd, void *data, > > static void fill_status_trb(struct xhci_command_trb *cmd, uint32_t dir) > { > - uint32_t field1, field2, field3, field4; > + uint32_t field1, field2, field3, field4 = 0; > > field1 = 0; > field2 = 0; > or: field4 = TRB_CMD_TYPE(TRB_STATUS_STAGE) | TRB_IOC; if (dir) field4 |= TRB_DIR_IN; Laurent
Laurent Vivier <lvivier@redhat.com> writes: > On 02/06/2016 11:58, Nikunj A Dadhania wrote: >> Static analysis tool reported: >> >> file lib/libusb/usb-xhci.c >> line 1022 >> uninitialized `field4' >> >> file lib/libusb/usb-xhci.c >> line 1036 >> uninitialized `field4' >> >> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> >> --- >> lib/libusb/usb-xhci.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c >> index 3bbc9af..f8b1996 100644 >> --- a/lib/libusb/usb-xhci.c >> +++ b/lib/libusb/usb-xhci.c >> @@ -1012,7 +1012,7 @@ static void fill_setup_trb(struct xhci_command_trb *cmd, struct usb_dev_req *req >> static void fill_setup_data(struct xhci_command_trb *cmd, void *data, >> uint32_t size, uint32_t dir) >> { >> - uint32_t field1, field2, field3, field4; >> + uint32_t field1, field2, field3, field4 = 0; >> >> field1 = TRB_ADDR_LOW(data); >> field2 = TRB_ADDR_HIGH(data); > > Perhaps you can do instead: > > field4 = TRB_CMD_TYPE(TRB_DATA_STAGE); > if (dir) > field4 |= TRB_DIR_IN; > >> @@ -1025,7 +1025,7 @@ static void fill_setup_data(struct xhci_command_trb *cmd, void *data, >> >> static void fill_status_trb(struct xhci_command_trb *cmd, uint32_t dir) >> { >> - uint32_t field1, field2, field3, field4; >> + uint32_t field1, field2, field3, field4 = 0; >> >> field1 = 0; >> field2 = 0; >> > > or: > > field4 = TRB_CMD_TYPE(TRB_STATUS_STAGE) | TRB_IOC; > if (dir) > field4 |= TRB_DIR_IN; Right, both will be same affect, not very particular though. Nikunj
diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c index 3bbc9af..f8b1996 100644 --- a/lib/libusb/usb-xhci.c +++ b/lib/libusb/usb-xhci.c @@ -1012,7 +1012,7 @@ static void fill_setup_trb(struct xhci_command_trb *cmd, struct usb_dev_req *req static void fill_setup_data(struct xhci_command_trb *cmd, void *data, uint32_t size, uint32_t dir) { - uint32_t field1, field2, field3, field4; + uint32_t field1, field2, field3, field4 = 0; field1 = TRB_ADDR_LOW(data); field2 = TRB_ADDR_HIGH(data); @@ -1025,7 +1025,7 @@ static void fill_setup_data(struct xhci_command_trb *cmd, void *data, static void fill_status_trb(struct xhci_command_trb *cmd, uint32_t dir) { - uint32_t field1, field2, field3, field4; + uint32_t field1, field2, field3, field4 = 0; field1 = 0; field2 = 0;
Static analysis tool reported: file lib/libusb/usb-xhci.c line 1022 uninitialized `field4' file lib/libusb/usb-xhci.c line 1036 uninitialized `field4' Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> --- lib/libusb/usb-xhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)