This issue was reported by static analysis. It is a false positive, because both `rte_socket_count` and `rte_socket_id_by_idx` only report information about physical sockets, and these specific calls are made during EAL initialization, so no other sockets (i.e. external) could have been available, so it is pretty much impossible to get invalid return here.
Still, to avoid future false positives, we can fix it here. Coverity issue: 470131 Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com> --- lib/eal/linux/eal_memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 59f35b415e..e433c1afee 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -1785,8 +1785,14 @@ memseg_primary_init_32(void) unsigned int main_lcore_socket; struct rte_config *cfg = rte_eal_get_configuration(); bool skip; + int ret; - socket_id = rte_socket_id_by_idx(i); + ret = rte_socket_id_by_idx(i); + if (ret == -1) { + EAL_LOG(ERR, "Cannot get socket ID for socket index %u", i); + return -1; + } + socket_id = (unsigned int)ret; #ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES /* we can still sort pages by socket in legacy mode */ -- 2.47.1