]> git.sur5r.net Git - i3/i3status/commitdiff
strncpy + strlen is pointless (#312)
authorOrestis <orestisf1993@gmail.com>
Sun, 7 Oct 2018 18:26:24 +0000 (21:26 +0300)
committerMichael Stapelberg <stapelberg@users.noreply.github.com>
Sun, 7 Oct 2018 18:26:24 +0000 (20:26 +0200)
strlen already assumes that the string is NULL-terminated.

Fixes -Wstringop-overflow warning

i3status.c

index 76cb28084bf17291adf1a5b0dc33480120ce28ea..b83b1f3ab0660082bf2ef720638a32d06f4ead0c 100644 (file)
@@ -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);