Skip to content

Commit b1f42f2

Browse files
jeremybettismmahadevan108
authored andcommitted
drivers: Fix uninitialized variable warning.
In GCC 14.2.0, the keyvariable in usb_dc_ep_write is detected to be used before initialization, even though this usage should be safe. Fix by initializing the key variable to 0, and making the 2 if statements explicitly checking the same value. Signed-off-by: Jeremy Bettis <[email protected]>
1 parent 135214d commit b1f42f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/usb/device/usb_dc_it82xx2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ int usb_dc_ep_write(uint8_t ep, const uint8_t *buf,
13221322
{
13231323
struct usb_it82xx2_regs *const usb_regs = it82xx2_get_usb_regs();
13241324
struct it82xx2_usb_ep_fifo_regs *ff_regs = usb_regs->fifo_regs;
1325-
unsigned int key;
1325+
unsigned int key = 0;
13261326
uint8_t ep_idx = USB_EP_GET_IDX(ep);
13271327
uint8_t ep_fifo = (ep_idx > 0) ? (ep_fifo_res[ep_idx % FIFO_NUM]) : 0;
13281328

@@ -1369,7 +1369,7 @@ int usb_dc_ep_write(uint8_t ep, const uint8_t *buf,
13691369
}
13701370

13711371
it82xx2_usb_set_ep_ctrl(ep_idx, EP_READY_ENABLE, true);
1372-
if (ep_idx != 0) {
1372+
if (ep_idx != EP0) {
13731373
irq_unlock(key);
13741374
}
13751375

0 commit comments

Comments
 (0)