Fixes after coverity static analysis

This commit is contained in:
Olof hagsand 2024-03-03 17:05:36 +01:00
parent d94b4f5b7c
commit a1badc312e
24 changed files with 148 additions and 70 deletions

View file

@ -285,10 +285,10 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
char *xpath,
cxobj **xp)
{
int retval = -1;
plgstatedata_t *fn; /* Plugin statedata fn */
cxobj *x = NULL;
void *wh = NULL;
int retval = -1;
plgstatedata_t *fn; /* Plugin statedata fn */
cxobj *x = NULL;
void *wh = NULL;
if ((fn = clixon_plugin_api_get(cp)->ca_statedata) != NULL){
if ((x = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
@ -307,10 +307,14 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
goto done;
}
if (xp && x)
if (xp && x){
*xp = x;
x = NULL;
}
retval = 1;
done:
if (x)
xml_free(x);
return retval;
fail:
retval = 0;

View file

@ -232,7 +232,7 @@ backend_accept_client(int fd,
{
int retval = -1;
clixon_handle h = (clixon_handle)arg;
int s;
int s = -1;
struct sockaddr from = {0,};
socklen_t len;
struct client_entry *ce;
@ -297,8 +297,11 @@ backend_accept_client(int fd,
*/
if (clixon_event_reg_fd(s, from_client, (void*)ce, "local netconf client socket") < 0)
goto done;
s = -1;
retval = 0;
done:
if (s != -1)
close(s);
if (name)
free(name);
return retval;

View file

@ -142,7 +142,7 @@ backend_client_add(clixon_handle h,
struct sockaddr *addr)
{
struct backend_handle *bh = handle(h);
struct client_entry *ce;
struct client_entry *ce = NULL;
if ((ce = (struct client_entry *)malloc(sizeof(*ce))) == NULL){
clixon_err(OE_PLUGIN, errno, "malloc");
@ -151,15 +151,16 @@ backend_client_add(clixon_handle h,
memset(ce, 0, sizeof(*ce));
ce->ce_nr = bh->bh_ce_nr++; /* Session-id ? */
memcpy(&ce->ce_addr, addr, sizeof(*addr));
ce->ce_next = bh->bh_ce_list;
ce->ce_handle = h;
if (clicon_session_id_get(h, &ce->ce_id) < 0){
clixon_err(OE_NETCONF, ENOENT, "session_id not set");
free(ce);
return NULL;
}
clicon_session_id_set(h, ce->ce_id + 1);
gettimeofday(&ce->ce_time, NULL);
netconf_monitoring_counter_inc(h, "in-sessions");
ce->ce_next = bh->bh_ce_list;
bh->bh_ce_list = ce;
return ce;
}