1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 21:21:31 +00:00

Remove unused param and return value from AVal_match

This commit is contained in:
dmiller
2023-01-27 22:47:09 +00:00
parent 1d770ee059
commit 70f3350cf8

View File

@@ -339,26 +339,16 @@ static bool expr_match(const char *val, const char *expr) {
return false; return false;
} }
/* Returns true if perfect match -- if num_subtests & /* Updates num_subtests and num_subtests_succeeded for a given FingerTest.
num_subtests_succeeded are non_null it ADDS THE NEW VALUES to what If you want details of the match process printed, pass nonzero for 'verbose'.
is already there. So initialize them to zero first if you only */
want to see the results from this match. if shortcircuit is zero, static void AVal_match(const FingerTest &reference, const FingerTest &fprint, const FingerTestDef &points,
it does all the tests, otherwise it returns when the first one unsigned long &num_subtests,
fails. If you want details of the match process printed, pass n unsigned long &num_subtests_succeeded,
onzero for 'verbose'. If points is non-null, it is examined to
find the number of points for each test in the fprint AVal and use
that the increment num_subtests and num_subtests_succeeded
appropriately. If it is NULL, each test is worth 1 point. In that
case, you may also pass in the group name (SEQ, T1, etc) to have
that extra info printed. If you pass 0 for verbose, you might as
well pass NULL for testGroupName as it won't be used. */
static int AVal_match(const FingerTest &reference, const FingerTest &fprint, const FingerTestDef &points,
unsigned long *num_subtests,
unsigned long *num_subtests_succeeded, int shortcut,
int verbose) { int verbose) {
int subtests = 0, subtests_succeeded=0; int subtests = 0, subtests_succeeded=0;
if (!reference.results || !fprint.results) if (!reference.results || !fprint.results)
return 0; return;
const std::vector<Attr> &pointsV = points.Attrs; const std::vector<Attr> &pointsV = points.Attrs;
@@ -382,23 +372,14 @@ static int AVal_match(const FingerTest &reference, const FingerTest &fprint, con
if (expr_match(current_fp, current_ref)) { if (expr_match(current_fp, current_ref)) {
subtests_succeeded += pointsThisTest; subtests_succeeded += pointsThisTest;
} else { } else {
if (shortcut) {
if (num_subtests)
*num_subtests += subtests;
return 0;
}
if (verbose) if (verbose)
log_write(LOG_PLAIN, "%s.%s: \"%s\" NOMATCH \"%s\" (%d %s)\n", points.name.str, log_write(LOG_PLAIN, "%s.%s: \"%s\" NOMATCH \"%s\" (%d %s)\n", points.name.str,
aDef.name.str, current_fp, aDef.name.str, current_fp,
current_ref, pointsThisTest, (pointsThisTest == 1) ? "point" : "points"); current_ref, pointsThisTest, (pointsThisTest == 1) ? "point" : "points");
} }
} }
if (num_subtests) num_subtests += subtests;
*num_subtests += subtests; num_subtests_succeeded += subtests_succeeded;
if (num_subtests_succeeded)
*num_subtests_succeeded += subtests_succeeded;
return (subtests == subtests_succeeded) ? 1 : 0;
} }
/* Compares 2 fingerprints -- a referenceFP (can have expression /* Compares 2 fingerprints -- a referenceFP (can have expression
@@ -420,12 +401,8 @@ double compare_fingerprints(const FingerPrint *referenceFP, const FingerPrint *o
const FingerTest &current_fp = observedFP->tests[i]; const FingerTest &current_fp = observedFP->tests[i];
const FingerTestDef &points = MatchPoints->getTestDef(INT2ID(i)); const FingerTestDef &points = MatchPoints->getTestDef(INT2ID(i));
unsigned long new_subtests = 0, new_subtests_succeeded = 0;
AVal_match(current_ref, current_fp, points, AVal_match(current_ref, current_fp, points,
&new_subtests, &new_subtests_succeeded, 0, verbose); num_subtests, num_subtests_succeeded, verbose);
num_subtests += new_subtests;
num_subtests_succeeded += new_subtests_succeeded;
if (!verbose && num_subtests - num_subtests_succeeded > max_mismatch) { if (!verbose && num_subtests - num_subtests_succeeded > max_mismatch) {
break; break;
} }