Skip to content

Commit

Permalink
Fix several print formatting bugs
Browse files Browse the repository at this point in the history
%*.s is a format specifier for string width
%.*s is a format specifier for string length

99% of the time, we want the latter one and _not_ the former.

(cherry picked from commit e0c0a54)

Conflicts:
	modules/event_flatstore/event_flatstore.c
	modules/proto_tls/tls_params.c
	modules/usrloc/dlist.c
  • Loading branch information
liviuchircu committed Jan 8, 2016
1 parent a752c53 commit f4b81d3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion flags.c
Expand Up @@ -131,7 +131,7 @@ int flag_list_to_bitmask(str *flags, enum flag_type type, char delim)
return 0;

#ifdef EXTRA_DEBUG
LM_DBG("flag_list -> '%*.s'\n", flags->len, flags->s);
LM_DBG("flag_list -> '%.*s'\n", flags->len, flags->s);
#endif
lim = flags->s + flags->len;
crt_flag = flags->s;
Expand Down
4 changes: 2 additions & 2 deletions modules/drouting/drouting.c
Expand Up @@ -492,12 +492,12 @@ static int dr_disable(struct sip_msg *req, char * param_part_name) {
if( (current_partition = get_partition(&part_name))!= NULL) {
return dr_disable_w_part(req, current_partition);
} else {
LM_ERR("Given partition name <%*.s> was not found\n", part_name.len, part_name.s);
LM_ERR("Given partition name <%.*s> was not found\n", part_name.len, part_name.s);
return -1;
}
} else {
if( use_partitions ) {
LM_ERR("Partition name is mandatory <%*.s>\n", part_name.len
LM_ERR("Partition name is mandatory <%.*s>\n", part_name.len
,part_name.s);
return -1;
} else {
Expand Down
2 changes: 1 addition & 1 deletion modules/seas/encode_msg.c
Expand Up @@ -325,7 +325,7 @@ int print_encoded_msg(int fd,char *code,char *prefix)
fprintf(fp,"MESSAGE:\n[%.*s]\n",msglen,msg);
r=(i<100)?1:0;
if(r){
fprintf(fp,"%sREQUEST CODE=%d==%.*s,URI=%.*s,VERSION=%*.s\n",prefix,i,
fprintf(fp,"%sREQUEST CODE=%d==%.*s,URI=%.*s,VERSION=%.*s\n",prefix,i,
payload[METHOD_CODE_IDX+1],&msg[payload[METHOD_CODE_IDX]],
payload[URI_REASON_IDX+1],&msg[payload[URI_REASON_IDX]],
payload[VERSION_IDX+1],&msg[payload[VERSION_IDX]]);
Expand Down
4 changes: 2 additions & 2 deletions modules/usrloc/dlist.c
Expand Up @@ -252,13 +252,13 @@ static int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
continue;
}
if (parse_uri(uri.s, uri.len, &puri) < 0) {
LM_ERR("failed to parse path URI of next hop: '%*.s'\n",
LM_ERR("failed to parse path URI of next hop: '%.*s'\n",
p1_len, p1);
return -1;
}
} else {
if (parse_uri(p, p_len, &puri) < 0) {
LM_ERR("failed to parse contact of next hop: '%*.s'\n",
LM_ERR("failed to parse contact of next hop: '%.*s'\n",
p_len, p);
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/usrloc/ucontact.c
Expand Up @@ -64,7 +64,7 @@ static int compute_next_hop(ucontact_t *contact)

if (contact->path.s && contact->path.len > 0) {
if (get_path_dst_uri(&contact->path, &uri) < 0) {
LM_ERR("failed to get dst_uri for Path '%*.s'\n",
LM_ERR("failed to get dst_uri for Path '%.*s'\n",
contact->path.len, contact->path.s);
return -1;
}
Expand All @@ -75,7 +75,7 @@ static int compute_next_hop(ucontact_t *contact)
uri = contact->c;

if (parse_uri(uri.s, uri.len, &puri) < 0) {
LM_ERR("failed to parse URI of next hop: '%*.s'\n", uri.len, uri.s);
LM_ERR("failed to parse URI of next hop: '%.*s'\n", uri.len, uri.s);
return -1;
}

Expand Down

0 comments on commit f4b81d3

Please sign in to comment.