chiark / gitweb /
C89 friendly declarations
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 17 Nov 2013 10:52:17 +0000 (10:52 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 17 Nov 2013 10:52:17 +0000 (10:52 +0000)
Again, not a complete sweep.

clients/disorder.c
lib/addr.c
lib/client.c
lib/configuration.c
lib/queue.c
lib/vector.c

index 36af9f5eed5cbf44c019e7962a74ad6cbc5203bf..949eacf7cb2a2dda9c49cf7399f852aff183ba6d 100644 (file)
@@ -319,9 +319,10 @@ static void cf_random_enable(char attribute((unused)) **argv) {
 static void cf_stats(char attribute((unused)) **argv) {
   char **vec;
   int nvec;
+  int n;
 
   if(disorder_stats(getclient(), &vec, &nvec)) exit(EXIT_FAILURE);
-  for(int n = 0; n < nvec; ++n)
+  for(n = 0; n < nvec; ++n)
     xprintf("%s\n", nullcheck(utf82mb(vec[n])));
   free_strings(nvec, vec);
 }
@@ -629,10 +630,11 @@ static void cf_adopt(char **argv) {
 static void cf_playlists(char attribute((unused)) **argv) {
   char **vec;
   int nvec;
+  int n;
 
   if(disorder_playlists(getclient(), &vec, &nvec))
     exit(EXIT_FAILURE);
-  for(int n = 0; n < nvec; ++n)
+  for(n = 0; n < nvec; ++n)
     xprintf("%s\n", nullcheck(utf82mb(vec[n])));
   free_strings(nvec, vec);
 }
@@ -645,10 +647,11 @@ static void cf_playlist_del(char **argv) {
 static void cf_playlist_get(char **argv) {
   char **vec;
   int nvec;
+  int n;
 
   if(disorder_playlist_get(getclient(), argv[0], &vec, &nvec))
     exit(EXIT_FAILURE);
-  for(int n = 0; n < nvec; ++n)
+  for(n = 0; n < nvec; ++n)
     xprintf("%s\n", nullcheck(utf82mb(vec[n])));
   free_strings(nvec, vec);
 }
index d1c9d011db7382befb4dbac82e32d4ba5adbabbb..bb4f06cdbd8ab7f8514b988c053a9bf645d95048 100644 (file)
@@ -232,6 +232,8 @@ int netaddress_parse(struct netaddress *na,
                     int nvec,
                     char **vec) {
   const char *port;
+  long p;
+  int e;
 
   na->af = AF_UNSPEC;
   if(nvec > 0 && vec[0][0] == '-') {
@@ -282,8 +284,7 @@ int netaddress_parse(struct netaddress *na,
     }
     if(port[strspn(port, "0123456789")])
       return -1;
-    long p;
-    int e = xstrtol(&p, port, NULL, 10);
+    e = xstrtol(&p, port, NULL, 10);
 
     if(e)
       return -1;
index 08d70e762c1c37a87c2bf2c54638f354e8da1342..7ae0d07dd68b6ee4753ba7d64657fd24c5287917 100644 (file)
@@ -231,11 +231,12 @@ static int disorder_simple_v(disorder_client *c,
       } else if(arg == disorder__list) {
        char **list = va_arg(ap, char **);
        int nlist = va_arg(ap, int);
+        int n;
        if(nlist < 0) {
          for(nlist = 0; list[nlist]; ++nlist)
            ;
        }
-       for(int n = 0; n < nlist; ++n) {
+       for(n = 0; n < nlist; ++n) {
          dynstr_append(&d, ' ');
          dynstr_append_string(&d, quoteutf8(arg));
        }
@@ -263,10 +264,11 @@ static int disorder_simple_v(disorder_client *c,
       goto write_error;
     xfree(d.vec);
     if(has_body) {
+      int n;
       if(nbody < 0)
         for(nbody = 0; body[nbody]; ++nbody)
           ;
-      for(int n = 0; n < nbody; ++n) {
+      for(n = 0; n < nbody; ++n) {
         if(body[n][0] == '.')
           if(fputc('.', c->fpout) < 0)
             goto write_error;
index c2c9a9f69b4d7ed8a83ae5e2df6b2a04b22a4388..19a84a24dbac85385097275a079f5081e1f23c17 100644 (file)
@@ -1140,6 +1140,7 @@ static int config_set_args(const struct config_state *cs,
   va_list ap;
   struct vector v[1];
   char *s;
+  int rc;
 
   vector_init(v);
   vector_append(v, (char *)which);
@@ -1148,7 +1149,7 @@ static int config_set_args(const struct config_state *cs,
     vector_append(v, s);
   va_end(ap);
   vector_terminate(v);
-  int rc = config_set(cs, v->nvec, v->vec);
+  rc = config_set(cs, v->nvec, v->vec);
   xfree(v->vec);
   return rc;
 }
@@ -1698,7 +1699,8 @@ static int namepartlist_compare(const struct namepartlist *a,
 */
 int config_verify(void) {
   int fails = 0;
-  for(size_t n = 1; n < sizeof conf / sizeof *conf; ++n)
+  size_t n;
+  for(n = 1; n < sizeof conf / sizeof *conf; ++n)
     if(strcmp(conf[n-1].name, conf[n].name) >= 0) {
       fprintf(stderr, "%s >= %s\n", conf[n-1].name, conf[n].name);
       ++fails;
index 789d2eaa7120581824ee16ef55ee3c0e6cc59f86..c592f5a13a4e949f516e7106550dcf014720ac70 100644 (file)
@@ -234,12 +234,12 @@ int queue_unmarshall(struct queue_entry *q, const char *s,
                     void (*error_handler)(const char *, void *),
                     void *u) {
   char **vec;
-  int nvec;
+  int nvec, rc;
 
   q->pid = -1;                          /* =none */
   if(!(vec = split(s, &nvec, SPLIT_QUOTES, error_handler, u)))
     return -1;
-  int rc = queue_unmarshall_vec(q, nvec, vec, error_handler, u);
+  rc = queue_unmarshall_vec(q, nvec, vec, error_handler, u);
   free_strings(nvec, vec);
   return rc;
 }
@@ -291,11 +291,12 @@ char *queue_marshall(const struct queue_entry *q) {
 }
 
 void queue_free(struct queue_entry *q, int rest) {
+  unsigned n;
   if(!q)
     return;
   if(rest)
     queue_free(q->next, rest);
-  for(unsigned n = 0; n < NFIELDS; ++n)
+  for(n = 0; n < NFIELDS; ++n)
     fields[n].free(q, fields[n].offset);
   xfree(q);
 }
index fa8f9e388df6d0c90f157eacc94c7e14d6db4cd7..0d1dd4eb90493d6bc311ef7a73c99d98593e7443 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2007-2009 Richard Kettlewell
+ * Copyright (C) 2004, 2007-2009, 2013 Richard Kettlewell
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -40,7 +40,8 @@ void dynstr_append_bytes(struct dynstr *v, const char *ptr, size_t n) {
 
 /** @brief Free a string list */
 void free_strings(int nvec, char **vec) {
-  for(int n = 0; n < nvec; ++n)
+  int n;
+  for(n = 0; n < nvec; ++n)
     xfree(vec[n]);
   xfree(vec);
 }