From nobody Wed Apr 26 14:35:28 2023 X-Original-To: dev-commits-src-all@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 4Q61cx344qz46bXk; Wed, 26 Apr 2023 14:35:45 +0000 (UTC) (envelope-from gkontos.mail@gmail.com) Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q61cv6cL1z3CR5; Wed, 26 Apr 2023 14:35:43 +0000 (UTC) (envelope-from gkontos.mail@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20221208 header.b=KI50GNVB; spf=pass (mx1.freebsd.org: domain of gkontos.mail@gmail.com designates 2a00:1450:4864:20::12e as permitted sender) smtp.mailfrom=gkontos.mail@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4ec9c7c6986so7577319e87.0; Wed, 26 Apr 2023 07:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682519740; x=1685111740; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=w31fZqga7YY77Ud3wP1Ztp1+dVvHjIKD353g+ftWeLE=; b=KI50GNVBc/7BuP/PLvWBs6/mG11NQxUGAH7sI+RM+wJi+W/UE2QBeRmYEhphCyZuIt ZPydbbg/FzR84XngDSoxBiP9nYxYEAi219kKTD+JTOORI1wQS0KyvCUT4XJj2RKTeHCV Nk4g6/LY0/9tFng8FJjEPbAAgEiWBiw9cN2PLl17pI04nqC2ap6sXxDKwz2Sy4ctPJW3 dLHEJB6B2Af/zFPgOultvKLoUJioC9eTqPdav+QwDVl1BIIQTTacXfwId3YeKT+b8TEQ IVcX3L9rWyRllnDTXAuUz78WzwwoHMVdncb0sNV5zhOb6ze67/wb2YwaPxJ4Y/yIkqch za0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682519740; x=1685111740; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w31fZqga7YY77Ud3wP1Ztp1+dVvHjIKD353g+ftWeLE=; b=Ld1jK2Zl8IkiyRHxmTaA+RnNT32HW7keomZcGND53Suyjt58q7PGO/qudl2+C62PU/ vN36IvCZ24cghaHxAgDtcJlmpIri/l5j47TM5fLo5b7eN1Cv5vazn7ni7cK5zhmgLOtP MFVYoKSxR5oa3LnXWf7z5XrFckYLnnWqar/Twems9VQR9UCTE3AzgFgyKgAyiPYsDw4g V6Gv9Qw64aTB99NhC3+n7VbvQ51Mb9iIwo4YaxJtslsJhBLp2oInnlEiDjEIb47MFNZd 0GKdVLzhbXlSplL+UoBoY4R9mNZJMAHPBh5YB8zcUS4d//0W/I5CQySKmiFFrFme/ogq BiZw== X-Gm-Message-State: AAQBX9cldN8TgyRRiH1qOj1xuZ/tneaSlN2/D/zHheJbBqm+oFOcKK16 zdLKYAjahkLF6Cfh5I2dvA/OyCD5D13C4zSMDSkb9FMfXsPRnw== X-Google-Smtp-Source: AKy350aUWEI59lPL8JonPLIefWAnE6Q1fFVWlA42LRVsBpdL66gjq4HECaa8CzohpPvEe5ogaS+hYt9VzIrfWx76ZaQ= X-Received: by 2002:ac2:4151:0:b0:4d8:6540:a731 with SMTP id c17-20020ac24151000000b004d86540a731mr5410311lfi.47.1682519740015; Wed, 26 Apr 2023 07:35:40 -0700 (PDT) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 References: <202304260830.33Q8UI0P018409@gitrepo.freebsd.org> In-Reply-To: <202304260830.33Q8UI0P018409@gitrepo.freebsd.org> From: George Kontostanos Date: Wed, 26 Apr 2023 17:35:28 +0300 Message-ID: Subject: Re: git: b9600db494a0 - main - prometheus_sysctl_exporter: Replace magic numbers with identifiers. To: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.13 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20221208]; NEURAL_HAM_SHORT(-0.13)[-0.131]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::12e:from]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DKIM_TRACE(0.00)[gmail.com:+]; RCVD_TLS_LAST(0.00)[]; TAGGED_FROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; RCVD_COUNT_TWO(0.00)[2] X-Rspamd-Queue-Id: 4Q61cv6cL1z3CR5 X-Spamd-Bar: --- X-ThisMailContainsUnwantedMimeParts: N unsubscribe On Wed, Apr 26, 2023 at 11:30=E2=80=AFAM Peter Jeremy = wrote: > > The branch main has been updated by peterj: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3Db9600db494a04db6fbf1a16dbc= f92f7c64d5e863 > > 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_export= er.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] =3D 1; > + o->id[0] =3D CTL_KERN; > o->len =3D 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] =3D 0; > - lookup[1] =3D 2; > + lookup[0] =3D CTL_SYSCTL; > + lookup[1] =3D CTL_SYSCTL_NEXT; > memcpy(lookup + 2, cur->id, cur->len * sizeof(lookup[0])); > nextsize =3D sizeof(next->id); > if (sysctl(lookup, 2 + cur->len, &next->id, &nextsize, 0, 0) !=3D= 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] =3D 0; > - lookup[1] =3D 4; > + lookup[0] =3D CTL_SYSCTL; > + lookup[1] =3D CTL_SYSCTL_OIDFMT; > memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); > oflen =3D sizeof(*of); > if (sysctl(lookup, 2 + o->len, of, &oflen, 0, 0) !=3D 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] =3D 0; > - lookup[1] =3D 1; > + lookup[0] =3D CTL_SYSCTL; > + lookup[1] =3D CTL_SYSCTL_NAME; > memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); > len =3D sizeof(on->names); > if (sysctl(lookup, 2 + o->len, on->names, &len, 0, 0) !=3D 0) > @@ -464,8 +464,8 @@ oid_get_description(const struct oid *o, struct oidde= scription *od) > char *newline; > size_t odlen; > > - lookup[0] =3D 0; > - lookup[1] =3D 5; > + lookup[0] =3D CTL_SYSCTL; > + lookup[1] =3D CTL_SYSCTL_OIDDESCR; > memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0])); > odlen =3D sizeof(od->description); > if (sysctl(lookup, 2 + o->len, &od->description, &odlen, 0, 0) != =3D 0) { > --=20 George Kontostanos ---