NetBSD-Bugs archive

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

PR/60860 CVS commit: src/usr.bin/nbperf



The following reply was made to PR bin/60860; it has been noted by GNATS.

From: "Robert Elz" <kre%netbsd.org@localhost>
To: gnats-bugs%gnats.NetBSD.org@localhost
Cc: 
Subject: PR/60860 CVS commit: src/usr.bin/nbperf
Date: Fri, 9 Oct 2026 11:54:25 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Fri Oct  9 11:54:25 UTC 2026
 
 Modified Files:
 	src/usr.bin/nbperf: nbperf.c
 
 Log Message:
 PR bin/60860 : Open output files later
 
 Defer opening the output files until after the input file has
 been read.
 
 Also, check that the -o (output) file and the (optional) -m map
 file don't name the same file (simple textual check, very easy
 to defeat if desired).
 
 And finally, abort early if the input file is empty, to avoid
 generating a hash function which ends with (something like):
 
         return (g[h[0]] + g[h[1]]) % 0;
 
 which, if it compiles at all, which I doubt (I didn't bother
 testing it) certainly won't do anything useful (maybe dump core).
 
 Note: I doubt the utility of this change, the three files, in
 any practical usage, will all be wanted once the has function
 has run, the output file should usually be xxx.c (as it is C
 code being produced) - the input file is just a list of keys,
 very unlikely to have an xxx.c type file name (even if it is
 not just stdin), and the optional map file (which requires
 knowledge of the keys as ordered for the input to be meaningful)
 is certainly not C code.
 
 That said, it cannot possibly harm anything to defer opening
 the output files until later than was done before (it even
 simplifies the code a little, as now giving more than one of
 one of the -o or -m options does not require closing the previous
 file and opening a new one - just replace the file name that will
 be used to open the file later, well after option processing has
 finished).
 
 No algorithmic changes at all were made as a part of this change,
 the results (for valid inputs) will be exactly the same as they
 would have been before these changes.
 
 No pullups, this will be in HEAD, first in a release in 12.0
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.9 -r1.10 src/usr.bin/nbperf/nbperf.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 



Home | Main Index | Thread Index | Old Index