09/03/2022 16:24, Rahul Bhansali: > Hi Thomas, > > From: Thomas Monjalon <tho...@monjalon.net> > > 11/01/2022 13:50, Rahul Bhansali: > > > /* copy rest of the packets into the TX buffer. */ > > > len = num - n; > > > + if (len == 0) > > > + goto exit; > > > + > > > > I don't understand how it can fix something. > > There is already "while (j < len)" with j and len being 0, the loop should > > not be > > effective in this case. > > This Switch will execute Case statement first even before considering the > while condition or anything else before case statement. While condition will > be executed only after all switch cases are executed.
I don't know this construct. Is it part of the C standard? We learn something everyday :) > Hence in case of len = 0 and n > 28, it is throwing stack buffer overflow > error. > > Below is sample code to simulate the while loop behavior inside switch. > Checked it for both x86 and arm64. > https://godbolt.org/z/4Kecqbsde > > > > > > j = 0; > > > switch (len % FWDSTEP) { > > > while (j < len) {