Add proper const keywords to sysctl(3) parameters.
authorAlexandre Perrin <alex@kaworu.ch>
Fri, 22 Nov 2013 18:48:23 +0000 (19:48 +0100)
committerSascha Wildner <saw@online.de>
Sun, 24 Nov 2013 23:10:52 +0000 (00:10 +0100)
commit00f0918d338a0f863b786ed4565f12971eaecdc8
tree93f5caccb7fb6f84f02ff08ff3f7c9f965f0ac1c
parent2180d9bb5a241aa649c346c014c758da45ddea74
Add proper const keywords to sysctl(3) parameters.

  Import some sysctl(3) patches from FreeBSD.

  - r204170 change the sysctl(3) and sysctlbyname(3) interfaces so they
    are in sync with FreeBSD and NetBSD.
  - r240176 Avoid a potential segfault in libc when the `name' argument
    is invalid.
  - r204172 & r244153 are cosmetics changes.

  Here follow the commit message from r204170 and r240176:

  - r204170: Add proper const keywords to sysctl(3) parameters.

  The `name' and `newp' arguments can be marked const, because the
  buffers
  they refer to are never changed. While there, perform some other
  cleanups:

  * Implement sysctlbyname() using sysctlnametomib() to prevent
    duplication of an undocumented kernel interface.
  * Fix some whitespace nits.

  - r240176: Avoid segfault if name is invalid.

  Basically, only check for CTL_USER if the sysctl fails with ENOENT.
lib/libc/gen/sysctl.3
lib/libc/gen/sysctl.c
lib/libc/gen/sysctlbyname.c
lib/libc/gen/sysctlnametomib.c
sys/sys/sysctl.h