summaryrefslogtreecommitdiffstats
path: root/sys/dev/hatm
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2014-10-21 07:31:21 +0000
committerhselasky <hselasky@FreeBSD.org>2014-10-21 07:31:21 +0000
commit49c137f7be5791eee8102395257cdf48b40c81f7 (patch)
treeee67959a46304c59df434799575e3820a2cc841f /sys/dev/hatm
parentfef9d98869a5c15698b0511d8ff1044b517f1e8f (diff)
downloadFreeBSD-src-49c137f7be5791eee8102395257cdf48b40c81f7.zip
FreeBSD-src-49c137f7be5791eee8102395257cdf48b40c81f7.tar.gz
Fix multiple incorrect SYSCTL arguments in the kernel:
- Wrong integer type was specified. - Wrong or missing "access" specifier. The "access" specifier sometimes included the SYSCTL type, which it should not, except for procedural SYSCTL nodes. - Logical OR where binary OR was expected. - Properly assert the "access" argument passed to all SYSCTL macros, using the CTASSERT macro. This applies to both static- and dynamically created SYSCTLs. - Properly assert the the data type for both static and dynamic SYSCTLs. In the case of static SYSCTLs we only assert that the data pointed to by the SYSCTL data pointer has the correct size, hence there is no easy way to assert types in the C language outside a C-function. - Rewrote some code which doesn't pass a constant "access" specifier when creating dynamic SYSCTL nodes, which is now a requirement. - Updated "EXAMPLES" section in SYSCTL manual page. MFC after: 3 days Sponsored by: Mellanox Technologies
Diffstat (limited to 'sys/dev/hatm')
-rw-r--r--sys/dev/hatm/if_hatm.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/dev/hatm/if_hatm.c b/sys/dev/hatm/if_hatm.c
index 0be8a3d..0677a14 100644
--- a/sys/dev/hatm/if_hatm.c
+++ b/sys/dev/hatm/if_hatm.c
@@ -1312,9 +1312,17 @@ kenv_getuint(struct hatm_softc *sc, const char *var,
*ptr = def;
- if (SYSCTL_ADD_UINT(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
- OID_AUTO, var, rw ? CTLFLAG_RW : CTLFLAG_RD, ptr, 0, "") == NULL)
- return (ENOMEM);
+ if (rw != 0) {
+ if (SYSCTL_ADD_UINT(&sc->sysctl_ctx,
+ SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, var,
+ CTLFLAG_RW, ptr, 0, "") == NULL)
+ return (ENOMEM);
+ } else {
+ if (SYSCTL_ADD_UINT(&sc->sysctl_ctx,
+ SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, var,
+ CTLFLAG_RD, ptr, 0, "") == NULL)
+ return (ENOMEM);
+ }
snprintf(full, sizeof(full), "hw.%s.%s",
device_get_nameunit(sc->dev), var);
OpenPOWER on IntegriCloud