summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-08-12 08:22:47 +0000
committerJim Meyering <jim@meyering.net>2005-08-12 08:22:47 +0000
commit9a3ebcb54dc266d8905d97003bef44d4d82d646b (patch)
tree1328433140f5b7f7e7510df718269e4e68206133 /src
parent3623a168c480c2ec26109cd2c1d5fe88c64896f8 (diff)
downloadcoreutils-9a3ebcb54dc266d8905d97003bef44d4d82d646b.tar.xz
(long_time_expected_width): Don't test for failed localtime.
That cannot happen when the result date's year is in range. Add an assertion instead.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/ls.c b/src/ls.c
index dc01eaeba..561d7fe52 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -3068,13 +3068,15 @@ long_time_expected_width (void)
struct tm const *tm = localtime (&epoch);
char buf[TIME_STAMP_LEN_MAXIMUM + 1];
- if (tm)
- {
- size_t len =
- nstrftime (buf, sizeof buf, long_time_format[0], tm, 0, 0);
- if (len != 0)
- width = mbsnwidth (buf, len, 0);
- }
+ /* The above use of localtime cannot fail. */
+ assert (tm != NULL);
+
+ {
+ size_t len =
+ nstrftime (buf, sizeof buf, long_time_format[0], tm, 0, 0);
+ if (len != 0)
+ width = mbsnwidth (buf, len, 0);
+ }
if (width < 0)
width = 0;