1 |
commit: faaf0b2f02f3403cc727cd360e4dbf5509812735 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Mar 27 18:22:58 2016 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Mar 27 18:22:58 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=faaf0b2f |
7 |
|
8 |
qlop: slight ctime speedup |
9 |
|
10 |
qlop.c | 7 +++---- |
11 |
1 file changed, 3 insertions(+), 4 deletions(-) |
12 |
|
13 |
diff --git a/qlop.c b/qlop.c |
14 |
index dbbae06..ad62474 100644 |
15 |
--- a/qlop.c |
16 |
+++ b/qlop.c |
17 |
@@ -75,10 +75,9 @@ _q_static const char * |
18 |
chop_ctime(time_t t) |
19 |
{ |
20 |
static char ctime_out[50]; |
21 |
- char *p; |
22 |
- snprintf(ctime_out, sizeof(ctime_out), "%s", ctime(&t)); |
23 |
- if ((p = strchr(ctime_out, '\n')) != NULL) |
24 |
- *p = '\0'; |
25 |
+ int ret = snprintf(ctime_out, sizeof(ctime_out), "%s", ctime(&t)); |
26 |
+ /* Assume no error! */ |
27 |
+ ctime_out[ret - 1] = '\0'; |
28 |
return ctime_out; |
29 |
} |