From: Eugene Syromyatnikov Date: Wed, 1 Mar 2017 01:25:20 +0000 (+0100) Subject: util: return pointer to string literal directly in sprinttime X-Git-Tag: v4.17~41 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f07b184c8eae23d72f3aeec94fa927c2db0b1c0;p=strace 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. --- diff --git a/util.c b/util.c index 9144efb6..31336a42 100644 --- 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);