Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: eliminate local variable in new_st...



details:   https://anonhg.NetBSD.org/src/rev/16ef798f58da
branches:  trunk
changeset: 985904:16ef798f58da
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Sep 13 05:21:30 2021 +0000

description:
lint: eliminate local variable in new_style_function

No functional change.

diffstat:

 usr.bin/xlint/lint1/decl.c |  18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diffs (48 lines):

diff -r 27fa4154892f -r 16ef798f58da usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Mon Sep 13 01:12:36 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Mon Sep 13 05:21:30 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.237 2021/09/12 17:30:53 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.238 2021/09/13 05:21:30 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.237 2021/09/12 17:30:53 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.238 2021/09/13 05:21:30 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1431,7 +1431,6 @@
 {
        sym_t   *arg, *sym;
        scl_t   sc;
-       int     n;
 
        /*
         * Declarations of structs/unions/enums in param lists are legal,
@@ -1445,16 +1444,13 @@
                }
        }
 
-       n = 1;
        for (arg = args; arg != NULL; arg = arg->s_next) {
-               if (arg->s_type->t_tspec == VOID) {
-                       if (n > 1 || arg->s_next != NULL) {
-                               /* void must be sole parameter */
-                               error(60);
-                               arg->s_type = gettyp(INT);
-                       }
+               if (arg->s_type->t_tspec == VOID &&
+                   !(arg == args && arg->s_next == NULL)) {
+                       /* void must be sole parameter */
+                       error(60);
+                       arg->s_type = gettyp(INT);
                }
-               n++;
        }
 
        /* return NULL if first param is VOID */



Home | Main Index | Thread Index | Old Index