pedantic snprintf() improvement

POSIX says:
"If an output error was encountered, these functions shall return a negative
value and set errno to indicate the error."
This commit is contained in:
Hiltjo Posthuma
2019-03-09 12:39:10 +01:00
parent 587b01428d
commit bb1d06eb20
2 changed files with 4 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
r = snprintf(buf, bufsiz, "%s%s%s",
path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
if (r == -1 || (size_t)r >= bufsiz)
if (r < 0 || (size_t)r >= bufsiz)
errx(1, "path truncated: '%s%s%s'",
path, path[0] && path[strlen(path) - 1] != '/' ? "/" : "", path2);
}