return is not a function and if (x) -> if (x != NULL)
authorbenno <benno@openbsd.org>
Fri, 3 Aug 2018 17:57:21 +0000 (17:57 +0000)
committerbenno <benno@openbsd.org>
Fri, 3 Aug 2018 17:57:21 +0000 (17:57 +0000)
From Ross L Richardson, thanks
ok millert@

usr.sbin/acme-client/parse.y

index 172b5fb..a6ecdda 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: parse.y,v 1.28 2018/08/03 17:51:40 benno Exp $ */
+/*     $OpenBSD: parse.y,v 1.29 2018/08/03 17:57:21 benno Exp $ */
 
 /*
  * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -402,7 +402,7 @@ yyerror(const char *fmt, ...)
 int
 kw_cmp(const void *k, const void *e)
 {
-       return (strcmp(k, ((const struct keywords *)e)->k_name));
+       return strcmp(k, ((const struct keywords *)e)->k_name);
 }
 
 int
@@ -431,10 +431,10 @@ lookup(char *s)
        p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]),
            sizeof(keywords[0]), kw_cmp);
 
-       if (p)
-               return (p->k_val);
+       if (p != NULL)
+               return p->k_val;
        else
-               return (STRING);
+               return STRING;
 }
 
 #define        START_EXPAND    1
@@ -460,7 +460,7 @@ igetc(void)
                else
                        break;
        }
-       return (c);
+       return c;
 }
 
 int
@@ -474,9 +474,9 @@ lgetc(int quotec)
                            "quoted string");
                        if (file == topfile || popfile() == EOF)
                                return (EOF);
-                       return (quotec);
+                       return quotec;
                }
-               return (c);
+               return c;
        }
 
        while ((c = igetc()) == '\\') {
@@ -497,7 +497,7 @@ lgetc(int quotec)
                 */
                if (file->eof_reached == 0) {
                        file->eof_reached = 1;
-                       return ('\n');
+                       return '\n';
                }
                while (c == EOF) {
                        if (file == topfile || popfile() == EOF)
@@ -505,7 +505,7 @@ lgetc(int quotec)
                        c = igetc();
                }
        }
-       return (c);
+       return c;
 }
 
 void
@@ -539,7 +539,7 @@ findeol(void)
                if (c == EOF)
                        break;
        }
-       return (ERROR);
+       return ERROR;
 }
 
 int
@@ -562,11 +562,11 @@ top:
        if (c == '$' && !expanding) {
                while (1) {
                        if ((c = lgetc(0)) == EOF)
-                               return (0);
+                               return 0;
 
                        if (p + 1 >= buf + sizeof(buf) - 1) {
                                yyerror("string too long");
-                               return (findeol());
+                               return findeol();
                        }
                        if (isalnum(c) || c == '_') {
                                *p++ = c;
@@ -579,7 +579,7 @@ top:
                val = symget(buf);
                if (val == NULL) {
                        yyerror("macro '%s' not defined", buf);
-                       return (findeol());
+                       return findeol();
                }
                p = val + strlen(val) - 1;
                lungetc(DONE_EXPAND);
@@ -597,13 +597,13 @@ top:
                quotec = c;
                while (1) {
                        if ((c = lgetc(quotec)) == EOF)
-                               return (0);
+                               return 0;
                        if (c == '\n') {
                                file->lineno++;
                                continue;
                        } else if (c == '\\') {
                                if ((next = lgetc(quotec)) == EOF)
-                                       return (0);
+                                       return 0;
                                if (next == quotec || c == ' ' || c == '\t')
                                        c = next;
                                else if (next == '\n') {
@@ -616,18 +616,18 @@ top:
                                break;
                        } else if (c == '\0') {
                                yyerror("syntax error");
-                               return (findeol());
+                               return findeol();
                        }
                        if (p + 1 >= buf + sizeof(buf) - 1) {
                                yyerror("string too long");
-                               return (findeol());
+                               return findeol();
                        }
                        *p++ = c;
                }
                yylval.v.string = strdup(buf);
                if (yylval.v.string == NULL)
                        err(EXIT_FAILURE, "%s", __func__);
-               return (STRING);
+               return STRING;
        }
 
 #define allowed_to_end_number(x) \
@@ -638,7 +638,7 @@ top:
                        *p++ = c;
                        if ((unsigned)(p-buf) >= sizeof(buf)) {
                                yyerror("string too long");
-                               return (findeol());
+                               return findeol();
                        }
                } while ((c = lgetc(0)) != EOF && isdigit(c));
                lungetc(c);
@@ -650,19 +650,19 @@ top:
                        *p = '\0';
                        yylval.v.number = strtonum(buf, LLONG_MIN,
                            LLONG_MAX, &errstr);
-                       if (errstr) {
+                       if (errstr != NULL) {
                                yyerror("\"%s\" invalid number: %s",
                                    buf, errstr);
                                return (findeol());
                        }
-                       return (NUMBER);
+                       return NUMBER;
                } else {
 nodigits:
                        while (p > buf + 1)
                                lungetc(*--p);
                        c = *--p;
                        if (c == '-')
-                               return (c);
+                               return c;
                }
        }
 
@@ -686,15 +686,15 @@ nodigits:
                        if ((yylval.v.string = strdup(buf)) == NULL)
                                err(EXIT_FAILURE, "%s", __func__);
                }
-               return (token);
+               return token;
        }
        if (c == '\n') {
                yylval.lineno = file->lineno;
                file->lineno++;
        }
        if (c == EOF)
-               return (0);
-       return (c);
+               return 0;
+       return c;
 }
 
 struct file *
@@ -704,18 +704,18 @@ pushfile(const char *name)
 
        if ((nfile = calloc(1, sizeof(struct file))) == NULL) {
                warn("%s", __func__);
-               return (NULL);
+               return NULL;
        }
        if ((nfile->name = strdup(name)) == NULL) {
                warn("%s", __func__);
                free(nfile);
-               return (NULL);
+               return NULL;
        }
        if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
                warn("%s: %s", __func__, nfile->name);
                free(nfile->name);
                free(nfile);
-               return (NULL);
+               return NULL;
        }
        nfile->lineno = TAILQ_EMPTY(&files) ? 1 : 0;
        nfile->ungetsize = 16;
@@ -725,10 +725,10 @@ pushfile(const char *name)
                fclose(nfile->stream);
                free(nfile->name);
                free(nfile);
-               return (NULL);
+               return NULL;
        }
        TAILQ_INSERT_TAIL(&files, nfile, entry);
-       return (nfile);
+       return nfile;
 }
 
 int
@@ -759,7 +759,7 @@ parse_config(const char *filename, int opts)
 
        if ((file = pushfile(filename)) == NULL) {
                free(conf);
-               return (NULL);
+               return NULL;
        }
        topfile = file;
 
@@ -783,15 +783,15 @@ parse_config(const char *filename, int opts)
                }
        }
 
-       if (errors) {
+       if (errors != 0) {
                clear_config(conf);
-               return (NULL);
+               return NULL;
        }
 
        if (opts & ACME_OPT_CHECK)
                print_config(conf);
 
-       return (conf);
+       return conf;
 }
 
 int
@@ -815,23 +815,23 @@ symset(const char *nam, const char *val, int persist)
                }
        }
        if ((sym = calloc(1, sizeof(*sym))) == NULL)
-               return (-1);
+               return -1;
 
        sym->nam = strdup(nam);
        if (sym->nam == NULL) {
                free(sym);
-               return (-1);
+               return -1;
        }
        sym->val = strdup(val);
        if (sym->val == NULL) {
                free(sym->nam);
                free(sym);
-               return (-1);
+               return -1;
        }
        sym->used = 0;
        sym->persist = persist;
        TAILQ_INSERT_TAIL(&symhead, sym, entry);
-       return (0);
+       return 0;
 }
 
 int
@@ -842,7 +842,7 @@ cmdline_symset(char *s)
        size_t  len;
 
        if ((val = strrchr(s, '=')) == NULL)
-               return (-1);
+               return -1;
 
        len = strlen(s) - strlen(val) + 1;
        if ((sym = malloc(len)) == NULL)
@@ -853,7 +853,7 @@ cmdline_symset(char *s)
        ret = symset(sym, val + 1, 1);
        free(sym);
 
-       return (ret);
+       return ret;
 }
 
 char *
@@ -864,10 +864,10 @@ symget(const char *nam)
        TAILQ_FOREACH(sym, &symhead, entry) {
                if (strcmp(nam, sym->nam) == 0) {
                        sym->used = 1;
-                       return (sym->val);
+                       return sym->val;
                }
        }
-       return (NULL);
+       return NULL;
 }
 
 struct authority_c *
@@ -876,14 +876,14 @@ conf_new_authority(struct acme_conf *c, char *s)
        struct authority_c *a;
 
        a = authority_find(c, s);
-       if (a)
-               return (NULL);
+       if (a != NULL)
+               return NULL;
        if ((a = calloc(1, sizeof(struct authority_c))) == NULL)
                err(EXIT_FAILURE, "%s", __func__);
        TAILQ_INSERT_TAIL(&c->authority_list, a, entry);
 
        a->name = s;
-       return (a);
+       return a;
 }
 
 struct authority_c *
@@ -893,10 +893,10 @@ authority_find(struct acme_conf *c, char *s)
 
        TAILQ_FOREACH(a, &c->authority_list, entry) {
                if (strncmp(a->name, s, AUTH_MAXLEN) == 0) {
-                       return (a);
+                       return a;
                }
        }
-       return (NULL);
+       return NULL;
 }
 
 struct authority_c *
@@ -911,7 +911,7 @@ conf_new_domain(struct acme_conf *c, char *s)
        struct domain_c *d;
 
        d = domain_find(c, s);
-       if (d)
+       if (d != NULL)
                return (NULL);
        if ((d = calloc(1, sizeof(struct domain_c))) == NULL)
                err(EXIT_FAILURE, "%s", __func__);
@@ -920,7 +920,7 @@ conf_new_domain(struct acme_conf *c, char *s)
        d->domain = s;
        TAILQ_INIT(&d->altname_list);
 
-       return (d);
+       return d;
 }
 
 struct domain_c *
@@ -930,10 +930,10 @@ domain_find(struct acme_conf *c, char *s)
 
        TAILQ_FOREACH(d, &c->domain_list, entry) {
                if (strncmp(d->domain, s, DOMAIN_MAXLEN) == 0) {
-                       return (d);
+                       return d;
                }
        }
-       return (NULL);
+       return NULL;
 }
 
 struct keyfile *
@@ -943,7 +943,7 @@ conf_new_keyfile(struct acme_conf *c, char *s)
 
        LIST_FOREACH(k, &c->used_key_list, entry) {
                if (strncmp(k->name, s, PATH_MAX) == 0) {
-                       return (NULL);
+                       return NULL;
                }
        }
 
@@ -952,7 +952,7 @@ conf_new_keyfile(struct acme_conf *c, char *s)
        LIST_INSERT_HEAD(&c->used_key_list, k, entry);
 
        k->name = s;
-       return (k);
+       return k;
 }
 
 void
@@ -1036,8 +1036,8 @@ domain_valid(const char *cp)
        for ( ; *cp != '\0'; cp++)
                if (!(*cp == '.' || *cp == '-' ||
                    *cp == '_' || isalnum((int)*cp)))
-                       return (0);
-       return (1);
+                       return 0;
+       return 1;
 }
 
 int
@@ -1047,17 +1047,17 @@ conf_check_file(char *s, int dontstat)
 
        if (s[0] != '/') {
                warnx("%s: not an absolute path", s);
-               return (0);
+               return 0;
        }
        if (dontstat)
-               return (1);
+               return 1;
        if (stat(s, &st)) {
                warn("cannot stat %s", s);
-               return (0);
+               return 0;
        }
        if (st.st_mode & (S_IRWXG | S_IRWXO)) {
                warnx("%s: group read/writable or world read/writable", s);
-               return (0);
+               return 0;
        }
-       return (1);
+       return 1;
 }