hwpstate_intel(4): Silence/fix Coverity reports

These were all introduced in the initial import of hwpstate_intel(4).

Reported by:	Coverity
CIDs:		1413161, 1413164, 1413165, 1413167
X-MFC-With:	r357002
This commit is contained in:
cem 2020-01-29 03:15:34 +00:00
parent 08a81a6075
commit 0f0a35a048
2 changed files with 16 additions and 16 deletions

View File

@ -473,11 +473,12 @@ cf_get_method(device_t dev, struct cf_level *level)
* first try the driver and if that fails, fall back to
* estimating.
*/
if (CPUFREQ_DRV_GET(sc->cf_drv_dev, &set) != 0)
goto estimate;
sc->curr_level.total_set = set;
CF_DEBUG("get returning immediate freq %d\n", curr_set->freq);
goto out;
if (CPUFREQ_DRV_GET(sc->cf_drv_dev, &set) == 0) {
sc->curr_level.total_set = set;
CF_DEBUG("get returning immediate freq %d\n",
curr_set->freq);
goto out;
}
} else if (curr_set->freq != CPUFREQ_VAL_UNKNOWN) {
CF_DEBUG("get returning known freq %d\n", curr_set->freq);
error = 0;
@ -523,9 +524,6 @@ cf_get_method(device_t dev, struct cf_level *level)
goto out;
}
estimate:
CF_MTX_ASSERT(&sc->lock);
/*
* We couldn't find an exact match, so attempt to estimate and then
* match against a level.

View File

@ -147,17 +147,19 @@ intel_hwp_dump_sysctl_handler(SYSCTL_HANDLER_ARGS)
sbuf_printf(sb, "\tLowest Performance: %03ju\n", (data >> 24) & 0xff);
rdmsr_safe(MSR_IA32_HWP_REQUEST, &data);
if (sc->hwp_pkg_ctrl && (data & IA32_HWP_REQUEST_PACKAGE_CONTROL)) {
data2 = 0;
if (sc->hwp_pkg_ctrl && (data & IA32_HWP_REQUEST_PACKAGE_CONTROL))
rdmsr_safe(MSR_IA32_HWP_REQUEST_PKG, &data2);
}
sbuf_putc(sb, '\n');
#define pkg_print(x, name, offset) do { \
if (!sc->hwp_pkg_ctrl || (data & x) != 0) \
sbuf_printf(sb, "\t%s: %03ju\n", name, (data >> offset) & 0xff);\
else \
sbuf_printf(sb, "\t%s: %03ju\n", name, (data2 >> offset) & 0xff);\
#define pkg_print(x, name, offset) do { \
if (!sc->hwp_pkg_ctrl || (data & x) != 0) \
sbuf_printf(sb, "\t%s: %03u\n", name, \
(unsigned)(data >> offset) & 0xff); \
else \
sbuf_printf(sb, "\t%s: %03u\n", name, \
(unsigned)(data2 >> offset) & 0xff); \
} while (0)
pkg_print(IA32_HWP_REQUEST_EPP_VALID,
@ -413,7 +415,7 @@ intel_hwpstate_attach(device_t dev)
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
"epp", CTLTYPE_INT | CTLFLAG_RWTUN, dev, sizeof(dev),
"epp", CTLTYPE_INT | CTLFLAG_RWTUN, dev, 0,
sysctl_epp_select, "I",
"Efficiency/Performance Preference "
"(range from 0, most performant, through 100, most efficient)");