On Sat, Mar 15, 2014 at 12:21:40AM +0100, Matthias Andree wrote: > Am 15.03.2014 00:36, schrieb David Laight: > > IIRC the warnings come from a property of the symbol in the linker > > not the compiler...
That doesn't make it better. ;)
> There are strlcpy and strlcat, which take the output buffer capacity,
> and permit checking if truncation happened or no.
$ cat strjunk.c
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char *a = "foo";
char *b = "bar";
char c[7];
strlcpy(a, c, 7);
strlcat(b, c, 7);
printf("%s\n", c);
return 0;
}
$ gcc -o sj strjunk.c
[...]/ccW4BTCh.o: In function `main':
strjunk.c:(.text+0x38): undefined reference to `strlcpy'
strjunk.c:(.text+0x55): undefined reference to `strlcat'
collect2: ld returned 1 exit status
So... not so helpful.
> > OTOH generating a C++ exception is likely to be even nastier.
Indeed.
> > 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.
That's not any less annoying than checking a return value you don't
care about. It's 6 useless characters, * many occurences in your
program.
--
Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address. Replying to it will result in
undeliverable mail due to spam prevention. Sorry for the inconvenience.
pgphi4z0_J77m.pgp
Description: PGP signature
