From: Sascha Wildner Date: Sun, 3 Aug 2014 01:08:37 +0000 (+0200) Subject: kernel: Don't pass the size of the var as arg2 to sysctl_handle_int(). X-Git-Tag: v4.1.0~339 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/4520cefcef52ac2e5f26e70fcef4be1111290d27 kernel: Don't pass the size of the var as arg2 to sysctl_handle_int(). arg1 (second parameter) is for passing a variable and arg2 (third parameter) is for passing a constant (in which case arg1 is NULL). --- diff --git a/sys/ddb/db_sysctl.c b/sys/ddb/db_sysctl.c index 4d548f11c5..afd511259a 100644 --- a/sys/ddb/db_sysctl.c +++ b/sys/ddb/db_sysctl.c @@ -37,7 +37,6 @@ * Author: Archie Cobbs * * $FreeBSD: src/sys/ddb/db_sysctl.c,v 1.1.4.1 2000/08/03 00:09:27 ps Exp $ - * $DragonFly: src/sys/ddb/db_sysctl.c,v 1.2 2003/06/17 04:28:20 dillon Exp $ */ #include @@ -87,7 +86,7 @@ sysctl_debug_panic(SYSCTL_HANDLER_ARGS) int err; int val = 0; - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (val == 1) panic("sysctl_debug_panic"); return err; @@ -116,7 +115,7 @@ sysctl_debug_panic2(SYSCTL_HANDLER_ARGS) int err; int val = 0; - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (val == 1) stack_guard_panic2(); return err; diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c index 628a9ff2dd..d3161144f7 100644 --- a/sys/dev/acpica/acpi_timer.c +++ b/sys/dev/acpica/acpi_timer.c @@ -344,7 +344,7 @@ acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS) if (acpi_cputimer.freq == 0) return (EOPNOTSUPP); freq = acpi_cputimer.freq; - error = sysctl_handle_int(oidp, &freq, sizeof(freq), req); + error = sysctl_handle_int(oidp, &freq, 0, req); if (error == 0 && req->newptr != NULL) cputimer_set_frequency(&acpi_cputimer, freq); diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c index 2e82990790..34515f3805 100644 --- a/sys/dev/sound/pci/es137x.c +++ b/sys/dev/sound/pci/es137x.c @@ -1167,7 +1167,7 @@ sysctl_es137x_spdif_enable(SYSCTL_HANDLER_ARGS) r = es_rd(es, ES1370_REG_STATUS, 4); ES_UNLOCK(es); new_en = (r & ENABLE_SPDIF) ? 1 : 0; - err = sysctl_handle_int(oidp, &new_en, sizeof(new_en), req); + err = sysctl_handle_int(oidp, &new_en, 0, req); if (err || req->newptr == NULL) return (err); @@ -1205,7 +1205,7 @@ sysctl_es137x_latency_timer(SYSCTL_HANDLER_ARGS) ES_LOCK(es); val = pci_read_config(dev, PCIR_LATTIMER, 1); ES_UNLOCK(es); - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (err || req->newptr == NULL) return (err); @@ -1234,7 +1234,7 @@ sysctl_es137x_fixed_rate(SYSCTL_HANDLER_ARGS) if (val < es_caps.minspeed) val = 0; ES_UNLOCK(es); - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (err || req->newptr == NULL) return (err); @@ -1289,7 +1289,7 @@ sysctl_es137x_single_pcm_mixer(SYSCTL_HANDLER_ARGS) set = ES_SINGLE_PCM_MIX(es->escfg); val = set; ES_UNLOCK(es); - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (err || req->newptr == NULL) return (err); diff --git a/sys/dev/sound/pci/via8233.c b/sys/dev/sound/pci/via8233.c index 04b900e164..599c53a033 100644 --- a/sys/dev/sound/pci/via8233.c +++ b/sys/dev/sound/pci/via8233.c @@ -139,7 +139,7 @@ sysctl_via8233_spdif_enable(SYSCTL_HANDLER_ARGS) r = pci_read_config(dev, VIA_PCI_SPDIF, 1); snd_mtxunlock(via->lock); new_en = (r & VIA_SPDIF_EN) ? 1 : 0; - err = sysctl_handle_int(oidp, &new_en, sizeof(new_en), req); + err = sysctl_handle_int(oidp, &new_en, 0, req); if (err || req->newptr == NULL) return err; @@ -170,7 +170,7 @@ sysctl_via8233_dxs_src(SYSCTL_HANDLER_ARGS) snd_mtxlock(via->lock); val = via->dxs_src; snd_mtxunlock(via->lock); - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (err || req->newptr == NULL) return err; diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 164e7093f0..712abbed89 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -55,7 +55,7 @@ sysctl_hw_snd_targetirqrate(SYSCTL_HANDLER_ARGS) int err, val; val = chn_targetirqrate; - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (val < 16 || val > 512) err = EINVAL; else diff --git a/sys/dev/sound/pcm/feeder_rate.c b/sys/dev/sound/pcm/feeder_rate.c index 4365eb59ac..5eaade6e93 100644 --- a/sys/dev/sound/pcm/feeder_rate.c +++ b/sys/dev/sound/pcm/feeder_rate.c @@ -140,7 +140,7 @@ sysctl_hw_snd_feeder_rate_ratemin(SYSCTL_HANDLER_ARGS) int err, val; val = feeder_rate_ratemin; - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (val < 1 || val >= feeder_rate_ratemax) err = EINVAL; else @@ -156,7 +156,7 @@ sysctl_hw_snd_feeder_rate_ratemax(SYSCTL_HANDLER_ARGS) int err, val; val = feeder_rate_ratemax; - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (val <= feeder_rate_ratemin || val > 0x7fffff) err = EINVAL; else @@ -172,7 +172,7 @@ sysctl_hw_snd_feeder_rate_scaling(SYSCTL_HANDLER_ARGS) int err, val; val = feeder_rate_scaling; - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); /* * Feeder Scaling Type * =================== @@ -215,7 +215,7 @@ sysctl_hw_snd_feeder_rate_buffersize(SYSCTL_HANDLER_ARGS) int err, val; val = feeder_rate_buffersize; - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); /* * Don't waste too much kernel space */ diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c index 59f6a5f2b2..f890104cf9 100644 --- a/sys/dev/sound/pcm/sndstat.c +++ b/sys/dev/sound/pcm/sndstat.c @@ -86,7 +86,7 @@ sysctl_hw_sndverbose(SYSCTL_HANDLER_ARGS) int error, verbose; verbose = sndstat_verbose; - error = sysctl_handle_int(oidp, &verbose, sizeof(verbose), req); + error = sysctl_handle_int(oidp, &verbose, 0, req); if (error == 0 && req->newptr != NULL) { lockmgr(&sndstat_lock, LK_EXCLUSIVE); if (verbose < 0 || verbose > 3) diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 8f2a455a4a..4076d5fdf0 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -25,7 +25,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/sound.c,v 1.93.2.5 2007/06/04 09:06:05 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pcm/sound.c,v 1.12 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -362,7 +361,7 @@ sysctl_hw_snd_unit(SYSCTL_HANDLER_ARGS) int error, unit; unit = snd_unit; - error = sysctl_handle_int(oidp, &unit, sizeof(unit), req); + error = sysctl_handle_int(oidp, &unit, 0, req); if (error == 0 && req->newptr != NULL) { if (unit < 0 || (pcm_devclass != NULL && unit >= devclass_get_maxunit(pcm_devclass))) @@ -385,7 +384,7 @@ sysctl_hw_snd_maxautovchans(SYSCTL_HANDLER_ARGS) int i, v, error; v = snd_maxautovchans; - error = sysctl_handle_int(oidp, &v, sizeof(v), req); + error = sysctl_handle_int(oidp, &v, 0, req); if (error == 0 && req->newptr != NULL) { if (v < 0 || v > PCMMAXCHAN) return E2BIG; @@ -1087,7 +1086,7 @@ sysctl_hw_snd_vchans(SYSCTL_HANDLER_ARGS) d = oidp->oid_arg1; newcnt = d->vchancount; - err = sysctl_handle_int(oidp, &newcnt, sizeof(newcnt), req); + err = sysctl_handle_int(oidp, &newcnt, 0, req); if (err == 0 && req->newptr != NULL && d->vchancount != newcnt) err = pcm_setvchans(d, newcnt); diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c index e3b029f841..7dcaf249a1 100644 --- a/sys/dev/sound/pcm/vchan.c +++ b/sys/dev/sound/pcm/vchan.c @@ -356,7 +356,7 @@ sysctl_hw_snd_vchanrate(SYSCTL_HANDLER_ARGS) pcm_inprog(d, -1); return EINVAL; } - err = sysctl_handle_int(oidp, &newspd, sizeof(newspd), req); + err = sysctl_handle_int(oidp, &newspd, 0, req); if (err == 0 && req->newptr != NULL) { if (newspd < 1 || newspd < feeder_rate_ratemin || newspd > feeder_rate_ratemax) { diff --git a/sys/dev/usbmisc/ubt/ubt.c b/sys/dev/usbmisc/ubt/ubt.c index 11fdc973b8..e336babf93 100644 --- a/sys/dev/usbmisc/ubt/ubt.c +++ b/sys/dev/usbmisc/ubt/ubt.c @@ -651,7 +651,7 @@ ubt_sysctl_config(SYSCTL_HANDLER_ARGS) int t, error; t = sc->sc_config; - error = sysctl_handle_int(oidp, &t, sizeof(t), req); + error = sysctl_handle_int(oidp, &t, 0, req); if (error || req->newptr == NULL) return error; diff --git a/sys/dev/usbmisc/uplcom/uplcom.c b/sys/dev/usbmisc/uplcom/uplcom.c index 2ba12313ab..3fb4284185 100644 --- a/sys/dev/usbmisc/uplcom/uplcom.c +++ b/sys/dev/usbmisc/uplcom/uplcom.c @@ -283,7 +283,7 @@ sysctl_hw_usb_uplcom_interval(SYSCTL_HANDLER_ARGS) int err, val; val = uplcominterval; - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (err != 0 || req->newptr == NULL) return (err); if (0 < val && val <= 1000) diff --git a/sys/dev/usbmisc/uticom/uticom.c b/sys/dev/usbmisc/uticom/uticom.c index 6d9c88cd19..adfa8431f1 100644 --- a/sys/dev/usbmisc/uticom/uticom.c +++ b/sys/dev/usbmisc/uticom/uticom.c @@ -211,7 +211,7 @@ sysctl_hw_usb_uticom_stickdsr(SYSCTL_HANDLER_ARGS) int err, val; val = uticomstickdsr; - err = sysctl_handle_int(oidp, &val, sizeof(val), req); + err = sysctl_handle_int(oidp, &val, 0, req); if (err != 0 || req->newptr == NULL) return (err); if (val == 0 || val == 1) diff --git a/sys/netgraph/pppoe/ng_pppoe.c b/sys/netgraph/pppoe/ng_pppoe.c index d3ed66f448..af9b869d88 100644 --- a/sys/netgraph/pppoe/ng_pppoe.c +++ b/sys/netgraph/pppoe/ng_pppoe.c @@ -181,7 +181,7 @@ ngpppoe_set_ethertype(SYSCTL_HANDLER_ARGS) int val; val = pppoe_mode; - error = sysctl_handle_int(oidp, &val, sizeof(int), req); + error = sysctl_handle_int(oidp, &val, 0, req); if (error != 0 || req->newptr == NULL) return (error); switch (val) { diff --git a/sys/platform/pc32/i386/mp_clock.c b/sys/platform/pc32/i386/mp_clock.c index 7425ae6230..44249e553a 100644 --- a/sys/platform/pc32/i386/mp_clock.c +++ b/sys/platform/pc32/i386/mp_clock.c @@ -68,7 +68,7 @@ sysctl_machdep_piix_freq(SYSCTL_HANDLER_ARGS) if (piix_timecounter.tc_frequency == 0) return (EOPNOTSUPP); freq = piix_freq; - error = sysctl_handle_int(oidp, &freq, sizeof(freq), req); + error = sysctl_handle_int(oidp, &freq, 0, req); if (error == 0 && req->newptr != NULL) { piix_freq = freq; piix_timecounter.tc_frequency = piix_freq;