Page MenuHomeFreeBSD

Round out SYSCTL macros for the full set of signed and unsigned integers.
ClosedPublic

Authored by rpokala-panasas.com on Nov 6 2015, 4:53 AM.
Tags
None
Referenced Files
F103361552: D4091.diff
Sun, Nov 24, 1:17 AM
Unknown Object (File)
Tue, Nov 19, 7:09 AM
Unknown Object (File)
Sun, Nov 17, 9:51 PM
Unknown Object (File)
Sat, Nov 16, 3:12 PM
Unknown Object (File)
Mon, Nov 11, 2:50 PM
Unknown Object (File)
Wed, Oct 30, 6:50 AM
Unknown Object (File)
Wed, Oct 30, 6:50 AM
Unknown Object (File)
Wed, Oct 30, 6:50 AM
Subscribers

Details

Summary

man9/Makefile - add links for the new macros

sysctl.9 - add the new macros to the various lists. A few things were moved into proper lexical order. Corrected types for some of the existing macros.

sysctl_add_oid.9 - document changed type for "arg2"

kern_sysctl.c - change "arg2" of sysctl_add_oid() to intmax_t, so it can hold any value (including 64-bit values on 32-bit systems). Add sysctl_handle_32() to deal with 32-bit integers

sysctl.h - add CTLTYPE values for types that were missing - signed 8-, 16-, and 32-bit integers, and unsigned 32-bit integers; add SYSCTL macros for them. It turns out that while CTLTYPEs were defined for 64-bit integers, the macros weren't; there are QUAD and UQUAD macros, but they take different parameters than the macros for all the other integer types.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rpokala-panasas.com retitled this revision from to Round out SYSCTL macros for the full set of signed and unsigned integers..
rpokala-panasas.com updated this object.
rpokala-panasas.com edited the test plan for this revision. (Show Details)
rpokala-panasas.com added a reviewer: cem.

Typoed and forgot to include sysctl.9

I think these are fine, but wonder why all the pointer types for the new wrappers are unsigned int * rather than the specific type.

share/man/man9/Makefile
1277 ↗(On Diff #9979)

This change is unrelated.

1294–1297 ↗(On Diff #9979)

This change is unrelated.

share/man/man9/Makefile
1277–1297 ↗(On Diff #9979)

Leftovers from JHB's patch?

share/man/man9/sysctl.9
192–199 ↗(On Diff #9979)

intptr_t is not sufficient for a 64-bit immediate on any 32-bit architecture.

265 ↗(On Diff #9979)

(same)

share/man/man9/sysctl.9
165 ↗(On Diff #9979)

+1 to what imp said.

Should be uint8_t * (similar for the rest of the new ptr argument documentation).

Huh. I synced and did `svn diff', and man9/Makefile only shows my additions. (Or is that the problem - once I created the review, I shouldn't sync anymore until it's submitted?)

The type mis-matches in sysctl.9 are because I was stupid and copy/pasted. But in looking closer, *all* the types listed for "val" args are wrong, including for the pre-existing SYSCTL_ADD_INT, SYSCTL_ADD_U8, SYSCTL_ADD_U16, SYSCTL_ADD_UINT. I'm fixing them all.

Huh. I synced and did `svn diff', and man9/Makefile only shows my additions. (Or is that the problem - once I created the review, I shouldn't sync anymore until it's submitted?)

Yeah, maybe that. I only use arc with git though, so I have no idea.

The type mis-matches in sysctl.9 are because I was stupid and copy/pasted. But in looking closer, *all* the types listed for "val" args are wrong, including for the pre-existing SYSCTL_ADD_INT, SYSCTL_ADD_U8, SYSCTL_ADD_U16, SYSCTL_ADD_UINT. I'm fixing them all.

Be careful; there aren't CTASSERTs for the type of val and if you add them it may take a while to flush out all misuses there. I think it's fine for this patch if val is documented as taking a larger integer type (and implicitly truncating). If you want to clean up the type of val I'd do it in a separate patch.

Be careful; there aren't CTASSERTs for the type of val and if you add them it may take a while to flush out all misuses there

Sorry I was unclear - the code DTRT, but the manpage is wrong. I'm fixing the manpage.

rpokala-panasas.com edited edge metadata.

Hopefully clean up some merge cruft in man9/Makefile, and correct the types of the "val" arguments in the manpage.

Be careful; there aren't CTASSERTs for the type of val and if you add them it may take a while to flush out all misuses there

Sorry I was unclear - the code DTRT, but the manpage is wrong. I'm fixing the manpage.

I think the code does two things wrong(-ish):

  1. sysctl_add_oid()'s val (arg2) argument is only intptr_t when in fact it should be int64_t or intmax_t. 64-bit immediate values are broken on 32-bit architectures without this.
  2. This one is more questionable (and I don't think it should be done in this patch): the code doesn't make any assertions about the size of val given to the macros. (It does make assertions about the size of *ptr.)

Hopefully clean up some merge cruft in man9/Makefile, and correct the types of the "val" arguments in the manpage.

The "ptr" arguments are still documented wrong :).

rpokala-panasas.com marked 3 inline comments as done.
rpokala-panasas.com edited edge metadata.

Change sysctl_add_oid()'s "arg2" (which is what the macro's "val" maps to) to intmax_t, to ensure it can hold any value.

Update sysctl.9 to make sure the type listed for "ptr" and "val" match those actually used by the macros.

cem edited edge metadata.
This revision is now accepted and ready to land.Nov 6 2015, 10:41 PM
This revision was automatically updated to reflect the committed changes.