Minor code cleanups suggested by NetBSD lint:
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 25 Apr 2010 07:40:36 +0000 (07:40 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 25 Apr 2010 07:40:36 +0000 (07:40 +0000)
 - some commas at the end of enum declarations removed.
 - some unused statements and variables removed
 - some more careful typing of query expressions in index.c.
   (Writing 'condition ? (ptrtype *)stuff : NULL' doesn't give the
   overall expression type 'ptrtype *'; it's better to put the cast
   outside the ?:.)

git-svn-id: svn://svn.tartarus.org/sgt/agedu@8928 cda61777-01e9-0310-a592-d414129be87e

agedu.c
httpd.c
index.c
trie.c

diff --git a/agedu.c b/agedu.c
index a3b9904..08286a5 100644 (file)
--- a/agedu.c
+++ b/agedu.c
@@ -393,8 +393,8 @@ enum { OPTIONS(IGNORE,IGNORE,IGNORE,LONGTMP) NLONGOPTS };
 static const int opthasval[NOPTIONS] = {OPTIONS(ZERO,ONE,IGNORE,IGNORE)};
 static const char shortopts[] = {OPTIONS(IGNORE,IGNORE,STRINGNOCOMMA,IGNORE)};
 static const char *const longopts[] = {OPTIONS(IGNORE,IGNORE,IGNORE,STRING)};
-enum { OPTIONS(SHORTNEWOPT,SHORTNEWOPT,SHORTTHISOPT,IGNORE) };
-enum { OPTIONS(LONGNEWOPT,LONGNEWOPT,IGNORE,LONGTHISOPT) };
+enum { OPTIONS(SHORTNEWOPT,SHORTNEWOPT,SHORTTHISOPT,IGNORE) UNUSEDENUMVAL1 };
+enum { OPTIONS(LONGNEWOPT,LONGNEWOPT,IGNORE,LONGTHISOPT) UNUSEDENUMVAL2 };
 static const int shortvals[] = {OPTIONS(IGNORE,IGNORE,SHORTOPTVAL,IGNORE)};
 static const int longvals[] = {OPTIONS(IGNORE,IGNORE,IGNORE,LONGOPTVAL)};
 
@@ -664,8 +664,6 @@ int main(int argc, char **argv)
 
                        for (i = 0; licence[i]; i++)
                            fputs(licence[i], stdout);
-
-                       return 0;
                    }
                    return 0;
                  case OPT_SCAN:
@@ -1133,6 +1131,7 @@ int main(int argc, char **argv)
                prevbuf[0] = '\0';
                tf = triewalk_next(tw, buf);
                assert(tf);
+               prevtf = NULL;         /* placate lint */
                while (1) {
                    int i;
 
diff --git a/httpd.c b/httpd.c
index 90d4e42..aa40084 100644 (file)
--- a/httpd.c
+++ b/httpd.c
@@ -90,7 +90,7 @@ char *got_data(struct connctx *ctx, char *data, int length,
               const struct html_config *cfg)
 {
     char *line, *p, *q, *r, *z1, *z2, c1, c2;
-    int auth_provided = 0, auth_correct = 0;
+    int auth_correct = 0;
     unsigned long index;
     char *document, *ret;
 
@@ -235,7 +235,6 @@ char *got_data(struct connctx *ctx, char *data, int length,
                    p = q;
            }
            if (p < q) {
-               auth_provided = 1;
                while (p < q && isspace((unsigned char)*p))
                    p++;
                r = p;
@@ -414,7 +413,6 @@ void run_httpd(const void *t, int authmask, const struct httpd_config *dcfg,
     int fd, ret;
     int authtype;
     char *authstring = NULL;
-    struct fd *f;
     struct sockaddr_in addr;
     socklen_t addrlen;
     struct html_config cfg = *incfg;
@@ -575,7 +573,7 @@ void run_httpd(const void *t, int authmask, const struct httpd_config *dcfg,
     /*
      * Now construct an fd structure to hold it.
      */
-    f = new_fdstruct(fd, FD_LISTENER);
+    new_fdstruct(fd, FD_LISTENER);
 
     /*
      * Read from standard input, and treat EOF as a notification
diff --git a/index.c b/index.c
index a74c165..f4b9801 100644 (file)
--- a/index.c
+++ b/index.c
@@ -69,11 +69,11 @@ struct indexbuild {
 };
 
 #define ELEMENT(t,offset) \
-    ((offset) ? (struct trie_file *)((char *)(t) + (offset)) : NULL)
+    ((struct trie_file *) ((offset) ? ((char *)(t) + (offset)) : NULL))
 #define NODE(t,offset) \
-    ((offset) ? (struct avlnode *)((char *)(t) + (offset)) : NULL)
+    ((struct avlnode *) ((offset) ? ((char *)(t) + (offset)) : NULL))
 #define OFFSET(t,node) \
-    ((node) ? (off_t)((const char *)node - (const char *)t) : 0)
+    ((node) ? (off_t)((const char *)node - (const char *)t) : (off_t)0)
 #define MAXDEPTH(node) ((node) ? (node)->maxdepth : 0)
 
 indexbuild *indexbuild_new(void *t, off_t startoff, int nodecount,
diff --git a/trie.c b/trie.c
index ad0cd84..4857891 100644 (file)
--- a/trie.c
+++ b/trie.c
@@ -484,6 +484,7 @@ static unsigned long long fake_atime_recurse(void *t, struct trie_common *node,
 
        return max;
     }
+    return 0;                         /* placate lint */
 }
 
 void trie_fake_dir_atimes(void *t)