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: reduce indentation in fnnalloc



details:   https://anonhg.NetBSD.org/src/rev/9b1c099e33a6
branches:  trunk
changeset: 953988:9b1c099e33a6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 27 11:54:35 2021 +0000

description:
lint: reduce indentation in fnnalloc

No functional change.

diffstat:

 usr.bin/xlint/lint1/mem1.c |  39 +++++++++++++++++++++------------------
 1 files changed, 21 insertions(+), 18 deletions(-)

diffs (60 lines):

diff -r b1ed5fac3dd5 -r 9b1c099e33a6 usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c        Sat Mar 27 11:50:34 2021 +0000
+++ b/usr.bin/xlint/lint1/mem1.c        Sat Mar 27 11:54:35 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mem1.c,v 1.30 2021/03/27 11:50:34 rillig Exp $ */
+/*     $NetBSD: mem1.c,v 1.31 2021/03/27 11:54:35 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.30 2021/03/27 11:50:34 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.31 2021/03/27 11:54:35 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -130,22 +130,25 @@
        if (s == NULL)
                return NULL;
 
-       if ((fn = srchfn(s, len)) == NULL) {
-               fn = xmalloc(sizeof *fn);
-               /* Do not use strdup() because s is not NUL-terminated.*/
-               fn->fn_name = xmalloc(len + 1);
-               (void)memcpy(fn->fn_name, s, len);
-               fn->fn_name[len] = '\0';
-               fn->fn_len = len;
-               fn->fn_id = nxt_id++;
-               fn->fn_next = fnames;
-               fnames = fn;
-               /* Write id of this filename to the output file. */
-               outclr();
-               outint(fn->fn_id);
-               outchar('s');
-               outstrg(fnxform(fn->fn_name, fn->fn_len));
-       }
+       if ((fn = srchfn(s, len)) != NULL)
+               return fn->fn_name;
+
+       fn = xmalloc(sizeof *fn);
+       /* Do not use strdup() because s is not NUL-terminated.*/
+       fn->fn_name = xmalloc(len + 1);
+       (void)memcpy(fn->fn_name, s, len);
+       fn->fn_name[len] = '\0';
+       fn->fn_len = len;
+       fn->fn_id = nxt_id++;
+       fn->fn_next = fnames;
+       fnames = fn;
+
+       /* Write id of this filename to the output file. */
+       outclr();
+       outint(fn->fn_id);
+       outchar('s');
+       outstrg(fnxform(fn->fn_name, fn->fn_len));
+
        return fn->fn_name;
 }
 



Home | Main Index | Thread Index | Old Index