From: Orestis Date: Sun, 7 Oct 2018 18:26:24 +0000 (+0300) Subject: strncpy + strlen is pointless (#312) X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=494efd49a26ed96d7b0d3d4f69099ccd83e2ccba;p=i3%2Fi3status strncpy + strlen is pointless (#312) strlen already assumes that the string is NULL-terminated. Fixes -Wstringop-overflow warning --- diff --git a/i3status.c b/i3status.c index 76cb280..b83b1f3 100644 --- a/i3status.c +++ b/i3status.c @@ -227,9 +227,10 @@ static char *resolve_tilde(const char *path) { } else { head = globbuf.gl_pathv[0]; result = scalloc(strlen(head) + (tail ? strlen(tail) : 0) + 1); - strncpy(result, head, strlen(head)); - if (tail) - strncat(result, tail, strlen(tail)); + strcpy(result, head); + if (tail) { + strcat(result, tail); + } } globfree(&globbuf);