Commit 82cea15b authored by Pekka Pessi's avatar Pekka Pessi

Merge branch 'coverity-fixes'

parents b3b31a87 4a50aac2
......@@ -16,12 +16,15 @@ file. The instructions are aimed at developers.
Quick start
===========
To build Sofia-IP::
To build Sofia-SIP::
sh> ``./autogen.sh`` (if building from a fresh CVS checkout)
sh> ``./autogen.sh`` (if building from a fresh Git checkout)
sh> ``./configure``
sh> ``make``
Note that autogen.sh expects to have automake 1.9. If using a newer
automake, generate the GNU autotool files using the command autoreconf.
Autotool notes
==============
......@@ -47,7 +50,7 @@ Maintainer mode
---------------
Sofia-SIP tree is by default configured with automake
maintainer mode disable. In other words, Makefiles do not
maintainer mode disabled. In other words, Makefiles do not
contain rules for recreating or updating configure, Makefiles
or other autotool-generated files. To update these files,
you need to run top-level autogen.sh script.
......@@ -66,8 +69,8 @@ execture. Therefore, they are run only if the environment variable
EXPENSIVE_CHECKS has been set. EXPENSIVE_CHECKS is also set by the build
system if configure option '--enable-expensive-checks' has been used.
On hosts with i386 architecture, it is possible to run tests under
valgrind. Use the make target 'valcheck' for that purpose.
On selectes architectures, it is possible to run tests under valgrind.
Use the make target 'valcheck' for that purpose.
Code-tree layout
================
......
......@@ -535,7 +535,7 @@ void auth_method_basic(auth_mod_t *am,
if (!au->au_params)
continue;
n = base64_d(userpass, upsize - 1, au->au_params[0]);
if (n < 0 || n >= INT_MAX)
if (n >= INT_MAX)
continue;
if (n >= upsize) {
void *b = realloc(userpass == buffer ? NULL : userpass, upsize = n + 1);
......@@ -957,12 +957,12 @@ int auth_readdb_if_needed(auth_mod_t *am)
#define auth_apw_local ((void *)(intptr_t)auth_readdb_internal)
/** Read authentication database */
static
int auth_readdb_internal(auth_mod_t *am, int always)
static int auth_readdb_internal(auth_mod_t *am, int always)
{
FILE *f;
char *data, *s;
size_t len, i, n, N;
ssize_t len;
size_t i, n, N;
auth_passwd_t *apw;
if (!am->am_stat)
......@@ -1018,7 +1018,7 @@ int auth_readdb_internal(auth_mod_t *am, int always)
fclose(f);
if (len < 0)
if (len == -1)
return -1;
/* Count number of entries in new buffer */
......
......@@ -2914,6 +2914,7 @@ int msg_header_remove(msg_t *msg, msg_pub_t *pub, msg_header_t *h)
if (msg == NULL || h == NULL || h == MSG_HEADER_NONE ||
h->sh_class == NULL)
return -1;
if (pub == NULL)
pub = msg->m_object;
......@@ -3004,8 +3005,8 @@ int msg_header_remove_all(msg_t *msg, msg_pub_t *pub, msg_header_t *h)
*
* @param msg message object owning the fragment chain
* @param pub public message structure to which header is added
* @param replaced old header to be removed
* @param h list of header(s) to be added
* @param replaced old header to be removed (may be NULL)
* @param h list of header(s) to be added (may be NULL)
*/
int msg_header_replace(msg_t *msg,
msg_pub_t *pub,
......@@ -3014,16 +3015,20 @@ int msg_header_replace(msg_t *msg,
{
msg_header_t *h0, *last, **hh, **hh0;
if (msg == NULL || replaced == NULL)
if (msg == NULL)
return -1;
if (h == NULL || h == MSG_HEADER_NONE || h->sh_class == NULL)
return msg_header_remove(msg, pub, replaced);
if (pub == NULL)
pub = msg->m_object;
hh = hh0 = msg_hclass_offset(msg->m_class, pub, h->sh_class);
if (hh == NULL)
return -1;
if (replaced == NULL)
return msg_header_add(msg, pub, hh, h);
......
......@@ -1219,7 +1219,6 @@ nea_event_t *nea_event_tcreate(nea_server_t *nes,
tag_type_t tag, tag_value_t value, ...)
{
nea_event_t *ev, **pev;
size_t len = strlen(name);
ta_list ta;
if (nes == NULL || callback == NULL || name == NULL)
......@@ -1235,6 +1234,11 @@ nea_event_t *nea_event_tcreate(nea_server_t *nes,
}
}
else {
size_t len = strlen(name);
if (len == 0)
return NULL;
for (pev = &nes->nes_events; (ev = *pev); pev = &(*pev)->ev_next) {
if (strncmp(ev->ev_event->o_type, name, len) != 0 ||
ev->ev_event->o_type[len] != '.' ||
......
......@@ -428,7 +428,9 @@ struct nta_incoming_s
short irq_status;
unsigned irq_retries:8;
unsigned irq_retries:8; /**< Number of retries.
* Disable SigComp if too many retries.
*/
unsigned irq_default:1; /**< Default transaction */
unsigned irq_canceled:1; /**< Transaction is canceled */
unsigned irq_completed:1; /**< Transaction is completed */
......@@ -1866,7 +1868,7 @@ int nta_agent_get_stats(nta_agent_t *agent,
ta_list ta;
if (!agent)
return su_seterrno(EINVAL), -1;
return su_seterrno(EINVAL);
ta_start(ta, tag, value);
......@@ -3767,7 +3769,7 @@ int nta_msg_ackbye(nta_agent_t *agent, msg_t *msg)
TAG_END())))
goto err;
else
nta_outgoing_destroy(ack);
nta_outgoing_destroy(ack); /* Fire and forget */
home = msg_home(bmsg);
......@@ -3785,6 +3787,8 @@ int nta_msg_ackbye(nta_agent_t *agent, msg_t *msg)
NTATAG_STATELESS(1),
TAG_END())))
goto err;
else
nta_outgoing_destroy(bye); /* Fire and forget */
msg_destroy(msg);
return 0;
......@@ -6351,10 +6355,10 @@ int nta_incoming_complete_response(nta_incoming_t *irq,
ta_list ta;
if (irq == NULL || sip == NULL)
return su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
if (status != 0 && (status < 100 || status > 699))
return su_seterrno(EINVAL), -1;
return su_seterrno(EINVAL);
if (status != 0 && !sip->sip_status)
sip->sip_status = sip_status_create(home, status, phrase, NULL);
......@@ -6756,27 +6760,30 @@ void incoming_retransmit_reply(nta_incoming_t *irq, tport_t *tport)
if (tport == NULL)
tport = irq->irq_tport;
if (tport == NULL)
return;
/* Answer with existing reply */
if (irq->irq_reliable && !irq->irq_reliable->rel_pracked)
msg = reliable_response(irq);
else
msg = irq->irq_response;
if (msg && tport) {
irq->irq_retries++;
if (msg == NULL)
return;
if (irq->irq_retries == 2 && irq->irq_tpn->tpn_comp) {
irq->irq_tpn->tpn_comp = NULL;
if (irq->irq_tpn->tpn_comp && ++irq->irq_retries == 2) {
irq->irq_tpn->tpn_comp = NULL;
if (irq->irq_cc) {
agent_close_compressor(irq->irq_agent, irq->irq_cc);
nta_compartment_decref(&irq->irq_cc);
}
if (irq->irq_cc) {
agent_close_compressor(irq->irq_agent, irq->irq_cc);
nta_compartment_decref(&irq->irq_cc);
}
}
tport = tport_tsend(tport, msg, irq->irq_tpn,
IF_SIGCOMP_TPTAG_COMPARTMENT(irq->irq_cc)
TPTAG_MTU(INT_MAX), TAG_END());
if (tport_tsend(tport, msg, irq->irq_tpn,
IF_SIGCOMP_TPTAG_COMPARTMENT(irq->irq_cc)
TPTAG_MTU(INT_MAX), TAG_END())) {
irq->irq_agent->sa_stats->as_sent_msg++;
irq->irq_agent->sa_stats->as_sent_response++;
}
......@@ -10680,7 +10687,10 @@ void outgoing_answer_a(sres_context_t *orq, sres_query_t *q,
else if (found)
results = &result;
for (i = j = 0; answers && answers[i]; i++) {
if (results == NULL)
found = 0;
for (i = j = 0; results && answers && answers[i]; i++) {
char addr[SU_ADDRSIZE];
sres_a_record_t const *a = answers[i]->sr_a;
......@@ -11343,6 +11353,8 @@ nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq,
agent = orq->orq_agent;
tagged = su_zalloc(agent->sa_home, sizeof(*tagged));
if (!tagged)
return NULL;
home = msg_home((msg_t *)orq->orq_request);
......@@ -11754,7 +11766,7 @@ int nta_agent_bind_tport_update(nta_agent_t *agent,
nta_update_tport_f *callback)
{
if (!agent)
return su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
agent->sa_update_magic = magic;
agent->sa_update_tport = callback;
return 0;
......
......@@ -174,7 +174,7 @@ int nua_client_create(nua_handle_t *nh,
if (tags) {
nua_move_signal(cr->cr_signal, nh->nh_nua->nua_signal);
if (cr->cr_signal) {
if (cr->cr_signal[0]) {
/* Steal reference from signal */
cr->cr_owner = e->e_nh, e->e_nh = NULL;
cr->cr_tags = tags;
......@@ -1150,13 +1150,9 @@ int nua_base_client_check_restart(nua_client_request_t *cr,
sip_add_dup(cr->cr_msg, cr->cr_sip, (sip_header_t *)r) >= 0)
return nua_client_restart(cr, 100, "Redirected via a proxy");
break;
default:
break;
}
}
if (status == 423) {
unsigned my_expires = 0;
......
......@@ -2035,7 +2035,7 @@ sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
char *s = strcpy(_transport, transport);
short c;
for (s = _transport; (c = *s) && c != ';'; s++)
for (; (c = *s) && c != ';'; s++)
if (isupper(c))
*s = tolower(c);
......
......@@ -1549,10 +1549,11 @@ static void nua_session_usage_refresh(nua_handle_t *nh,
sr->sr_method == sip_method_update))
return;
/* XXX - should check if we actually start something */
if (ss->ss_timer->refresher == nua_remote_refresher) {
ss->ss_reason = "SIP;cause=408;text=\"Session timeout\"";
nua_stack_bye(nh->nh_nua, nh, nua_r_bye, NULL);
return;
}
else if (NH_PGET(nh, update_refresh)) {
nua_stack_update(nh->nh_nua, nh, nua_r_update, NULL);
......@@ -2917,8 +2918,8 @@ int nua_prack_server_report(nua_server_request_t *sr, tagi_t const *tags)
status, phrase,
ss->ss_state);
if (nh->nh_soa) {
soa_activate(nh->nh_soa, NULL);
ss->ss_sdp_version = soa_get_user_version(nh->nh_soa);
if (soa_activate(nh->nh_soa, NULL) >= 0)
ss->ss_sdp_version = soa_get_user_version(nh->nh_soa);
}
}
......@@ -4538,9 +4539,11 @@ int session_get_description(sip_t const *sip,
if (pl == NULL)
return 0;
else if (pl->pl_len == 0 || pl->pl_data == NULL)
if (pl->pl_len == 0 || pl->pl_data == NULL)
return 0;
else if (ct == NULL)
if (ct == NULL)
/* Be bug-compatible with our old gateways */
SU_DEBUG_3(("nua: no %s, assuming %s\n",
"Content-Type", SDP_MIME_TYPE));
......@@ -4554,9 +4557,6 @@ int session_get_description(sip_t const *sip,
else
matching_content_type = 1;
if (pl == NULL)
return 0;
if (!matching_content_type) {
/* Make sure we got SDP */
if (pl->pl_len < 3 || !su_casenmatch(pl->pl_data, "v=0", 3))
......
......@@ -107,8 +107,12 @@ static int parsing_error(sdp_parser_t *p, char const *fmt, ...);
/** Parse an SDP message.
*
* The function sdp_parse() parses an SDP message @a msg of size @a
* msgsize. Parsing is done according to the given @a flags. The SDP message
* may not contain a NUL.
* msgsize. If msgsize is -1, the size of message is calculated using
* strlen().
*
* Parsing is done according to the given @a flags.
*
* The SDP message may not contain a NUL.
*
* The parsing result is stored to an #sdp_session_t structure.
*
......@@ -144,7 +148,7 @@ sdp_parse(su_home_t *home, char const msg[], issize_t msgsize, int flags)
char *b;
size_t len;
if (msgsize == -1 || msg == NULL) {
if (msg == NULL) {
p = su_home_clone(home, sizeof(*p));
if (p)
parsing_error(p, "invalid input message");
......@@ -153,7 +157,7 @@ sdp_parse(su_home_t *home, char const msg[], issize_t msgsize, int flags)
return p;
}
if (msgsize == -1 && msg)
if (msgsize == -1)
len = strlen(msg);
else
len = msgsize;
......@@ -819,12 +823,12 @@ static void parse_connection(sdp_parser_t *p, char *r, sdp_connection_t **result
*result = c;
if (su_casenmatch(r, "IN", 2)) {
if (su_casenmatch(r, "IN", 2) && (r[2] == ' ' || r[2] == '\t')) {
char *s;
/* nettype is internet */
token(&r, SPACE TAB, NULL, NULL);
c->c_nettype = sdp_net_in;
s = token(&r, SPACE TAB, NULL, NULL);
/* addrtype */
s = token(&r, SPACE TAB, NULL, NULL);
......@@ -1030,8 +1034,11 @@ static void parse_repeat(sdp_parser_t *p, char *d, sdp_repeat_t **result)
switch (*d) {
case 'd': case 'D': tt *= 24;
/* FALLTHROUGH */
case 'h': case 'H': tt *= 60;
/* FALLTHROUGH */
case 'm': case 'M': tt *= 60;
/* FALLTHROUGH */
case 's': case 'S': d++;
break;
}
......@@ -1080,7 +1087,7 @@ static void parse_zone(sdp_parser_t *p, char *r, sdp_zone_t **result)
if (!(*s == '-' || is_posdigit(*s) || (!STRICT(p) && (*s) == '0')))
break;
do { s++; } while (is_digit(*s));
if (*s && strchr("dhms", *s))
if (*s && strchr(STRICT(p) ? "dhms" : "dhmsDHMS", *s))
s++;
N++;
if (!(i = STRICT(p) ? is_space(*s) : strspn(s, SPACE TAB)))
......@@ -1105,10 +1112,13 @@ static void parse_zone(sdp_parser_t *p, char *r, sdp_zone_t **result)
unsigned long at = strtoul(r, &r, 10);
long offset = strtol(r, &r, 10);
switch (*r) {
case 'd': offset *= 24;
case 'h': offset *= 60;
case 'm': offset *= 60;
case 's': r++;
case 'd': case 'D': offset *= 24;
/* FALLTHROUGH */
case 'h': case 'H': offset *= 60;
/* FALLTHROUGH */
case 'm': case 'M': offset *= 60;
/* FALLTHROUGH */
case 's': case 'S': r++;
break;
}
......
......@@ -260,7 +260,7 @@ sip_contact_string_from_via(su_home_t *home,
char *s = strcpy(_transport, transport);
short c;
for (s = _transport; (c = *s) && c != ';'; s++)
for (; (c = *s) && c != ';'; s++)
if (isupper(c))
*s = tolower(c);
......
......@@ -402,7 +402,7 @@ int soa_set_params(soa_session_t *ss, tag_type_t tag, tag_value_t value, ...)
ss ? ss->ss_actions->soa_name : "", (void *)ss));
if (ss == NULL)
return su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
ta_start(ta, tag, value);
......@@ -624,7 +624,7 @@ int soa_get_params(soa_session_t const *ss,
ss ? ss->ss_actions->soa_name : "", (void *)ss));
if (ss == NULL)
return su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
ta_start(ta, tag, value);
......@@ -856,7 +856,7 @@ int soa_get_capability_sdp(soa_session_t const *ss,
(void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
if (ss == NULL)
return (void)su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
sdp = ss->ss_caps->ssd_sdp;
sdp_str = ss->ss_caps->ssd_str;
......@@ -992,7 +992,7 @@ int soa_get_user_sdp(soa_session_t const *ss,
(void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
if (ss == NULL)
return (void)su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
sdp = ss->ss_user->ssd_sdp;
sdp_str = ss->ss_user->ssd_str;
......@@ -1109,7 +1109,7 @@ int soa_get_remote_sdp(soa_session_t const *ss,
(void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
if (ss == NULL)
return (void)su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
sdp = ss->ss_remote->ssd_sdp;
sdp_str = ss->ss_remote->ssd_str;
......@@ -1225,7 +1225,7 @@ int soa_clear_remote_sdp(soa_session_t *ss)
ss ? ss->ss_actions->soa_name : "", (void *)ss));
if (!ss)
return (void)su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
ss->ss_unprocessed_remote = 0;
......@@ -1281,7 +1281,7 @@ int soa_get_local_sdp(soa_session_t const *ss,
(void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
if (ss == NULL)
return (void)su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
sdp = ss->ss_local->ssd_sdp;
sdp_str = ss->ss_local->ssd_str;
......@@ -1393,7 +1393,7 @@ int soa_remote_sip_features(soa_session_t *ss,
/* Calls soa_base_remote_sip_features() by default */
return ss->ss_actions->soa_remote_sip_features(ss, supported, require);
else
return (void)su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
}
int soa_base_remote_sip_features(soa_session_t *ss,
......@@ -1438,27 +1438,27 @@ int soa_generate_offer(soa_session_t *ss,
/** @ERROR EFAULT Bad address. */
if (ss == NULL)
return su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
/** @ERROR EALREADY An operation is already in progress */
if (ss->ss_in_progress)
return su_seterrno(EALREADY), -1;
return su_seterrno(EALREADY);
/** @ERROR EPROTO We have received offer, now we should send answer */
if (ss->ss_offer_recv && !ss->ss_answer_sent)
return su_seterrno(EPROTO), -1;
return su_seterrno(EPROTO);
/** @ERROR EPROTO We have received SDP, but it has not been processed */
if (soa_has_received_sdp(ss))
return su_seterrno(EPROTO), -1;
return su_seterrno(EPROTO);
/** @ERROR EPROTO We have sent an offer, but have received no answer */
if (ss->ss_offer_sent && !ss->ss_answer_recv)
return su_seterrno(EPROTO), -1;
return su_seterrno(EPROTO);
/** @ERROR EPROTO We have received offer. */
if (ss->ss_unprocessed_remote)
return su_seterrno(EPROTO), -1;
return su_seterrno(EPROTO);
/* We should avoid actual operation unless always is true */
(void)always; /* We always regenerate offer */
......@@ -1527,19 +1527,19 @@ int soa_generate_answer(soa_session_t *ss,
/** @ERROR EFAULT Bad address as @a ss. */
if (ss == NULL)
return su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
/** @ERROR EALREADY An operation is already in progress. */
if (ss->ss_in_progress)
return su_seterrno(EALREADY), -1;
return su_seterrno(EALREADY);
/** @ERROR EPROTO We have sent an offer, but have received no answer. */
if (ss->ss_offer_sent && !ss->ss_answer_recv)
return su_seterrno(EPROTO), -1;
return su_seterrno(EPROTO);
/** @ERROR EPROTO We have not received offer. */
if (!ss->ss_unprocessed_remote)
return su_seterrno(EPROTO), -1;
return su_seterrno(EPROTO);
/* Calls soa_static_generate_answer() by default. */
return ss->ss_actions->soa_generate_answer(ss, completed);
......@@ -1607,20 +1607,20 @@ int soa_process_answer(soa_session_t *ss,
/** @ERROR EFAULT Bad address as @a ss. */
if (ss == NULL)
return su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
/** @ERROR EALREADY An operation is already in progress. */
if (ss->ss_in_progress)
return su_seterrno(EALREADY), -1;
return su_seterrno(EALREADY);
/** @ERROR EPROTO We have not sent an offer
or already have received answer. */
if (!ss->ss_offer_sent || ss->ss_answer_recv)
return su_seterrno(EPROTO), -1;
return su_seterrno(EPROTO);
/** @ERROR EPROTO We have not received answer. */
if (!ss->ss_unprocessed_remote)
return su_seterrno(EPROTO), -1;
return su_seterrno(EPROTO);
/**@sa soa_init_offer_answer(), soa_set_user_sdp(), soa_set_remote_sdp(),
* soa_get_local_sdp(), soa_generate_offer(), soa_generate_answer(),
......@@ -1688,16 +1688,16 @@ int soa_process_reject(soa_session_t *ss,
/** @ERROR EFAULT Bad address as @a ss. */
if (ss == NULL)
return su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
/** @ERROR EALREADY An operation is already in progress. */
if (ss->ss_in_progress)
return su_seterrno(EALREADY), -1;
return su_seterrno(EALREADY);
/** @ERROR EPROTO We have not sent an offer
or already have received answer. */
if (!ss->ss_offer_sent || ss->ss_answer_recv)
return su_seterrno(EPROTO), -1;
return su_seterrno(EPROTO);
/**@sa soa_init_offer_answer(), soa_set_user_sdp(), soa_set_remote_sdp(),
* soa_get_local_sdp(), soa_generate_offer(), soa_generate_answer(),
......@@ -2049,7 +2049,7 @@ int soa_set_sdp(soa_session_t *ss,
new_version = !su_strnmatch(sdp_str, ssd->ssd_unparsed, str_len + 1);
}
else
return (void)su_seterrno(EINVAL), -1;
return su_seterrno(EINVAL);
if (!new_version) {
if (what == soa_remote_sdp_kind) {
......@@ -2275,7 +2275,7 @@ soa_init_sdp_connection_with_session(soa_session_t *ss,
char abuffer[64]; /* getting value from ss_address */
if (ss == NULL || c == NULL || buffer == NULL)
return su_seterrno(EFAULT), -1;
return su_seterrno(EFAULT);
address = ss->ss_address;
......
......@@ -36,6 +36,14 @@ test x$s = x. && s=`pwd`
PATH=/usr/sbin:/usr/local/sbin:/sbin:$PATH
export PATH
# No BIND 9, no fun
{ type named >/dev/null &&
named -v | grep BIND.*9 > /dev/null
} || {
echo test_sresolv: there is no BIND 9 named in your path, skipping
exit 77
}
# Test for support for IPv6 on Linux. This probably fails on everything else.
ipv6='sysctl net.ipv6.conf.default.mtu >/dev/null 2>&1'
# Bind not working with IPv6 on RHEL 4:
......@@ -55,14 +63,6 @@ if netstat --ip >/dev/null 2>&1 ; then
done
fi
# No BIND 9, no fun
{ type named >/dev/null &&
named -v | grep BIND.*9 > /dev/null
} || {
echo test_sresolv: there is no BIND 9 named in you path, skipping
exit 77
}
if eval $ipv6
then
# Figure out nice IPv6 address for us
......
......@@ -516,7 +516,7 @@ sres_sip_url_transport(url_t const *uri)
if (len >= sizeof parameter)
return -1;
for (i = 0; sres_sip_tports[i].stp_name; i++) {
for (i = 0; sres_sip_tports[i].stp_number; i++) {
if (su_casematch(parameter, sres_sip_tports[i].stp_name))
return sres_sip_tports[i].stp_number;
}
......@@ -904,7 +904,7 @@ sres_sip_log_answers(sres_sip_t *srs,
SU_DEBUG_5(("srs(%p): %s IN CNAME %s\n", (void *)srs, domain, cname));
}
#if SU_HAVE_IN6
else if (type == sres_type_cname) {
else if (type == sres_type_aaaa) {
sres_aaaa_record_t const *aaaa = sr->sr_aaaa;
su_inet_ntop(AF_INET6, &aaaa->aaaa_addr, addr, sizeof(addr));
SU_DEBUG_5(("srs(%p): %s IN AAAA %s\n", (void *)srs, domain, addr));
......@@ -1625,7 +1625,7 @@ sres_sip_append_result(sres_sip_t *srs,
break;
}
if ((srs->srs_canonname && srs->srs_numeric) || (SU_LOG->log_level >= 0)) {
if ((srs->srs_canonname && srs->srs_numeric) || (SU_LOG->log_level >= 5)) {
unsigned port = 0;
char const *lb = "", *rb = "";
......@@ -1660,6 +1660,7 @@ sres_sip_append_result(sres_sip_t *srs,
if (!srs->srs_canonname)
canonname = NULL;
if (canonname) {
clen = strlen(canonname);
if (clen && canonname[clen - 1] == '.')
......@@ -1676,6 +1677,7 @@ sres_sip_append_result(sres_sip_t *srs,
*ai = *result;
ai->ai_next = NULL;
ai->ai_addr = memcpy(ai + 1, ai->ai_addr, ai->ai_addrlen);
if (canonname) {
ai->ai_canonname = (char *)(ai->ai_addr) + ai->ai_addrlen;
memcpy(ai->ai_canonname, canonname, clen - 1);
......
......@@ -62,9 +62,8 @@ SOFIA_BEGIN_DECLS
#endif
#define SU_LOG_LEVEL \
((SU_LOG != NULL && SU_LOG->log_init) == 0 ? 9 : \
((SU_LOG != NULL && SU_LOG->log_init > 1) ? \
SU_LOG->log_level : su_log_default->log_level))
((SU_LOG->log_init) == 0 ? 9 : \
((SU_LOG->log_init > 1) ? SU_LOG->log_level : su_log_default->log_level))
#if SU_DEBUG_MAX >= 0
#ifndef SU_LOG
......@@ -86,7 +85,7 @@ SU_DEBUG_DEF(0)
*
* @sa su_llog(), su_vllog(), #su_log_t, @ref debug_logs
*/
#define SU_DEBUG_0(x) (SU_LOG_LEVEL >= 0 ? (su_debug_0 x) : (void)0)
#define SU_DEBUG_0(x) (su_debug_0 x)
/** Log C library errors. */
#define SU_LERROR(s) (su_llog(SU_LOG, 1, "%s: %s\n", (s), strerror(errno)))
......
......@@ -1582,7 +1582,7 @@ int su_home_mutex_unlock(su_home_t *home)
}
if (home->suh_blocks == NULL)
return su_seterrno(EINVAL), -1; /* Uninitialized home */
return su_seterrno(EINVAL); /* Uninitialized home */
su_home_unref(home);
......
......@@ -1196,11 +1196,12 @@ int tport_get_params(tport_t const *self,
int n;
tport_params_t const *tpp;
int connect;