]> granicus.if.org Git - fortune-mod/commitdiff
Avoid predeclaring variables and localize their decl.
authorShlomi Fish <shlomif@shlomifish.org>
Wed, 29 Apr 2020 08:32:07 +0000 (11:32 +0300)
committerShlomi Fish <shlomif@shlomifish.org>
Wed, 29 Apr 2020 08:32:07 +0000 (11:32 +0300)
See:

* http://perl-begin.org/tutorials/bad-elements/#declaring_all_vars_at_top

* https://en.wikipedia.org/wiki/Perl_Best_Practices

fortune-mod/util/strfile.c

index 6c31816b625dfc8fd229ca7b18c9bdee592414f9..4ba18e1efddd0eab4f88e238794f0ea5ed6fe840 100644 (file)
@@ -357,7 +357,6 @@ int main(int ac, char **av)
 {
     char *sp;
     FILE *inf, *outf;
-    int32_t *p;
     STR *fp;
     bool len_was_set = false;
 
@@ -512,7 +511,7 @@ int main(int ac, char **av)
     if (storing_ptrs())
     {
         int cnt = (int)Num_pts;
-        for (p = Seekpts; cnt--; ++p)
+        for (int32_t *p = Seekpts; cnt--; ++p)
         {
             *p = (int32_t)htonl((uint32_t)*p);
             fwrite(p, sizeof *p, 1, outf);