Re: [PATCH net 08/10] can: esd_usb: Fix not detecting version reply in probe routine
From: Stefan Mätje <stefan.maetje@esd.eu>
Date: 2025-09-24 10:05:27
Also in:
linux-can
Am Montag, dem 22.09.2025 um 17:16 -0700 schrieb Jakub Kicinski:
On Mon, 22 Sep 2025 12:07:38 +0200 Marc Kleine-Budde wrote:quoted
+ do { + int actual_length; + int pos; + + err = usb_bulk_msg(dev->udev, + usb_rcvbulkpipe(dev->udev, 1), + rx_buf, + ESD_USB_RX_BUFFER_SIZE, + &actual_length, + ESD_USB_DRAIN_TIMEOUT_MS); + dev_dbg(&dev->udev->dev, "AT %d, LEN %d, ERR %d\n", attempt, actual_length, err); + ++attempt; + if (err) + goto bail; + if (actual_length == 0) + continue;continue in do-while loops doesn't check the condition. This looks like a potential infinite loop?
I don't think so. A continue statement in a do, while or for loop always jumps to the end of the loop body. See a citation of the C standard there: https://stackoverflow.com/a/64120354 Therefore there is no potential for an infinite loop due to the continue statement. Refer to following code and its output: ---------------------------------------------- #include <stdio.h> #define LIMIT 4 int main(void) { int cnt = 0; do { printf("Top: %d\n", cnt); ++cnt; if (cnt > 2) continue; printf("Bottom: %d\n", cnt); } while (printf("Condition: %d\n\n", cnt), cnt < LIMIT); return 0; } ---------------------------------------------- Output: ---------------------------------------------- stefanm@pc-stefanm64:~/Tmp$ ./do_continue Top: 0 Bottom: 1 Condition: 1 Top: 1 Bottom: 2 Condition: 2 Top: 2 Condition: 3 Top: 3 Condition: 4 ---------------------------------------------- Sorry being late with this. Best regards, Stefan