platform: fix nm_platform_qdisc_to_string()

When using nm_utils_strbuf_*() API, the buffer gets always moved to the current
end. We must thus remember and return the original start of the buffer.

(cherry picked from commit b658e3da08)
This commit is contained in:
Thomas Haller 2019-05-01 08:23:00 +02:00 committed by Lubomir Rintel
parent ef2b660bb8
commit dd3ca10284

View file

@ -6427,10 +6427,13 @@ const char *
nm_platform_qdisc_to_string (const NMPlatformQdisc *qdisc, char *buf, gsize len)
{
char str_dev[TO_STRING_DEV_BUF_SIZE];
const char *buf0;
if (!nm_utils_to_string_buffer_init_null (qdisc, &buf, &len))
return buf;
buf0 = buf;
nm_utils_strbuf_append (&buf, &len, "%s%s family %u handle %x parent %x info %x",
qdisc->kind,
_to_string_dev (NULL, qdisc->ifindex, str_dev, sizeof (str_dev)),
@ -6458,7 +6461,7 @@ nm_platform_qdisc_to_string (const NMPlatformQdisc *qdisc, char *buf, gsize len)
nm_utils_strbuf_append (&buf, &len, " ecn");
}
return buf;
return buf0;
}
void