---
 lib/lib.c            | 4 ++--
 scripts/install.c    | 2 +-
 toys/other/blkid.c   | 2 +-
 toys/other/modinfo.c | 6 +++---
 toys/pending/host.c  | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)
From df8077b78fa68b64316bd0cb409b34a3898eb69a Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Sun, 3 Mar 2019 22:42:26 -0800
Subject: [PATCH] Consistently use ARRAY_LEN.

---
 lib/lib.c            | 4 ++--
 scripts/install.c    | 2 +-
 toys/other/blkid.c   | 2 +-
 toys/other/modinfo.c | 6 +++---
 toys/pending/host.c  | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/lib.c b/lib/lib.c
index 76d5765c..54bfc8c4 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -907,7 +907,7 @@ int sig_to_num(char *pidstr)
 
     if (!strncasecmp(pidstr, "sig", 3)) pidstr+=3;
   }
-  for (i = 0; i < sizeof(signames)/sizeof(struct signame); i++)
+  for (i=0; i<ARRAY_LEN(signames); i++)
     if (!pidstr) xputs(signames[i].name);
     else if (!strcasecmp(pidstr, signames[i].name)) return signames[i].num;
 
@@ -918,7 +918,7 @@ char *num_to_sig(int sig)
 {
   int i;
 
-  for (i=0; i<sizeof(signames)/sizeof(struct signame); i++)
+  for (i=0; i<ARRAY_LEN(signames); i++)
     if (signames[i].num == sig) return signames[i].name;
   return NULL;
 }
diff --git a/scripts/install.c b/scripts/install.c
index 3ffb867d..ba47dd14 100644
--- a/scripts/install.c
+++ b/scripts/install.c
@@ -22,7 +22,7 @@ int main(int argc, char *argv[])
   int i, len = 0;
 
   // Output list of applets.
-  for (i=1; i<sizeof(toy_list)/sizeof(*toy_list); i++) {
+  for (i=1; i<ARRAY_LEN(toy_list); i++) {
     int fl = toy_list[i].flags;
     if (fl & TOYMASK_LOCATION) {
       if (argc>1) {
diff --git a/toys/other/blkid.c b/toys/other/blkid.c
index b791fa62..38559981 100644
--- a/toys/other/blkid.c
+++ b/toys/other/blkid.c
@@ -80,7 +80,7 @@ static void do_blkid(int fd, char *name)
     if (len != sizeof(toybuf)) return;
 
     // Iterate through types in range
-    for (i=0; i < sizeof(fstypes)/sizeof(struct fstype); i++) {
+    for (i=0; i<ARRAY_LEN(fstypes); i++) {
       uint64_t test;
 
       // Skip tests not in this 4k block
diff --git a/toys/other/modinfo.c b/toys/other/modinfo.c
index 126d1d63..eaf6cb98 100644
--- a/toys/other/modinfo.c
+++ b/toys/other/modinfo.c
@@ -51,18 +51,18 @@ static void modinfo_file(char *full_name)
   if (!buf) {
     perror_msg_raw(full_name);
     return;
-  } 
+  }
 
   output_field("filename", full_name);
 
   for (pos = buf; pos < buf+len; pos++) {
     if (*pos) continue;
 
-    for (i = 0; i < sizeof(modinfo_tags) / sizeof(*modinfo_tags); i++) {
+    for (i=0; i<ARRAY_LEN(modinfo_tags); i++) {
       char *str = modinfo_tags[i];
       int len = strlen(str);
 
-      if (!strncmp(pos+1, str, len) && pos[len+1] == '=') 
+      if (!strncmp(pos+1, str, len) && pos[len+1] == '=')
         output_field(str, pos+len+2);
     }
   }
diff --git a/toys/pending/host.c b/toys/pending/host.c
index 96daf8e8..fa830a7d 100644
--- a/toys/pending/host.c
+++ b/toys/pending/host.c
@@ -103,7 +103,7 @@ void host_main(void)
   if (TT.type_str[0]-'0' < 10u) type = atoi(TT.type_str);
   else {
     type = -1;
-    for (i=0; i < sizeof rrt / sizeof *rrt; i++) {
+    for (i=0; i<ARRAY_LEN(rrt); i++) {
       if (rrt[i].name && !strcasecmp(TT.type_str, rrt[i].name)) {
         type = i;
         break;
-- 
2.21.0.352.gf09ad66450-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to