Skip to content

Commit

Permalink
cppcheck: fix further warning
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Klotzbuecher <mk@mkio.de>
  • Loading branch information
kmarkus committed Jun 9, 2020
1 parent 1bd37d3 commit df316f1
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions libubx/ubx.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,25 +755,26 @@ ubx_data_t *__ubx_data_alloc(const ubx_type_t *typ, const long array_len)
goto out;

d = calloc(1, sizeof(ubx_data_t));

if (d == NULL)
goto out_nomem;
goto out;

if (array_len > 0) {
d->data = calloc(array_len, typ->size);
if (d->data == NULL)
goto out_free;
}

d->type = typ;
d->len = array_len;

d->data = calloc(array_len, typ->size);
if (d->data == NULL)
goto out_nomem;

/* all ok */
goto out;

out_nomem:
if (d)
free(d);
out_free:
free(d);
d = NULL;

out:
out:
return d;
}

Expand Down Expand Up @@ -1970,7 +1971,7 @@ int ubx_port_rm(ubx_block_t *b, const char *name)
*/
ubx_port_t *ubx_port_get(const ubx_block_t *b, const char *name)
{
ubx_port_t *p;
ubx_port_t *p = NULL;

if (b == NULL) {
ERR("port_get: block is NULL");
Expand Down

0 comments on commit df316f1

Please sign in to comment.