util: return pointer to string literal directly in sprinttime

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.
This commit is contained in:
Eugene Syromyatnikov 2017-03-01 02:25:20 +01:00 committed by Dmitry V. Levin
parent 39f5742468
commit 0f07b184c8

6
util.c
View File

@ -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);