aboutsummaryrefslogtreecommitdiffstats
path: root/stagit-index.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <[email protected]>2019-03-09 12:39:10 +0100
committerHiltjo Posthuma <[email protected]>2019-03-09 12:39:10 +0100
commitbb1d06eb204b1d1135fcddccd14f6306abcd7f72 (patch)
tree5750cbeb39fe817e2ac8a46bf2481874d852694c /stagit-index.c
parent587b01428d6ec2be1ab6b468198663118d483990 (diff)
downloadstagit-bb1d06eb204b1d1135fcddccd14f6306abcd7f72.tar.gz
stagit-bb1d06eb204b1d1135fcddccd14f6306abcd7f72.zip
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."
Diffstat (limited to 'stagit-index.c')
-rw-r--r--stagit-index.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/stagit-index.c b/stagit-index.c
index accb1a5..cc70e4d 100644
--- a/stagit-index.c
+++ b/stagit-index.c
@@ -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);
}