chiark / gitweb /
checkpath,c, chpath.c, tmpdir.c: : Hoist declarations to function head.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 16 Jul 2024 17:42:56 +0000 (18:42 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 17 Jul 2024 12:23:10 +0000 (13:23 +0100)
checkpath.c
chkpath.c
tmpdir.c

index d874246025f69ed4b69fe14259226569304a88fa..440a6ab2a9faf6945db529e6637f554456240e32 100644 (file)
@@ -87,9 +87,9 @@ static dstr d = DSTR_INIT;            /* Current path string */
 static struct elt *splitpath(const char *path, struct elt *tail)
 {
   struct elt *head, **ee = &head, *e;
+  size_t n;
 
   while (*path) {
-    size_t n;
 
     /* --- Either a leading `/', or a doubled one --- *
      *
@@ -353,6 +353,7 @@ unsigned checkpath(const char *p, const struct checkpath *cp)
   struct stat st;
   unsigned bad = 0;
   dstr buf = DSTR_INIT;
+  int i;
 
   /* --- Initialize stack pointer and path string --- */
 
@@ -420,7 +421,6 @@ unsigned checkpath(const char *p, const struct checkpath *cp)
     /* --- Handle symbolic links specially --- */
 
     if (S_ISLNK(st.st_mode)) {
-      int i;
 
       /* --- Resolve the link --- */
 
index c5ef46ebe48d1acbb1587419695f12f8886c645f..a7158d3c7efb3978fc7813e0f9dd957b630c3e03 100644 (file)
--- a/chkpath.c
+++ b/chkpath.c
@@ -133,8 +133,8 @@ int main(int argc, char *argv[])
       { "verbose",     0,              0,      'v' },
       { 0,             0,              0,      0 }
     };
-    int i = mdwopt(argc, argv, "hVu" "g:pqstv", opts, 0, 0, 0);
 
+    i = mdwopt(argc, argv, "hVu" "g:pqstv", opts, 0, 0, 0);
     if (i < 0)
       break;
     switch (i) {
index c561c1c1e609b379ba5874fbb6796d50dc881a05..18eb4400c34b8ba95c36489fd9850de9c1fff76a 100644 (file)
--- a/tmpdir.c
+++ b/tmpdir.c
@@ -311,6 +311,7 @@ int main(int argc, char *argv[])
 {
   int shell = 0;
   int duff = 0;
+  int i;
   char *p;
 
   enum {
@@ -348,8 +349,8 @@ int main(int argc, char *argv[])
       { "verbose",     0,              0,      'v' },
       { 0,             0,              0,      0 }
     };
-    int i = mdwopt(argc, argv, "hVu" "C:bcg:v", opts, 0, 0, 0);
 
+    i = mdwopt(argc, argv, "hVu" "C:bcg:v", opts, 0, 0, 0);
     if (i < 0)
       break;
     switch (i) {