The return value of snprintf should be always nonnegative, so it should

be safe to cast it to a size_t before comparing it to a sizeof().
This commit is contained in:
David Malone 2002-07-28 15:41:15 +00:00
parent 47e9e6a168
commit 8015edeebb

View File

@ -234,7 +234,7 @@ newfile(void)
{ {
FILE *fp; FILE *fp;
if (snprintf(currfile, sizeof(currfile), "%s%0*ld", prefix, if ((size_t)snprintf(currfile, sizeof(currfile), "%s%0*ld", prefix,
(int)sufflen, nfiles) >= sizeof(currfile)) { (int)sufflen, nfiles) >= sizeof(currfile)) {
errno = ENAMETOOLONG; errno = ENAMETOOLONG;
err(1, NULL); err(1, NULL);