Simo Sorce wrote: > If you really want to avoid the warning instead of ignoring it, you > should change the code this way: > > strncpy(t->name, name, MAX_TUBE_NAME_LEN-1); > if (t->name[MAX_TUBE_NAME_LEN - 2] != '\0') { > t->name[MAX_TUBE_NAME_LEN - 1] = '\0'; > twarnx("truncating tube name"); > } That code will warn wrongly about truncation when the name is exactly MAX_TUBE_NAME_LEN - 1 bytes long. Nathanael, you could link to libbsd and use strlcpy if that's available on all target platforms. Or, if you happen to be using Glib, use g_strlcpy. Otherwise use Peter's snprintf solution, but DO NOT make the mistake of passing the input as the format string! And choose a better language than C for your next project. Björn Persson
Attachment:
pgpVmR4K7R95Q.pgp
Description: OpenPGP digital signatur
_______________________________________________ devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx