diff options
| author | Toomas Soome <tsoome@FreeBSD.org> | 2026-07-13 19:15:40 +0000 |
|---|---|---|
| committer | Toomas Soome <tsoome@FreeBSD.org> | 2026-07-13 19:15:40 +0000 |
| commit | 575529a92d7b35628daace82c2965984c6376e2e (patch) | |
| tree | fa3f7accc15a1c455d1b534ef9528e1ce8a505fa | |
| parent | 8ffb400bfd64102ac2a49639ccbbfffbe0c6f127 (diff) | |
bhyve: unsigned <= 0
illumos smatch build is complaining:
pci_nvme_parse_config() warn: 'sc->max_qentries' unsigned <= 0
pci_nvme_parse_config() warn: 'sc->ioslots' unsigned <= 0
Because we are using atoi() to translate string to int, we need
to use int type variable for translation.
Reviewed by: bnovkov
Differential Revision: https://reviews.freebsd.org/D58213
| -rw-r--r-- | usr.sbin/bhyve/pci_nvme.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index 7e6c8bc9d719..3656ee7a8d65 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -3167,6 +3167,7 @@ pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl) char bident[sizeof("XXX:XXX")]; const char *value; uint32_t sectsz; + int val; sc->max_queues = NVME_QUEUES; sc->max_qentries = NVME_MAX_QENTRIES; @@ -3183,20 +3184,21 @@ pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl) sc->max_queues = atoi(value); value = get_config_value_node(nvl, "qsz"); if (value != NULL) { - sc->max_qentries = atoi(value); - if (sc->max_qentries <= 0) { - EPRINTLN("nvme: Invalid qsz option %d", - sc->max_qentries); + val = atoi(value); + if (val <= 0) { + EPRINTLN("nvme: Invalid qsz option %d", val); return (-1); } + sc->max_qentries = val; } value = get_config_value_node(nvl, "ioslots"); if (value != NULL) { - sc->ioslots = atoi(value); - if (sc->ioslots <= 0) { - EPRINTLN("Invalid ioslots option %d", sc->ioslots); + val = atoi(value); + if (val <= 0) { + EPRINTLN("Invalid ioslots option %d", val); return (-1); } + sc->ioslots = val; } value = get_config_value_node(nvl, "sectsz"); if (value != NULL) |
