Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/xlint lint: move argument list modification fu...
details: https://anonhg.NetBSD.org/src/rev/971431766c6a
branches: trunk
changeset: 373067:971431766c6a
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 15 21:27:36 2023 +0000
description:
lint: move argument list modification further away from vfork
Just to be on the safe side.
While here, don't allocate argument strings needlessly.
No functional change.
diffstat:
usr.bin/xlint/xlint/xlint.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diffs (81 lines):
diff -r 6751efea6880 -r 971431766c6a usr.bin/xlint/xlint/xlint.c
--- a/usr.bin/xlint/xlint/xlint.c Sun Jan 15 18:43:49 2023 +0000
+++ b/usr.bin/xlint/xlint/xlint.c Sun Jan 15 21:27:36 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.99 2023/01/15 15:20:18 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.100 2023/01/15 21:27:36 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: xlint.c,v 1.99 2023/01/15 15:20:18 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.100 2023/01/15 21:27:36 rillig Exp $");
#endif
#include <sys/param.h>
@@ -648,10 +648,11 @@
}
list args = { NULL, 0, 0 };
- list_add(&args, pathname);
+ list_add_ref(&args, pathname);
list_add_all(&args, &cpp.flags);
list_add_all(&args, &cpp.lcflags);
list_add(&args, name);
+ list_add_ref(&args, NULL);
/* we reuse the same tmp file for cpp output, so rewind and truncate */
if (lseek(cpp.outfd, 0, SEEK_SET) != 0) {
@@ -664,7 +665,6 @@
}
run_child(pathname, &args, cpp.outfile, cpp.outfd);
- free(pathname);
list_clear(&args);
/* run lint1 */
@@ -680,13 +680,13 @@
pathname = concat2(libexec_dir, "/lint1");
}
- list_add(&args, pathname);
+ list_add_ref(&args, pathname);
list_add_all(&args, &lint1.flags);
list_add(&args, cpp.outfile);
list_add(&args, ofn);
+ list_add_ref(&args, NULL);
run_child(pathname, &args, ofn, -1);
- free(pathname);
list_clear(&args);
list_add(&lint2.infiles, ofn);
@@ -760,9 +760,7 @@
(void)dup2(fdout, STDOUT_FILENO);
(void)close(fdout);
}
- list_add_ref(args, NULL);
(void)execvp(path, args->items);
- args->len--;
warn("cannot exec %s", path);
_exit(1);
/* NOTREACHED */
@@ -851,13 +849,13 @@
}
list args = { NULL, 0, 0 };
- list_add(&args, path);
+ list_add_ref(&args, path);
list_add_all(&args, &lint2.flags);
list_add_all(&args, &lint2.inlibs);
list_add_all(&args, &lint2.infiles);
+ list_add_ref(&args, NULL);
run_child(path, &args, lint2.outlib, -1);
- free(path);
list_clear(&args);
}
Home |
Main Index |
Thread Index |
Old Index