]> granicus.if.org Git - strace/commitdiff
util: return pointer to string literal directly in sprinttime
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 1 Mar 2017 01:25:20 +0000 (02:25 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 21 Apr 2017 21:57:56 +0000 (21:57 +0000)
There is no sense to copy it to static buffer first.

* util.c (sprinttime): Just return "0", do not copy it to internal
buffer first.

util.c

diff --git a/util.c b/util.c
index 9144efb6368e0fd3902db490749443b3a6e11f3f..31336a42edbae07db1354c9c991daac7c903ad49 100644 (file)
--- a/util.c
+++ b/util.c
@@ -550,10 +550,8 @@ sprinttime(time_t t)
        struct tm *tmp;
        static char buf[sizeof(int) * 3 * 6 + sizeof("+0000")];
 
-       if (t == 0) {
-               strcpy(buf, "0");
-               return buf;
-       }
+       if (t == 0)
+               return "0";
        tmp = localtime(&t);
        if (tmp)
                strftime(buf, sizeof(buf), "%FT%T%z", tmp);