tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Sync between sysctl(3) and sysctlbyname(3) prototypes



Hi all,

I'd like to sync the sysctlbyname(3) and sysctl(3) prototypes by
adding the `const' qualifier to sysctlbyname(3)'s `newp' argument, cf
attached patch.

Any objections ?

 - Arnaud
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3
index dc7e1a9..539d98a 100644
--- a/lib/libc/gen/sysctl.3
+++ b/lib/libc/gen/sysctl.3
@@ -48,7 +48,7 @@
 "const void *newp" "size_t newlen"
 .Ft int
 .Fn sysctlbyname "const char *sname" "void *oldp" "size_t *oldlenp" \
-"void *newp" "size_t newlen"
+"const void *newp" "size_t newlen"
 .Ft int
 .Fn sysctlgetmibinfo "const char *sname" "int *name" "u_int *namelenp" \
 "char *cname" "size_t *csz" "struct sysctlnode **rnode" "int v"
diff --git a/lib/libc/gen/sysctlbyname.c b/lib/libc/gen/sysctlbyname.c
index aece52a..ba88e2f 100644
--- a/lib/libc/gen/sysctlbyname.c
+++ b/lib/libc/gen/sysctlbyname.c
@@ -46,8 +46,8 @@ __weak_alias(sysctlbyname,_sysctlbyname)
  * trivial sysctlbyname() function for the "lazy".
  */
 int
-sysctlbyname(const char *gname, void *oldp, size_t *oldlenp, void *newp,
-            size_t newlen)
+sysctlbyname(const char *gname, void *oldp, size_t *oldlenp,
+            const void *newp, size_t newlen)
 {
        int name[CTL_MAXNAME], rc;
        u_int namelen;
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index a2727b6..0978fe4 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1205,7 +1205,7 @@ typedef void *sysctlfn;
 
 __BEGIN_DECLS
 int    sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
-int    sysctlbyname(const char *, void *, size_t *, void *, size_t);
+int    sysctlbyname(const char *, void *, size_t *, const void *, size_t);
 int    sysctlgetmibinfo(const char *, int *, u_int *,
                         char *, size_t *, struct sysctlnode **, int);
 int    sysctlnametomib(const char *, int *, size_t *);


Home | Main Index | Thread Index | Old Index