Spot the bug: wchar_t buf[123]; swprintf(buf, sizeof buf, "%s/%d", str, num);
-
-
Replying to @RichFelker
sizeof can be avoided by using a named constant for the length
1 reply 0 retweets 0 likes -
Replying to @tyroxxxx
That's much worse. It creates an obligation to keep multiple things consistent, and it's not genericizable.
1 reply 0 retweets 0 likes -
-
Replying to @tyroxxxx
Now you need a convention for naming the length of each buffer object/struct-field, a way to namespace them, ...
1 reply 0 retweets 0 likes -
Replying to @RichFelker @tyroxxxx
...and if you accidentally mix up which goes with which, you have buffer overflows. snprintf(buf, sizeof buf, ...) is always ok.
1 reply 0 retweets 0 likes -
Replying to @RichFelker
ok, the constant works only for local arrays. The other obvious improvement over sizeof is an ARRAY_LENGTH macro.
1 reply 0 retweets 0 likes -
Replying to @RichFelker @tyroxxxx
But when ppl have to remember to use a countof rather than a sizeof, you have a security UX problem for programmers.
1 reply 0 retweets 0 likes -
Replying to @RichFelker
is there anything in C that is not a security UX problem?
1 reply 0 retweets 0 likes
Every interface not involving any pointers.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.