]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
bsearch.3: Use sizeof consistently
authorAlejandro Colomar <colomar.6.4.3@gmail.com>
Thu, 3 Sep 2020 19:43:23 +0000 (21:43 +0200)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 5 Sep 2020 12:49:42 +0000 (14:49 +0200)
Use ``sizeof`` consistently through all the examples in the following
way:

- Use the name of the variable instead of its type as argument for
  ``sizeof``.

Rationale:
https://www.kernel.org/doc/html/v5.8/process/coding-style.html#allocating-memory

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man3/bsearch.3

index 88e0e6ea17b6e2707c646d478091a244c7629854..6859bdba225834126c018bb0c0c2152a5225119c 100644 (file)
@@ -124,12 +124,12 @@ main(int argc, char **argv)
 {
     int i;
 
-    qsort(months, nr_of_months, sizeof(struct mi), compmi);
+    qsort(months, nr_of_months, sizeof(months[0]), compmi);
     for (i = 1; i < argc; i++) {
         struct mi key, *res;
         key.name = argv[i];
         res = bsearch(&key, months, nr_of_months,
-                      sizeof(struct mi), compmi);
+                      sizeof(months[0]), compmi);
         if (res == NULL)
             printf("\(aq%s\(aq: unknown month\en", argv[i]);
         else