Skip to content

Commit

Permalink
fix harmless warnings in several modules
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Apr 10, 2019
1 parent 72f0bf5 commit 7cf11de
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 68 deletions.
20 changes: 1 addition & 19 deletions modules/carrierroute/carrierroute.c
Expand Up @@ -391,24 +391,6 @@ static int mod_init(void) {
*
* @return 0 on success, -1 on failure
*/
static int pv_fixup(void ** param) {
pv_elem_t *model;
str s;

s.s = (char *)(*param);
s.len = strlen(s.s);
if (s.len <= 0) return -1;
/* Check the format */
if(pv_parse_format(&s, &model)<0) {
LM_ERR("pv_parse_format failed for '%s'\n", (char *)(*param));
return -1;
}
*param = (void*)model;

return 0;
}


/**
* fixes the module functions' parameter if it is a carrier.
*/
Expand All @@ -419,7 +401,7 @@ static int carrier_fixup(void ** param) {
return -1;
}
LM_DBG("carrier tree %.*s has id %d\n",
((str*)*param)->len, ((str*)*param)->s, (int)*param);
((str*)*param)->len, ((str*)*param)->s, (int)(unsigned long)*param);

return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions modules/carrierroute/route_func.c
Expand Up @@ -514,8 +514,8 @@ int cr_do_route(struct sip_msg * _msg, void *_carrier,

ret = -1;

carrier_id = (int)_carrier;
domain_id = (int)_domain;
carrier_id = (int)(unsigned long)_carrier;
domain_id = (int)(unsigned long)_domain;
if (domain_id < 0) {
LM_ERR("invalid domain id %d\n", domain_id);
return -1;
Expand Down Expand Up @@ -660,8 +660,8 @@ int cr_load_next_domain(struct sip_msg * _msg, void *_carrier,

ret = -1;

carrier_id = (int)_carrier;
domain_id = (int)_domain;
carrier_id = (int)(unsigned long)_carrier;
domain_id = (int)(unsigned long)_domain;
if (domain_id < 0) {
LM_ERR("invalid domain id %d\n", domain_id);
return -1;
Expand Down
30 changes: 15 additions & 15 deletions modules/db_berkeley/bdb_lib.c
Expand Up @@ -394,7 +394,7 @@ database_p bdblib_get_db(str *_s)
memcpy(_db_p->name.s, _s->s, _s->len);
_db_p->name.len = _s->len;

strncpy(name, _s->s, _s->len);
memcpy(name, _s->s, _s->len);
name[_s->len] = 0;

if ((rc = bdblib_create_dbenv(&(_db_p->dbenv), name)) != 0)
Expand Down Expand Up @@ -509,18 +509,18 @@ void bdblib_log(int op, table_p _tp, char* _msg, int len)
switch (op)
{
case JLOG_INSERT:
strncpy(c, "INSERT|", op_len);
memcpy(c, "INSERT|", op_len);
break;
case JLOG_UPDATE:
strncpy(c, "UPDATE|", op_len);
memcpy(c, "UPDATE|", op_len);
break;
case JLOG_DELETE:
strncpy(c, "DELETE|", op_len);
memcpy(c, "DELETE|", op_len);
break;
}

c += op_len;
strncpy(c, _msg, len);
memcpy(c, _msg, len);
c +=len;
*c = '\n';
c++;
Expand Down Expand Up @@ -587,7 +587,7 @@ table_p bdblib_create_table(database_p _db, str *_s)
}

memset(tblname, 0, MAX_TABLENAME_SIZE);
strncpy(tblname, _s->s, _s->len);
memcpy(tblname, _s->s, _s->len);

#ifdef BDB_EXTRA_DEBUG
LM_DBG("CREATE TABLE = %s\n", tblname);
Expand Down Expand Up @@ -726,18 +726,18 @@ int bdblib_create_journal(table_p _tp)
if(! _db_parms->log_enable) return 0;
/* journal filename ; e.g. '/var/opensips/db/location-YYYYMMDDhhmmss.jnl' */
s=fn;
strncpy(s, _db_p->name.s, _db_p->name.len);
memcpy(s, _db_p->name.s, _db_p->name.len);
s+=_db_p->name.len;

*s = '/';
s++;

strncpy(s, _tp->name.s, _tp->name.len);
memcpy(s, _tp->name.s, _tp->name.len);
s+=_tp->name.len;

t = localtime( &tim );
bl=strftime(d,128,"-%Y%m%d%H%M%S.jnl",t);
strncpy(s, d, bl);
memcpy(s, d, bl);
s+= bl;
*s = 0;

Expand Down Expand Up @@ -1101,7 +1101,7 @@ int bdblib_valtochar(table_p _tp, int* _lres, char* _k, int* _klen, db_val_t* _v
}

/* write sk */
strncpy(p, sk, len);
memcpy(p, sk, len);
p += len;
*_klen = sum;

Expand All @@ -1112,7 +1112,7 @@ int bdblib_valtochar(table_p _tp, int* _lres, char* _k, int* _klen, db_val_t* _v
}

/* write delim */
strncpy(p, delim, DELIM_LEN);
memcpy(p, delim, DELIM_LEN);
p += DELIM_LEN;
*_klen = sum;;
}
Expand Down Expand Up @@ -1174,7 +1174,7 @@ int bdblib_valtochar(table_p _tp, int* _lres, char* _k, int* _klen, db_val_t* _v
return -5;
}

strncpy(p, sk, len);
memcpy(p, sk, len);
p += len;
*_klen = sum;

Expand All @@ -1185,7 +1185,7 @@ int bdblib_valtochar(table_p _tp, int* _lres, char* _k, int* _klen, db_val_t* _v
}

/* append delim */
strncpy(p, delim, DELIM_LEN);
memcpy(p, delim, DELIM_LEN);
p += DELIM_LEN;
*_klen = sum;

Expand Down Expand Up @@ -1217,7 +1217,7 @@ int bdblib_valtochar(table_p _tp, int* _lres, char* _k, int* _klen, db_val_t* _v
return -5;
}

strncpy(p, _tp->colp[i]->dv.s, len);
memcpy(p, _tp->colp[i]->dv.s, len);
p += len;
*_klen = sum;

Expand All @@ -1227,7 +1227,7 @@ int bdblib_valtochar(table_p _tp, int* _lres, char* _k, int* _klen, db_val_t* _v
return -5;
}

strncpy(p, delim, DELIM_LEN);
memcpy(p, delim, DELIM_LEN);
p += DELIM_LEN;
*_klen = sum;
next:
Expand Down
12 changes: 4 additions & 8 deletions modules/db_berkeley/bdb_res.c
Expand Up @@ -137,8 +137,7 @@ int bdb_convert_row(db_res_t* _res, char *bdb_result, int* _lres)
goto error;
}
LM_DBG("allocated %d bytes for row_buf[%d] at %p\n", len, i, row_buf[i]);
memset(row_buf[i], 0, len+1);
strncpy(row_buf[i], s, len);
memcpy(row_buf[i], s, len+1);
}

}
Expand All @@ -156,8 +155,7 @@ int bdb_convert_row(db_res_t* _res, char *bdb_result, int* _lres)
return -1;
}
LM_DBG("allocated %d bytes for row_buf[%d] at %p\n", len, col, row_buf[col]);
memset(row_buf[col], 0, len+1);
strncpy(row_buf[col], s, len);
memcpy(row_buf[col], s, len+1);
}
s = strsep(&bdb_result, DELIM);
col++;
Expand Down Expand Up @@ -255,8 +253,7 @@ int bdb_append_row(db_res_t* _res, char *bdb_result, int* _lres, int _rx)
LM_ERR("no private memory left\n");
goto error;
}
memset(row_buf[i], 0, len+1);
strncpy(row_buf[i], s, len);
memcpy(row_buf[i], s, len+1);
}
}
}
Expand All @@ -277,8 +274,7 @@ int bdb_append_row(db_res_t* _res, char *bdb_result, int* _lres, int _rx)
LM_ERR("no private memory left\n");
return -1;
}
memset(row_buf[col], 0, len+1);
strncpy(row_buf[col], s, len);
memcpy(row_buf[col], s, len+1);
}
s = strsep(&bdb_result, DELIM);
col++;
Expand Down
12 changes: 6 additions & 6 deletions modules/db_berkeley/db_berkeley.c
Expand Up @@ -191,7 +191,7 @@ db_con_t* bdb_init(const str* _sqlurl)
}
strcpy(bdb_path, CFG_DIR);
bdb_path[sizeof(CFG_DIR)] = '/';
strncpy(&bdb_path[sizeof(CFG_DIR)+1], _s.s, _s.len);
memcpy(&bdb_path[sizeof(CFG_DIR)+1], _s.s, _s.len);
_s.len += sizeof(CFG_DIR);
_s.s = bdb_path;
}
Expand Down Expand Up @@ -284,7 +284,7 @@ void bdb_check_reload(db_con_t* _con)
return;
}

strncpy(p, s.s, s.len);
memcpy(p, s.s, s.len);
p+=s.len;

len++;
Expand All @@ -307,10 +307,10 @@ void bdb_check_reload(db_con_t* _con)
return;
}

strncpy(t, s.s, s.len);
memcpy(t, s.s, s.len);
t[s.len] = 0;

strncpy(p, s.s, s.len);
memcpy(p, s.s, s.len);
p+=s.len;
*p=0;

Expand Down Expand Up @@ -1190,7 +1190,7 @@ int bdb_update(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
}

/* copy original column to the new column */
strncpy(t, c, len);
memcpy(t, c, len);

next:
t+=len;
Expand All @@ -1203,7 +1203,7 @@ int bdb_update(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
goto cleanup;
}

strncpy(t, delim, DELIM_LEN);
memcpy(t, delim, DELIM_LEN);
t += DELIM_LEN;

c = strsep(&tmp, DELIM);
Expand Down
10 changes: 0 additions & 10 deletions modules/jabber/jabber.c
Expand Up @@ -125,7 +125,6 @@ static int xj_send_message(struct sip_msg*, char*, char*);
static int xj_join_jconf(struct sip_msg*, char*, char*);
static int xj_exit_jconf(struct sip_msg*, char*, char*);
static int xj_go_online(struct sip_msg*, char*, char*);
static int xj_go_offline(struct sip_msg*, char*, char*);

void destroy(void);

Expand Down Expand Up @@ -447,15 +446,6 @@ static int xj_go_online(struct sip_msg *msg, char* foo1, char * foo2)
return xjab_manage_sipmsg(msg, XJ_GO_ONLINE);
}

/**
* go offline in Jabber network
*/
static int xj_go_offline(struct sip_msg *msg, char* foo1, char * foo2)
{
LM_DBG("go offline in Jabber network\n");
return xjab_manage_sipmsg(msg, XJ_GO_OFFLINE);
}

/**
* manage SIP message
*/
Expand Down
12 changes: 6 additions & 6 deletions modules/permissions/hash.c
Expand Up @@ -515,16 +515,16 @@ int subnet_table_mi_print(struct subnet* table, mi_item_t *part_item,
static char ip_buff[IP_ADDR_MAX_STR_SIZE];
mi_item_t *dests_arr, *dest_item;

count = table[PERM_MAX_SUBNETS].grp;
count = table[PERM_MAX_SUBNETS].grp;

dests_arr = add_mi_array(part_item, MI_SSTR("Destinations"));
dests_arr = add_mi_array(part_item, MI_SSTR("Destinations"));
if (dests_arr)
return -1;

for (i = 0; i < count; i++) {
dest_item = add_mi_object(dests_arr, NULL, 0);
if (!dest_item)
return -1;
for (i = 0; i < count; i++) {
dest_item = add_mi_object(dests_arr, NULL, 0);
if (!dest_item)
return -1;

ip = ip_addr2a(&table[i].subnet->ip);
if (!ip) {
Expand Down

0 comments on commit 7cf11de

Please sign in to comment.