host: Don't log port if it is zero

This commit is contained in:
Tobias Brunner 2017-02-17 12:32:04 +01:00
parent d8e12fdb13
commit 2283c8148a
2 changed files with 6 additions and 6 deletions

View File

@ -139,7 +139,7 @@ int host_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
snprintf(buffer, sizeof(buffer),
"(address conversion failed)");
}
else if (spec->hash)
else if (spec->hash && port)
{
len = strlen(buffer);
snprintf(buffer + len, sizeof(buffer) - len,

View File

@ -657,18 +657,18 @@ END_TEST
static struct {
char *addr;
uint16_t port;
/* results for %H, %+H, %#H (falls back to [0]) */
/* results for %H, %+H, %#H (falls back to the first entry) */
char *result[3];
} printf_data[] = {
{NULL, 0, { "(null)" }},
{NULL, 500, { "(null)" }},
{"%any", 0, { "%any", "0.0.0.0", "0.0.0.0[0]" }},
{"%any", 0, { "%any", "0.0.0.0", "0.0.0.0" }},
{"%any", 500, { "%any", "0.0.0.0", "0.0.0.0[500]" }},
{"%any6", 0, { "%any6", "::", "::[0]" }},
{"%any6", 0, { "%any6", "::", "::" }},
{"%any6", 500, { "%any6", "::", "::[500]" }},
{"192.168.0.1", 0, { "192.168.0.1", "192.168.0.1", "192.168.0.1[0]" }},
{"192.168.0.1", 0, { "192.168.0.1" }},
{"192.168.0.1", 500, { "192.168.0.1", "192.168.0.1", "192.168.0.1[500]" }},
{"fec1::1", 0, { "fec1::1", "fec1::1", "fec1::1[0]" }},
{"fec1::1", 0, { "fec1::1" }},
{"fec1::1", 500, { "fec1::1", "fec1::1", "fec1::1[500]" }},
};