From: Dongkyun Son Date: Mon, 12 Jul 2021 04:12:08 +0000 (+0900) Subject: Fix coverity defect: Dereference before null check X-Git-Tag: submit/tizen/20210712.052211^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F99%2F261099%2F1;p=sdk%2Ftarget%2Fsdbd.git Fix coverity defect: Dereference before null check CID 1238715 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking value suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Change-Id: I9a8295a32fc709a9095126db6e2cf5f78cda6c9a Signed-off-by: Dongkyun Son --- diff --git a/src/sdb.c b/src/sdb.c index 4e1e67d..29ed3a8 100755 --- a/src/sdb.c +++ b/src/sdb.c @@ -1757,17 +1757,17 @@ static void init_capabilities(void) { "%s", UNKNOWN); E("fail to get the CPU architecture of model:%d\n", errno); } else { - // check for armv8 and 32 bit architecture, for it make the cpu arch as armv7l - if(!strncmp(value,"armv8",sizeof("armv8")+1) && !strncmp(arch,"32",sizeof("32")+1)) - { - D("Changing cpu arch in capability from %s to %s for %s bit\n",value,"armv7l",arch); - snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch), - "%s", "armv7l"); - } else { - snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch), - "%s", value); - } if (value != NULL) { + // check for armv8 and 32 bit architecture, for it make the cpu arch as armv7l + if(!strncmp(value,"armv8",sizeof("armv8")+1) && !strncmp(arch,"32",sizeof("32")+1)) + { + D("Changing cpu arch in capability from %s to %s for %s bit\n",value,"armv7l",arch); + snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch), + "%s", "armv7l"); + } else { + snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch), + "%s", value); + } free(value); } }