Module Name: src Committed By: rillig Date: Fri Apr 2 09:45:55 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: mem1.c Log Message: lint: extract filename ID counter into separate function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/lint1/mem1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/mem1.c diff -u src/usr.bin/xlint/lint1/mem1.c:1.38 src/usr.bin/xlint/lint1/mem1.c:1.39 --- src/usr.bin/xlint/lint1/mem1.c:1.38 Fri Apr 2 09:39:25 2021 +++ src/usr.bin/xlint/lint1/mem1.c Fri Apr 2 09:45:55 2021 @@ -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 @@ transform_filename(const char *name, siz 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 @@ record_filename(const char *s, size_t sl const struct filename *existing_fn; struct filename *fn; - static int nxt_id = 0; - if (s == NULL) return NULL; @@ -139,7 +145,7 @@ record_filename(const char *s, size_t sl (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;