]> granicus.if.org Git - zfs/commitdiff
Fix `zpool iostat -T d 1` on musl
authorRichard Yao <ryao@gentoo.org>
Sun, 9 Apr 2017 19:00:03 +0000 (15:00 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 12 Apr 2017 15:57:46 +0000 (08:57 -0700)
When building on Gentoo against musl, GCC complains:

timestamp.c: In function ‘print_timestamp’:
timestamp.c:32:19: warning: passing argument 1 of ‘nl_langinfo’ makes
integer from pointer without a cast
 #define _DATE_FMT "%+"
                   ^
timestamp.c:47:21: note: in expansion of macro ‘_DATE_FMT’
   fmt = nl_langinfo(_DATE_FMT);
                     ^
The error was wrapped to meet comment style requirements.

This code is used by `zpool iostat -T d 1` to print a date and upon
testing it, I see no date printed. Lets use D_T_FMT so that something
gets printed and if D_T_FMT is not avaliable, then we can fall back to
"%+".

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Closes #5993

lib/libspl/timestamp.c

index e2838da121f3de46286bb2f91205ac14c318faf8..eab15f3f13f915ef9407e8187871bfc1d557b034 100644 (file)
 #include "statcommon.h"
 
 #ifndef _DATE_FMT
+#ifdef D_T_FMT
+#define        _DATE_FMT D_T_FMT
+#else /* D_T_FMT */
 #define        _DATE_FMT "%+"
-#endif
+#endif /* !D_T_FMT */
+#endif /* _DATE_FMT */
 
 /*
  * Print timestamp as decimal reprentation of time_t value (-T u was specified)