New answers tagged

3

Small review Bug case 'u': { ... *ptr = strtol_s(token, base, &strtolErr); can form the wrong value as strtol() can limit values to 231-1. Same with 'x'. Better to use strtoul(). Type conflagration long strtol_s() looks like a function to convert a string to long yet it errors when out of int range and is curiously used in the code only for ...


2

Your compiler should be smart enough to replace the division by multiplication. Here's an experiment I did with CLang on x86_64: #include <inttypes.h> uint8_t div8_100(uint8_t a) { return a / 100; } uint8_t div8_10(uint8_t a) { return a / 10; } clang -O3 -Wall -Weverything -S div8.c div8_100: movzbl %cl, %eax leal (%rax,%rax,4), %ecx ...


4

Potential bugs I just spent a few minutes reviewing this, so I'm not sure these are bugs, but you should have a look at them: The comma operator is not the same as &&. You have this code: for (int i = 0; i < ipSrcLen, addrIdx < 4; i++) { but I think you meant to use && instead of ,. I'm not sure it matters because I'm not sure what ...


Top 50 recent answers are included