Date: Wed, 26 Apr 2023 17:35:28 +0300 From: George Kontostanos <gkontos.mail@gmail.com> To: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: b9600db494a0 - main - prometheus_sysctl_exporter: Replace magic numbers with identifiers. Message-ID: <CA%2BdUSyotDYAeAc9SjvEE%2B=4TOKERr5UXJk5K-GKKUeXGuaapiQ@mail.gmail.com> In-Reply-To: <202304260830.33Q8UI0P018409@gitrepo.freebsd.org> References: <202304260830.33Q8UI0P018409@gitrepo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
unsubscribe On Wed, Apr 26, 2023 at 11:30=E2=80=AFAM Peter Jeremy <peterj@freebsd.org> = wrote: > > The branch main has been updated by peterj: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3Db9600db494a04db6fbf1a16dbc= f92f7c64d5e863 > > commit b9600db494a04db6fbf1a16dbcf92f7c64d5e863 > Author: Peter Jeremy <peterj@FreeBSD.org> > AuthorDate: 2023-04-26 08:29:33 +0000 > Commit: Peter Jeremy <peterj@FreeBSD.org> > 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 ---
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2BdUSyotDYAeAc9SjvEE%2B=4TOKERr5UXJk5K-GKKUeXGuaapiQ>