]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(long_time_expected_width): Don't test for failed localtime.
authorJim Meyering <jim@meyering.net>
Fri, 12 Aug 2005 08:22:47 +0000 (08:22 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 12 Aug 2005 08:22:47 +0000 (08:22 +0000)
That cannot happen when the result date's year is in range.
Add an assertion instead.

src/ls.c

index dc01eaeba7741a62085ac877ada0f32bd853e049..561d7fe526e4b7a899c9a4817917a6dd69f462c5 100644 (file)
--- 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;