Page MenuHomeFreeBSD

Permit the kernel environment to set an array of numeric values for a single sysctl(9) node.
ClosedPublic

Authored by hselasky on Jun 14 2018, 12:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 2:59 PM
Unknown Object (File)
Sun, Oct 27, 10:19 AM
Unknown Object (File)
Oct 6 2024, 11:25 PM
Unknown Object (File)
Sep 29 2024, 7:10 AM
Unknown Object (File)
Sep 29 2024, 7:10 AM
Unknown Object (File)
Sep 29 2024, 7:10 AM
Unknown Object (File)
Sep 29 2024, 7:10 AM
Unknown Object (File)
Sep 29 2024, 7:09 AM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 17273

Event Timeline

I think this is good. I'm a little hesitant about the suffix part of it, but know of no good way to flag it's acceptance (I know of several ways, they are all complex and error-prone though).
so, I'd feel better with someone else also blessed the change.

This revision is now accepted and ready to land.Jun 14 2018, 2:14 PM
kern/kern_environment.c
548 ↗(On Diff #43750)

I am confused by this loop control. You start with a random garbage on stack for the initial buf[] content.

kern/kern_environment.c
548 ↗(On Diff #43750)

ptr = buf, means address of buf. buf is filled with a valid string after the getenv_string() call.

kern/kern_environment.c
545 ↗(On Diff #43750)

The comment is useless.

548 ↗(On Diff #43750)

Ah, I missed it.

552 ↗(On Diff #43750)

Style: declare vars at the top of the function.

554 ↗(On Diff #43750)

Well, almost all of the comments trivially rephrase the code.

587 ↗(On Diff #43750)

This accepts arbitrary garbage after the numeric part.

614 ↗(On Diff #43750)

Now I am confused by this comparision. Valid range for unsigned char on all supported arches is 0..255.

619 ↗(On Diff #43750)

Same note for uint16_t.

624 ↗(On Diff #43750)

And there.

kern/kern_environment.c
614 ↗(On Diff #43750)

I'll fix.

This revision now requires review to proceed.Jun 14 2018, 4:28 PM
This revision is now accepted and ready to land.Jun 14 2018, 4:58 PM
sys/kern/kern_environment.c
539

I think it would be simpler to just add a 'bool signed' parameter instead of overloading type_size. type_size can then always be 'sizeof(foo)' which would be easier to read at the call-site. If you'd rather not use a bool, then define a simple enum:

enum sign {
    SIGNED,
    UNSIGNED,
};

And use that instead so you have something like this for CTLTYPE_UINT:

error = getenv_array(path + rem, data, sizeof(data), &size, sizeof(int), UNSIGNED);
sys/kern/kern_sysctl.c
195

Using a uint64_t array initially threw me off. I wonder if it wouldn't be more accurate to declare this as 'char data[1024] __Alignas(uint64_t)' or the like?

Update patch as per jhb@'s suggestions.

This revision now requires review to proceed.Jun 15 2018, 2:56 PM
sys/sys/systm.h
349

0 should be false, since you use bool as the function argument type.

350

1 -> true

351

Wrap the line.

Update as per kib@'s suggestions.

jhb added inline comments.
sys/sys/systm.h
349

I would perhaps move these constants up out of the list of function prototypes, however the prevailing style in this file seems to be to include them without a comment below a function prototype followed by a blank line before the next function prototype (see HD_* after hexdump(), HASH_* after hashinit_flags()).

This revision is now accepted and ready to land.Jun 20 2018, 6:07 PM
This revision was automatically updated to reflect the committed changes.