diff options
author | Thomas Haller <thaller@redhat.com> | 2017-05-25 15:24:08 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-05-30 13:40:34 +0200 |
commit | afc76d78ed07ebfc68d939353612476d694ffdaa (patch) | |
tree | 145ed6a4a863e867b14e1beb89cea957a5e78fe8 | |
parent | 844bf3d1a239f409d12ea437dbe866b66f5f1af4 (diff) | |
download | NetworkManager-afc76d78ed07ebfc68d939353612476d694ffdaa.tar.gz |
ifcfg-rh: move numbered_tag() util to "nms-ifcfg-rh-utils.h" header
-rw-r--r-- | src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 24 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h | 24 |
2 files changed, 24 insertions, 24 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 17a0467de7..cdc6669f31 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -302,30 +302,6 @@ read_ip4_address (shvarFile *ifcfg, return TRUE; } -static void -_numbered_tag (char *buf, gsize buf_len, const char *tag_name, int which) -{ - gsize l; - - l = g_strlcpy (buf, tag_name, buf_len); - nm_assert (l < buf_len); - if (which != -1) { - buf_len -= l; - l = g_snprintf (&buf[l], buf_len, "%d", which); - nm_assert (l < buf_len); - } -} -#define numbered_tag(buf, tag_name, which) \ - ({ \ - _nm_unused char *const _buf = (buf); \ - \ - /* some static assert trying to ensure that the buffer is statically allocated. - * It disallows a buffer size of sizeof(gpointer) to catch that. */ \ - G_STATIC_ASSERT (G_N_ELEMENTS (buf) == sizeof (buf) && sizeof (buf) != sizeof (char *) && sizeof (buf) < G_MAXINT); \ - _numbered_tag (buf, sizeof (buf), ""tag_name"", (which)); \ - buf; \ - }) - static gboolean is_any_ip4_address_defined (shvarFile *ifcfg, int *idx) { diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h index 2b2c27558f..8e003ccf89 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h @@ -57,4 +57,28 @@ char *utils_detect_ifcfg_path (const char *path, gboolean only_ifcfg); void nms_ifcfg_rh_utils_user_key_encode (const char *key, GString *str_buffer); gboolean nms_ifcfg_rh_utils_user_key_decode (const char *name, GString *str_buffer); +static inline const char * +_nms_ifcfg_rh_utils_numbered_tag (char *buf, gsize buf_len, const char *tag_name, int which) +{ + gsize l; + + l = g_strlcpy (buf, tag_name, buf_len); + nm_assert (l < buf_len); + if (which != -1) { + buf_len -= l; + l = g_snprintf (&buf[l], buf_len, "%d", which); + nm_assert (l < buf_len); + } + return buf; +} +#define numbered_tag(buf, tag_name, which) \ + ({ \ + _nm_unused char *const _buf = (buf); \ + \ + /* some static assert trying to ensure that the buffer is statically allocated. + * It disallows a buffer size of sizeof(gpointer) to catch that. */ \ + G_STATIC_ASSERT (G_N_ELEMENTS (buf) == sizeof (buf) && sizeof (buf) != sizeof (char *) && sizeof (buf) < G_MAXINT); \ + _nms_ifcfg_rh_utils_numbered_tag (buf, sizeof (buf), ""tag_name"", (which)); \ + }) + #endif /* _UTILS_H_ */ |