Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverity: Fix API usage errors #3465

Merged
merged 9 commits into from
Sep 11, 2024
4 changes: 2 additions & 2 deletions cfg.y
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ port: NUMBER { $$=$1; }

portrange: portrange COMMA NUMBER MINUS NUMBER { IFOR();
if ($3 > $5) {
yyerrorf("invalid port range (%d > %d)\n", $3, $5);
yyerrorf("invalid port range (%d > %d)\n", (int)$3, (int)$5);
YYABORT;
}
pr_tmp = mk_port_range($3, $5);
Expand All @@ -644,7 +644,7 @@ portrange: portrange COMMA NUMBER MINUS NUMBER { IFOR();
}
| NUMBER MINUS NUMBER { IFOR();
if ($1 > $3) {
yyerrorf("invalid port range (%d > %d)\n", $1, $3);
yyerrorf("invalid port range (%d > %d)\n", (int)$1, (int)$3);
YYABORT;
}
$$=mk_port_range($1, $3);
Expand Down
2 changes: 1 addition & 1 deletion dprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ static int log_print_json(str *buf, enum log_json_format json_fmt, char *time,
l = log_escape_json_buf(log_msg_buf, l, p,
buf->len - len - rlen - 1);
if (l < 0) {
stderr_dprint_tmp_err("failed to escape log message!\n",l);
stderr_dprint_tmp_err("failed to escape log message!\n");
return -1;
}

Expand Down
1 change: 1 addition & 0 deletions lib/dbg/struct_hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ int _sh_log(osips_realloc_f realloc_f, struct struct_hist *sh,
if (!new) {
lock_release(&sh->wlock);
LM_ERR("oom\n");
va_end(ap);
return -1;
}
/* CAREFUL: newly added actions are not memset, for speed reasons! */
Expand Down
2 changes: 1 addition & 1 deletion lib/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gen_hash_t *hash_init(unsigned int size)
gen_lock_set_t *locks = NULL;

/* initialized the hash table */
for (n=0 ; n<(8*sizeof(n)) ; n++) {
for (n=0 ; n<(8*sizeof(n) - 1) ; n++) {
if (size==(1<<n))
break;
if (size<(1<<n)) {
Expand Down
2 changes: 1 addition & 1 deletion mem/shm_mem_dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
shm_skip_sh_log = 1; \
hist = _sh_push(p, shm_hist, 1, \
shm_dbg_malloc_func, shm_dbg_free_func); \
_sh_log(shm_dbg_realloc_func, hist, (verb), "%s:%s:%d, %d", \
_sh_log(shm_dbg_realloc_func, hist, (verb), "%s:%s:%d, %lu", \
file, function, line, size); \
/* on oom, we'd rather crash here */ \
_sh_unref(hist, shm_dbg_free_func); \
Expand Down
1 change: 1 addition & 0 deletions modules/httpd/httpd_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ void httpd_proc(int rank)

cert_pem = load_file(tls_cert_file.s);
if (NULL == cert_pem) {
free(key_pem);
LM_ERR("unable to load tls certificate\n");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/proto_ipsec/proto_ipsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ static void ipsec_usrloc_restore(ucontact_t *contact)
return;
}

ctx = ipsec_ctx_new(&sa, &user->ip, ss, sc, &ck, &ik, spi_ps, spi_pc);
ctx = ipsec_ctx_new(&sa, &user->ip, ss, sc, &ck, &ik, spi_pc, spi_ps);
if (!ctx) {
LM_ERR("could not allocate new IPSec ctx\n");
goto release_user;
Expand Down
2 changes: 1 addition & 1 deletion modules/usrloc/ul_mi.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static inline int mi_add_aor_node(mi_item_t *aor_item, urecord_t* r,
if (add_mi_string(ct_item, MI_SSTR("Contact"), c->c.s, c->c.len) < 0)
return -1;

if (add_mi_string_fmt(ct_item, MI_SSTR("ContactID"), "%llu", c->contact_id) < 0)
if (add_mi_string_fmt(ct_item, MI_SSTR("ContactID"), "%lu", c->contact_id) < 0)
return -1;

if (c->expires == 0) {
Expand Down