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: extract filename ID counter into s...



details:   https://anonhg.NetBSD.org/src/rev/67cd85abb677
branches:  trunk
changeset: 982136:67cd85abb677
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 02 09:45:55 2021 +0000

description:
lint: extract filename ID counter into separate function

No functional change.

diffstat:

 usr.bin/xlint/lint1/mem1.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (51 lines):

diff -r 1f78515e46b4 -r 67cd85abb677 usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c        Fri Apr 02 09:39:25 2021 +0000
+++ b/usr.bin/xlint/lint1/mem1.c        Fri Apr 02 09:45:55 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mem1.c,v 1.38 2021/04/02 09:39:25 rillig Exp $ */
+/*     $NetBSD: mem1.c,v 1.39 2021/04/02 09:45:55 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.38 2021/04/02 09:39:25 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.39 2021/04/02 09:45:55 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -115,6 +115,14 @@
        return buf;
 }
 
+static int
+next_filename_id(void)
+{
+       static int next_id = 0;
+
+       return next_id++;
+}
+
 /*
  * Return a copy of the filename s with unlimited lifetime.
  * If the filename is new, write it to the output file.
@@ -125,8 +133,6 @@
        const struct filename *existing_fn;
        struct filename *fn;
 
-       static  int     nxt_id = 0;
-
        if (s == NULL)
                return NULL;
 
@@ -139,7 +145,7 @@
        (void)memcpy(fn->fn_name, s, slen);
        fn->fn_name[slen] = '\0';
        fn->fn_len = slen;
-       fn->fn_id = nxt_id++;
+       fn->fn_id = next_filename_id();
        fn->fn_next = filenames;
        filenames = fn;
 



Home | Main Index | Thread Index | Old Index