diff options
author | Thomas Haller <thaller@redhat.com> | 2015-10-12 10:27:33 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-11-01 17:28:08 +0100 |
commit | a2d59f5f102a5d6a353769f72571c3cad8d7c3d4 (patch) | |
tree | 8e69d232eb1017ce801b29364c73b70a29684ff9 /src/platform/tests/test-general.c | |
parent | 7e2710fcd03ebd11c70efbc3904b3812b001db5b (diff) |
platform: add buffer argument to platform to-string functions
Arguably, it is more convenient to use the static buffer as
it saves typing.
But having such a low-level function use a static buffer also
limits the way how to use it. As it was, you could not avoid
using the static buffer.
E.g. you cannot do:
char buf[100];
_LOGD ("nmp-object: %s; platform-link: %s",
nmp_object_to_string (nmpobj, buf, sizeof(buf)),
nm_platform_link_to_string (link));
This will fail for non-obvious reasons because both
to-string functions end up using the same static buffer.
Also change the to-string implementations to accept NULL
as valid and return it as "(null)".
https://bugzilla.gnome.org/show_bug.cgi?id=756427
Diffstat (limited to 'src/platform/tests/test-general.c')
-rw-r--r-- | src/platform/tests/test-general.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/platform/tests/test-general.c b/src/platform/tests/test-general.c index b1dd454e2..20522b5b8 100644 --- a/src/platform/tests/test-general.c +++ b/src/platform/tests/test-general.c @@ -58,28 +58,28 @@ test_nm_platform_ip6_address_to_string_flags (void) { NMPlatformIP6Address addr = { 0 }; - g_assert_cmpstr (strstr (nm_platform_ip6_address_to_string (&addr), " flags "), ==, NULL); + g_assert_cmpstr (strstr (nm_platform_ip6_address_to_string (&addr, NULL, 0), " flags "), ==, NULL); addr.flags = IFA_F_MANAGETEMPADDR; - nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags mngtmpaddr "); + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr, NULL, 0), " flags mngtmpaddr "); addr.flags = IFA_F_NOPREFIXROUTE; - nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags noprefixroute "); + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr, NULL, 0), " flags noprefixroute "); addr.flags = IFA_F_MANAGETEMPADDR | IFA_F_NOPREFIXROUTE; - nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags mngtmpaddr,noprefixroute "); + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr, NULL, 0), " flags mngtmpaddr,noprefixroute "); addr.flags = IFA_F_TENTATIVE | IFA_F_NOPREFIXROUTE; - nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags tentative,noprefixroute "); + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr, NULL, 0), " flags tentative,noprefixroute "); addr.flags = IFA_F_TENTATIVE | IFA_F_PERMANENT | IFA_F_MANAGETEMPADDR| IFA_F_NOPREFIXROUTE; - nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags tentative,permanent,mngtmpaddr,noprefixroute "); + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr, NULL, 0), " flags tentative,permanent,mngtmpaddr,noprefixroute "); addr.flags = IFA_F_TENTATIVE | IFA_F_PERMANENT | IFA_F_MANAGETEMPADDR| IFA_F_NOPREFIXROUTE | 0x8000; - nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags tentative,permanent,mngtmpaddr,noprefixroute, "); + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr, NULL, 0), " flags tentative,permanent,mngtmpaddr,noprefixroute, "); addr.flags = IFA_F_TENTATIVE | IFA_F_PERMANENT | IFA_F_MANAGETEMPADDR| IFA_F_NOPREFIXROUTE | ((G_MAXUINT - (G_MAXUINT >> 1)) >> 1); - nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr), " flags tentative,permanent,mngtmpaddr,noprefixroute, "); + nmtst_assert_str_has_substr (nm_platform_ip6_address_to_string (&addr, NULL, 0), " flags tentative,permanent,mngtmpaddr,noprefixroute, "); } /******************************************************************/ |