From nobody Wed Apr 26 08:30:18 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q5sWG6m55z47gm7; Wed, 26 Apr 2023 08:30:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q5sWG65Znz3Cmq; Wed, 26 Apr 2023 08:30:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682497818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yzDpwiFqmekCJlk9mxUO5Hq6O34km5Jf9bY6tKMJLlQ=; b=vGKxNXJbpqZpY+XICmypWf4HdYPCp9GIEFs/xn6hAtQlcixcNeiPvOgSd0MwLPxCsFYXTK VSxWDnhcBIWES6ssIOuKtG6XEGtjfdHdIcah4MzgvzL9k3COMYY7uKJi+Wpuoji9dDCnmN Za8scy7lgyD87E7uvL3DTlYT9MTpxaPsCcrZAimpioBCumaVrD0iygvSgGywLytf8zRJ0A +GajyQoYxfadcemSq2vB6YGRrUZBkmgCjoUMDpu+k90qNJjsQO0JP/CmSaopyxvPiQRPTN kCLwOH6LiN9IUdYU1VbOe9UAsf+WHf7a83XKFo5FW2igrW/1cVOPpo0lFOGmTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682497818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yzDpwiFqmekCJlk9mxUO5Hq6O34km5Jf9bY6tKMJLlQ=; b=dronZ+lZQfSpI78roMHMoeK4VfujgA8eUvL1cDAd/kGNsHxAppjXF22D/4VKKcePJK2e1G onUghpkxxJExpQ4FGKp6kspJ5HxG6CkK9OROCp5pi9V6T0Bva7TwQoHHiqRA7Eu9/12azZ hYytfySzeBHSK50BxS1VM+nyo1K309L3VgUBaYxDjMXpn7hu0EG2wlcnXAzl2e47IHhKFy KEb71B/C7FAFTI2/jNb5aK7s+J8tnfVJhw5UCHVAmMWDKvtgrxZ2/8mUijwe5/n1gHFsp0 q41JXPCJkt424QD7kL8KVSpZepHBSqaIh7K6AkVowg/HKMrG/2yqeK2CZj2TLQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682497818; a=rsa-sha256; cv=none; b=aQwigq9aT1WB1rpmeQxH2PVJuToJKnDv1UF/0MisfWhqxLlMvZuJSBLxeVVnGl+syPx5bs uNmKrJ0xRaIYkctxfx7dFSBGrDe8o0tDqhn8wK8BUxrRPCdpbHVmOXJDtet20VdcfzxK7q p+v3iLkAYfsTI7yT/zk1mES7tlQ4ORZPnsOV/8f/9NVGRYZPc9bbM+SvF36L7EvpAMrgg2 39rO9MXbFQ452pVBg588Ob1JoWGACntJdeS9ycwij5Fy80FaS/2Q4vT4kQDmaXRaq6rK0p t/b1Q8oqo/bcbTLcdklDXSz8MpeGELQ+3XdwpAKnrYlnNk2exjIWeQV5zIzT1Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q5sWG58VQzS4V; Wed, 26 Apr 2023 08:30:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33Q8UIxB018410; Wed, 26 Apr 2023 08:30:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33Q8UI0P018409; Wed, 26 Apr 2023 08:30:18 GMT (envelope-from git) Date: Wed, 26 Apr 2023 08:30:18 GMT Message-Id: <202304260830.33Q8UI0P018409@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Jeremy Subject: git: b9600db494a0 - main - prometheus_sysctl_exporter: Replace magic numbers with identifiers. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: peterj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b9600db494a04db6fbf1a16dbcf92f7c64d5e863 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by peterj: URL: https://cgit.FreeBSD.org/src/commit/?id=b9600db494a04db6fbf1a16dbcf92f7c64d5e863 commit b9600db494a04db6fbf1a16dbcf92f7c64d5e863 Author: Peter Jeremy AuthorDate: 2023-04-26 08:29:33 +0000 Commit: Peter Jeremy CommitDate: 2023-04-26 08:29:33 +0000 prometheus_sysctl_exporter: Replace magic numbers with identifiers. Identifiers make it clearer what is going on and makes it easier to find consumers of sysctl functionality. No functional change. MFC after: 3 days Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D39797 --- .../prometheus_sysctl_exporter.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c index 931d8e965d00..6c20d639a6d3 100644 --- a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c +++ b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c @@ -62,7 +62,7 @@ static void oid_get_root(struct oid *o) { - o->id[0] = 1; + o->id[0] = CTL_KERN; o->len = 1; } @@ -91,8 +91,8 @@ oid_get_next(const struct oid *cur, struct oid *next) int lookup[CTL_MAXNAME + 2]; size_t nextsize; - lookup[0] = 0; - lookup[1] = 2; + lookup[0] = CTL_SYSCTL; + lookup[1] = CTL_SYSCTL_NEXT; memcpy(lookup + 2, cur->id, cur->len * sizeof(lookup[0])); nextsize = sizeof(next->id); if (sysctl(lookup, 2 + cur->len, &next->id, &nextsize, 0, 0) != 0) { @@ -135,8 +135,8 @@ oid_get_format(const struct oid *o, struct oidformat *of) int lookup[CTL_MAXNAME + 2]; size_t oflen; - lookup[0] = 0; - lookup[1] = 4; + lookup[0] = CTL_SYSCTL; + lookup[1] = CTL_SYSCTL_OIDFMT; memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); oflen = sizeof(*of); if (sysctl(lookup, 2 + o->len, of, &oflen, 0, 0) != 0) { @@ -344,8 +344,8 @@ oid_get_name(const struct oid *o, struct oidname *on) size_t i, len; /* Fetch the name and split it up in separate components. */ - lookup[0] = 0; - lookup[1] = 1; + lookup[0] = CTL_SYSCTL; + lookup[1] = CTL_SYSCTL_NAME; memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); len = sizeof(on->names); if (sysctl(lookup, 2 + o->len, on->names, &len, 0, 0) != 0) @@ -464,8 +464,8 @@ oid_get_description(const struct oid *o, struct oiddescription *od) char *newline; size_t odlen; - lookup[0] = 0; - lookup[1] = 5; + lookup[0] = CTL_SYSCTL; + lookup[1] = CTL_SYSCTL_OIDDESCR; memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); odlen = sizeof(od->description); if (sysctl(lookup, 2 + o->len, &od->description, &odlen, 0, 0) != 0) {