]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
stat-time: Use countof.
authorBruno Haible <bruno@clisp.org>
Mon, 11 May 2026 22:57:55 +0000 (00:57 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 11 May 2026 23:00:44 +0000 (01:00 +0200)
* lib/stat-time.h: Include <stdcountof.h>.
(stat_time_normalize): Use countof.
* modules/stat-time (Depends-on): Add stdcountof-h.
* modules/relocatable-prog-wrapper (Depends-on): Likewise.

ChangeLog
lib/stat-time.h
modules/relocatable-prog-wrapper
modules/stat-time

index 8bf96973037a78876dca1713d22b195df3407832..d5e8e6fb7416272de2f03f6feaa9069bef8c1216 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2026-05-11  Bruno Haible  <bruno@clisp.org>
 
+       stat-time: Use countof.
+       * lib/stat-time.h: Include <stdcountof.h>.
+       (stat_time_normalize): Use countof.
+       * modules/stat-time (Depends-on): Add stdcountof-h.
+       * modules/relocatable-prog-wrapper (Depends-on): Likewise.
+
        setlocale: Use countof.
        * lib/setlocale.c: Include <stdcountof.h>.
        (setlocale_unixlike, get_main_locale_with_same_language,
index 45364316645e05788a7566d0baf5925f8d804aaf..461a0c88b933ce4019843a41046b57239f949011 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <errno.h>
 #include <stdckdint.h>
+#include <stdcountof.h>
 #include <stddef.h>
 #include <sys/stat.h>
 #include <time.h>
@@ -232,7 +233,7 @@ stat_time_normalize (int result, _GL_UNUSED struct stat *st)
       short int const ts_off[] = { STAT_TIMESPEC_OFFSETOF (st_atim),
                                    STAT_TIMESPEC_OFFSETOF (st_mtim),
                                    STAT_TIMESPEC_OFFSETOF (st_ctim) };
-      for (int i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
+      for (int i = 0; i < countof (ts_off); i++)
         {
           struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]);
           long int q = ts->tv_nsec / timespec_hz;
index e37da6cc189d5f34c9a3eb9ad3747f5d36774ec1..346767d307589f81eb82d074cc6a3a2a7589fb56 100644 (file)
@@ -73,6 +73,7 @@ ssize_t
 bool
 stddef-h
 stdckdint-h
+stdcountof-h
 stdint-h
 stdlib-h
 string-h
index 424f33d48365e4493ba39ad9089981551385d2be..83722cd51c2e6dc2979fdc84acca1cf7828567cf 100644 (file)
@@ -12,6 +12,7 @@ errno-h
 extensions
 extern-inline
 stdckdint-h
+stdcountof-h
 
 configure.ac:
 gl_STAT_TIME