Am 15.03.2014 00:36, schrieb David Laight: > On Fri, Mar 14, 2014 at 05:04:59PM -0500, Derek Martin wrote: >> >> I dislike those warnings because any half-competent programmer is >> aware of the *n* versions of functions, and if you chose not to use >> one there was probably a reason. Please, Mr. Compiler, please stop >> complaining about something I know is perfectly valid and not broken. >> More specifically, -Wall should not enable these warnings, you should >> have to explicitly turn them on separately, IMO. > > IIRC the warnings come from a property of the symbol in the linker > not the compiler... > > The dangerous functions are actually strncpy() and strncat() > neither of which does what is expected.
and later: > At some point there will be something nasty caused by the silent > truncation of strings. There are strlcpy and strlcat, which take the output buffer capacity, and permit checking if truncation happened or no. > snprintf() is a lot better than sprintf(), but calling any of > the alternatives 'safe' is a complete misnomer. As though you knew all of the alternatives. If you confine yourself to C89-sanctioned alternatives, well, yes, but see above for others. > OTOH generating a C++ exception is likely to be even nastier. > > Some system's header files have started forcing programs to check > the error returns from some library functions. > That gets to be a PITA - is some cases you really don't care. Cast to void. > Also any program that looks at the return value from fprintf() > is probably broken anyway! Why? Buffering doesn't make error checking useless.