From: martijn Date: Sun, 12 Nov 2023 20:10:13 +0000 (+0000) Subject: Now that smi_oid_cmp() is only used by the oidtree RB-tree, and nothing X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5135a244324e615816627a32fec2411db9b9da60;p=openbsd Now that smi_oid_cmp() is only used by the oidtree RB-tree, and nothing fancy is using it, we can simply rely on ober_oid_cmp(). OK tb@ --- diff --git a/usr.sbin/snmpd/smi.c b/usr.sbin/snmpd/smi.c index 423bf5c2590..f895f41e6ee 100644 --- a/usr.sbin/snmpd/smi.c +++ b/usr.sbin/snmpd/smi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smi.c,v 1.35 2023/11/12 20:07:48 martijn Exp $ */ +/* $OpenBSD: smi.c,v 1.36 2023/11/12 20:10:13 martijn Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter @@ -48,8 +48,6 @@ #include "mib.h" #include "application.h" -#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) - RB_HEAD(oidtree, oid); RB_PROTOTYPE(oidtree, oid, o_element, smi_oid_cmp); struct oidtree smi_oidtree; @@ -694,23 +692,7 @@ smi_application(struct ber_element *elm) int smi_oid_cmp(struct oid *a, struct oid *b) { - size_t i; - - for (i = 0; i < MINIMUM(a->o_oidlen, b->o_oidlen); i++) - if (a->o_oid[i] != b->o_oid[i]) - return (a->o_oid[i] - b->o_oid[i]); - - /* - * Return success if the matched object is a table - * or a MIB registered by a subagent - * (it will match any sub-elements) - */ - if (b->o_flags & OID_TABLE && - (a->o_flags & OID_KEY) == 0 && - (a->o_oidlen > b->o_oidlen)) - return (0); - - return (a->o_oidlen - b->o_oidlen); + return ober_oid_cmp(&a->o_id, &b->o_id); } RB_GENERATE(oidtree, oid, o_element, smi_oid_cmp);