[PATCH 1/1] all/trivial: rename STRLEN() macro to NM_STRLEN()
- From: Thomas Haller <thaller redhat com>
- To: networkmanager-list gnome org
- Subject: [PATCH 1/1] all/trivial: rename STRLEN() macro to NM_STRLEN()
- Date: Fri, 12 Feb 2016 12:34:43 +0100
We should not have defines/macros in header files without a nm/NM prefix.
STRLEN() was one of the few offendors.
---
clients/cli/settings.c | 8 ++---
libnm-core/nm-keyfile-reader.c | 12 ++++----
libnm-core/nm-setting-8021x.c | 8 ++---
libnm-core/nm-utils.c | 2 +-
libnm-core/tests/test-keyfile.c | 4 +--
libnm-util/nm-setting-8021x.c | 8 ++---
libnm-util/nm-utils.c | 2 +-
shared/nm-macros-internal.h | 2 +-
src/NetworkManagerUtils.c | 36 +++++++++++------------
src/dhcp-manager/nm-dhcp-client.c | 2 +-
src/dhcp-manager/nm-dhcp-dhclient-utils.c | 6 ++--
src/dhcp-manager/nm-dhcp-systemd.c | 4 +--
src/dhcp-manager/tests/test-dhcp-dhclient.c | 4 +--
src/nm-config-data.c | 10 +++----
src/nm-config.c | 10 +++----
src/nm-dispatcher.c | 2 +-
src/nm-logging.c | 2 +-
src/nm-route-manager.c | 2 +-
src/platform/nm-linux-platform.c | 4 +--
src/platform/nm-platform-utils.c | 4 +--
src/platform/nm-platform.c | 6 ++--
src/settings/nm-settings.c | 4 +--
src/settings/plugins/ibft/reader.c | 4 +--
src/settings/plugins/ifcfg-rh/reader.c | 2 +-
src/settings/plugins/ifcfg-rh/utils.c | 8 ++---
src/settings/plugins/ifnet/net_utils.c | 2 +-
src/settings/plugins/keyfile/tests/test-keyfile.c | 6 ++--
src/tests/test-general.c | 4 +--
28 files changed, 84 insertions(+), 84 deletions(-)
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index baf0a92..fc7e0c6 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -3328,8 +3328,8 @@ nmc_property_connection_set_lldp (NMSetting *setting, const char *prop,
char *p = val_strip; \
gboolean success; \
\
- if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, STRLEN
(NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
- p += STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
+ if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, NM_STRLEN
(NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
+ p += NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
\
success = set_func (NM_SETTING_802_1X (setting), \
p, \
@@ -3350,8 +3350,8 @@ nmc_property_connection_set_lldp (NMSetting *setting, const char *prop,
const char *path, *password; \
gboolean success; \
\
- if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, STRLEN
(NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
- p += STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
+ if (strncmp (val_strip, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, NM_STRLEN
(NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) == 0) \
+ p += NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH); \
\
strv = nmc_strsplit_set (p, " \t,", 2); \
path = strv[0]; \
diff --git a/libnm-core/nm-keyfile-reader.c b/libnm-core/nm-keyfile-reader.c
index 6a0584a..41cd9a7 100644
--- a/libnm-core/nm-keyfile-reader.c
+++ b/libnm-core/nm-keyfile-reader.c
@@ -874,17 +874,17 @@ handle_as_scheme (KeyfileReaderInfo *info, GBytes *bytes, NMSetting *setting, co
/* It's the PATH scheme, can just set plain data.
* In this case, @data_len includes */
- if ( data_len >= STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)
+ if ( data_len >= NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)
&& g_str_has_prefix (data, NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)) {
if (nm_setting_802_1x_check_cert_scheme (data, data_len + 1, NULL) ==
NM_SETTING_802_1X_CK_SCHEME_PATH) {
- const char *path = &data[STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)];
+ const char *path = &data[NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)];
gs_free char *path_free = NULL;
if (path[0] != '/') {
/* we want to read absolute paths because we use keyfile as exchange
* between different processes which might not have the same cwd. */
path = path_free = get_cert_path (info->base_dir, (const guint8 *) path,
- data_len - STRLEN
(NM_KEYFILE_CERT_SCHEME_PREFIX_PATH));
+ data_len - NM_STRLEN
(NM_KEYFILE_CERT_SCHEME_PREFIX_PATH));
}
g_object_set (setting, key, bytes, NULL);
@@ -899,15 +899,15 @@ handle_as_scheme (KeyfileReaderInfo *info, GBytes *bytes, NMSetting *setting, co
}
return TRUE;
}
- if ( data_len > STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB)
+ if ( data_len > NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB)
&& g_str_has_prefix (data, NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB)) {
- const char *cdata = data + STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB);
+ const char *cdata = data + NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB);
guchar *bin;
GBytes *bytes2;
gsize i;
gboolean valid_base64;
- data_len -= STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB);
+ data_len -= NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB);
/* Let's be strict here. We expect valid base64, no funny stuff!!
* We didn't write such invalid data ourselfes and refuse to read it as blob. */
diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c
index cd0d4e6..c141817 100644
--- a/libnm-core/nm-setting-8021x.c
+++ b/libnm-core/nm-setting-8021x.c
@@ -447,8 +447,8 @@ nm_setting_802_1x_check_cert_scheme (gconstpointer pdata, gsize length, GError *
}
/* interpret the blob as PATH if it starts with "file://". */
- if ( length >= STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)
- && !memcmp (data, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, STRLEN
(NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH))) {
+ if ( length >= NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)
+ && !memcmp (data, NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH, NM_STRLEN
(NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH))) {
/* But it must also be NUL terminated, contain at least
* one non-NUL character, and contain only one trailing NUL
* chracter.
@@ -464,7 +464,7 @@ nm_setting_802_1x_check_cert_scheme (gconstpointer pdata, gsize length, GError *
}
length--;
- if (length <= STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) {
+ if (length <= NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH)) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
@@ -472,7 +472,7 @@ nm_setting_802_1x_check_cert_scheme (gconstpointer pdata, gsize length, GError *
return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
}
- if (!g_utf8_validate (data + STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH), length -
STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH), NULL)) {
+ if (!g_utf8_validate (data + NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH), length -
NM_STRLEN (NM_SETTING_802_1X_CERT_SCHEME_PREFIX_PATH), NULL)) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 930f528..c382d7e 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -48,7 +48,7 @@
#include "nm-setting-wireless.h"
/* Embed the commit id in the build binary */
-static const char *const __nm_git_sha = STRLEN (NM_GIT_SHA) > 0 ? "NM_GIT_SHA:"NM_GIT_SHA : "";
+static const char *const __nm_git_sha = NM_STRLEN (NM_GIT_SHA) > 0 ? "NM_GIT_SHA:"NM_GIT_SHA : "";
/**
* SECTION:nm-utils
diff --git a/libnm-core/tests/test-keyfile.c b/libnm-core/tests/test-keyfile.c
index 99f88ac..d74adb6 100644
--- a/libnm-core/tests/test-keyfile.c
+++ b/libnm-core/tests/test-keyfile.c
@@ -287,7 +287,7 @@ _test_8021x_cert_check_blob_full (NMConnection *con, const void *data, gsize len
_test_8021x_cert_check (con, NM_SETTING_802_1X_CK_SCHEME_BLOB, g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
g_bytes_unref (bytes);
}
-#define _test_8021x_cert_check_blob(con, data) _test_8021x_cert_check_blob_full(con, data, STRLEN (data))
+#define _test_8021x_cert_check_blob(con, data) _test_8021x_cert_check_blob_full(con, data, NM_STRLEN (data))
static void
test_8021x_cert (void)
@@ -352,7 +352,7 @@ test_8021x_cert (void)
_test_8021x_cert_check_blob (con, "\0");
_test_8021x_cert_check_blob (con, "10");
_test_8021x_cert_check_blob (con, "data:;base64,a");
- _test_8021x_cert_check_blob_full (con, "data:;base64,a", STRLEN ("data:;base64,a") + 1);
+ _test_8021x_cert_check_blob_full (con, "data:;base64,a", NM_STRLEN ("data:;base64,a") + 1);
_test_8021x_cert_check_blob (con, "data:;base64,file://a");
_test_8021x_cert_check_blob (con, "123");
diff --git a/libnm-util/nm-setting-8021x.c b/libnm-util/nm-setting-8021x.c
index 30febf9..ace3ffe 100644
--- a/libnm-util/nm-setting-8021x.c
+++ b/libnm-util/nm-setting-8021x.c
@@ -431,16 +431,16 @@ get_cert_scheme (GByteArray *array)
return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
/* interpret the blob as PATH if it starts with "file://". */
- if ( array->len >= STRLEN (SCHEME_PATH)
- && !memcmp (array->data, SCHEME_PATH, STRLEN (SCHEME_PATH))) {
+ if ( array->len >= NM_STRLEN (SCHEME_PATH)
+ && !memcmp (array->data, SCHEME_PATH, NM_STRLEN (SCHEME_PATH))) {
/* But it must also be NUL terminated, contain at least
* one non-NUL character, and contain only one trailing NUL
* chracter.
* And ensure it's UTF-8 valid too so we can pass it through
* D-Bus and stuff like that. */
- if ( array->len > STRLEN (SCHEME_PATH) + 1
+ if ( array->len > NM_STRLEN (SCHEME_PATH) + 1
&& array->data[array->len - 1] == '\0'
- && g_utf8_validate ((const char *) &array->data[STRLEN (SCHEME_PATH)], array->len -
(STRLEN (SCHEME_PATH) + 1), NULL))
+ && g_utf8_validate ((const char *) &array->data[NM_STRLEN (SCHEME_PATH)], array->len -
(NM_STRLEN (SCHEME_PATH) + 1), NULL))
return NM_SETTING_802_1X_CK_SCHEME_PATH;
return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
}
diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c
index 1659a1a..a9a1b0d 100644
--- a/libnm-util/nm-utils.c
+++ b/libnm-util/nm-utils.c
@@ -39,7 +39,7 @@
#include "nm-macros-internal.h"
/* Embed the commit id in the build binary */
-static const char *const __nm_git_sha = STRLEN (NM_GIT_SHA) > 0 ? "NM_GIT_SHA:"NM_GIT_SHA : "";
+static const char *const __nm_git_sha = NM_STRLEN (NM_GIT_SHA) > 0 ? "NM_GIT_SHA:"NM_GIT_SHA : "";
/**
* SECTION:nm-utils
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h
index 2612cff..63f5138 100644
--- a/shared/nm-macros-internal.h
+++ b/shared/nm-macros-internal.h
@@ -107,7 +107,7 @@
/********************************************************/
/* macro to return strlen() of a compile time string. */
-#define STRLEN(str) ( sizeof ("" str) - 1 )
+#define NM_STRLEN(str) ( sizeof ("" str) - 1 )
#define NM_SET_OUT(out_val, value) \
G_STMT_START { \
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index d13158c..b592032 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -1204,8 +1204,8 @@ nm_utils_find_helper(const char *progname, const char *try_first, GError **error
const char **_spec = (pspec); \
gboolean _has = FALSE; \
\
- if (!g_ascii_strncasecmp (*_spec, (""tag), STRLEN (tag))) { \
- *_spec += STRLEN (tag); \
+ if (!g_ascii_strncasecmp (*_spec, (""tag), NM_STRLEN (tag))) { \
+ *_spec += NM_STRLEN (tag); \
_has = TRUE; \
} \
_has; \
@@ -1214,8 +1214,8 @@ nm_utils_find_helper(const char *progname, const char *try_first, GError **error
static const char *
_match_except (const char *spec_str, gboolean *out_except)
{
- if (!g_ascii_strncasecmp (spec_str, EXCEPT_TAG, STRLEN (EXCEPT_TAG))) {
- spec_str += STRLEN (EXCEPT_TAG);
+ if (!g_ascii_strncasecmp (spec_str, EXCEPT_TAG, NM_STRLEN (EXCEPT_TAG))) {
+ spec_str += NM_STRLEN (EXCEPT_TAG);
*out_except = TRUE;
} else
*out_except = FALSE;
@@ -1240,10 +1240,10 @@ nm_match_spec_device_type (const GSList *specs, const char *device_type)
spec_str = _match_except (spec_str, &except);
- if (g_ascii_strncasecmp (spec_str, DEVICE_TYPE_TAG, STRLEN (DEVICE_TYPE_TAG)) != 0)
+ if (g_ascii_strncasecmp (spec_str, DEVICE_TYPE_TAG, NM_STRLEN (DEVICE_TYPE_TAG)) != 0)
continue;
- spec_str += STRLEN (DEVICE_TYPE_TAG);
+ spec_str += NM_STRLEN (DEVICE_TYPE_TAG);
if (strcmp (spec_str, device_type) == 0) {
if (except)
return NM_MATCH_SPEC_NEG_MATCH;
@@ -1270,13 +1270,13 @@ nm_match_spec_hwaddr (const GSList *specs, const char *hwaddr)
spec_str = _match_except (spec_str, &except);
- if ( !g_ascii_strncasecmp (spec_str, INTERFACE_NAME_TAG, STRLEN (INTERFACE_NAME_TAG))
- || !g_ascii_strncasecmp (spec_str, SUBCHAN_TAG, STRLEN (SUBCHAN_TAG))
- || !g_ascii_strncasecmp (spec_str, DEVICE_TYPE_TAG, STRLEN (DEVICE_TYPE_TAG)))
+ if ( !g_ascii_strncasecmp (spec_str, INTERFACE_NAME_TAG, NM_STRLEN (INTERFACE_NAME_TAG))
+ || !g_ascii_strncasecmp (spec_str, SUBCHAN_TAG, NM_STRLEN (SUBCHAN_TAG))
+ || !g_ascii_strncasecmp (spec_str, DEVICE_TYPE_TAG, NM_STRLEN (DEVICE_TYPE_TAG)))
continue;
- if (!g_ascii_strncasecmp (spec_str, MAC_TAG, STRLEN (MAC_TAG)))
- spec_str += STRLEN (MAC_TAG);
+ if (!g_ascii_strncasecmp (spec_str, MAC_TAG, NM_STRLEN (MAC_TAG)))
+ spec_str += NM_STRLEN (MAC_TAG);
else if (except)
continue;
@@ -1307,13 +1307,13 @@ nm_match_spec_interface_name (const GSList *specs, const char *interface_name)
spec_str = _match_except (spec_str, &except);
- if ( !g_ascii_strncasecmp (spec_str, MAC_TAG, STRLEN (MAC_TAG))
- || !g_ascii_strncasecmp (spec_str, SUBCHAN_TAG, STRLEN (SUBCHAN_TAG))
- || !g_ascii_strncasecmp (spec_str, DEVICE_TYPE_TAG, STRLEN (DEVICE_TYPE_TAG)))
+ if ( !g_ascii_strncasecmp (spec_str, MAC_TAG, NM_STRLEN (MAC_TAG))
+ || !g_ascii_strncasecmp (spec_str, SUBCHAN_TAG, NM_STRLEN (SUBCHAN_TAG))
+ || !g_ascii_strncasecmp (spec_str, DEVICE_TYPE_TAG, NM_STRLEN (DEVICE_TYPE_TAG)))
continue;
- if (!g_ascii_strncasecmp (spec_str, INTERFACE_NAME_TAG, STRLEN (INTERFACE_NAME_TAG))) {
- spec_str += STRLEN (INTERFACE_NAME_TAG);
+ if (!g_ascii_strncasecmp (spec_str, INTERFACE_NAME_TAG, NM_STRLEN (INTERFACE_NAME_TAG))) {
+ spec_str += NM_STRLEN (INTERFACE_NAME_TAG);
if (spec_str[0] == '=')
spec_str += 1;
else {
@@ -1425,8 +1425,8 @@ nm_match_spec_s390_subchannels (const GSList *specs, const char *subchannels)
spec_str = _match_except (spec_str, &except);
- if (!g_ascii_strncasecmp (spec_str, SUBCHAN_TAG, STRLEN (SUBCHAN_TAG))) {
- spec_str += STRLEN (SUBCHAN_TAG);
+ if (!g_ascii_strncasecmp (spec_str, SUBCHAN_TAG, NM_STRLEN (SUBCHAN_TAG))) {
+ spec_str += NM_STRLEN (SUBCHAN_TAG);
if (parse_subchannels (spec_str, &spec_a, &spec_b, &spec_c)) {
if (a == spec_a && b == spec_b && c == spec_c) {
if (except)
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index 2c210be..213cd9e 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -746,7 +746,7 @@ maybe_add_option (GHashTable *hash,
}
if (g_str_has_prefix (key, NEW_TAG))
- key += STRLEN (NEW_TAG);
+ key += NM_STRLEN (NEW_TAG);
if (!key[0])
return;
diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.c b/src/dhcp-manager/nm-dhcp-dhclient-utils.c
index 5340d21..05a8a4e 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient-utils.c
+++ b/src/dhcp-manager/nm-dhcp-dhclient-utils.c
@@ -148,9 +148,9 @@ read_client_id (const char *str)
gs_free char *s = NULL;
char *p;
- g_assert (!strncmp (str, CLIENTID_TAG, STRLEN (CLIENTID_TAG)));
+ g_assert (!strncmp (str, CLIENTID_TAG, NM_STRLEN (CLIENTID_TAG)));
- str += STRLEN (CLIENTID_TAG);
+ str += NM_STRLEN (CLIENTID_TAG);
while (g_ascii_isspace (*str))
str++;
@@ -188,7 +188,7 @@ nm_dhcp_dhclient_get_client_id_from_config_file (const char *path)
lines = g_strsplit_set (contents, "\n\r", 0);
for (line = lines; lines && *line; line++) {
- if (!strncmp (*line, CLIENTID_TAG, STRLEN (CLIENTID_TAG)))
+ if (!strncmp (*line, CLIENTID_TAG, NM_STRLEN (CLIENTID_TAG)))
return read_client_id (*line);
}
return NULL;
diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c
index da42466..3a40225 100644
--- a/src/dhcp-manager/nm-dhcp-systemd.c
+++ b/src/dhcp-manager/nm-dhcp-systemd.c
@@ -146,7 +146,7 @@ take_option (GHashTable *options,
for (i = 0; requests[i].name; i++) {
if (requests[i].num == option) {
g_hash_table_insert (options,
- (gpointer) (requests[i].name + STRLEN (REQPREFIX)),
+ (gpointer) (requests[i].name + NM_STRLEN (REQPREFIX)),
value);
break;
}
@@ -362,7 +362,7 @@ lease_to_ip4_config (const char *iface,
r = sd_dhcp_lease_get_vendor_specific (lease, &data, &data_len);
if (r >= 0)
- metered = !!memmem (data, data_len, "ANDROID_METERED", STRLEN ("ANDROID_METERED"));
+ metered = !!memmem (data, data_len, "ANDROID_METERED", NM_STRLEN ("ANDROID_METERED"));
nm_ip4_config_set_metered (ip4_config, metered);
return ip4_config;
diff --git a/src/dhcp-manager/tests/test-dhcp-dhclient.c b/src/dhcp-manager/tests/test-dhcp-dhclient.c
index f9e1e1e..dc8de8a 100644
--- a/src/dhcp-manager/tests/test-dhcp-dhclient.c
+++ b/src/dhcp-manager/tests/test-dhcp-dhclient.c
@@ -295,9 +295,9 @@ static void
test_existing_ascii_client_id (void)
{
gs_unref_bytes GBytes *new_client_id = NULL;
- char buf[STRLEN (EACID) + 1] = { 0 };
+ char buf[NM_STRLEN (EACID) + 1] = { 0 };
- memcpy (buf + 1, EACID, STRLEN (EACID));
+ memcpy (buf + 1, EACID, NM_STRLEN (EACID));
new_client_id = g_bytes_new (buf, sizeof (buf));
test_config (existing_ascii_client_id_orig, existing_ascii_client_id_expected,
FALSE, NULL, NULL,
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index e2b6c3a..f547d18 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -118,7 +118,7 @@ G_DEFINE_TYPE (NMConfigData, nm_config_data, G_TYPE_OBJECT)
#define _HAS_PREFIX(str, prefix) \
({ \
const char *_str = (str); \
- g_str_has_prefix ( _str, ""prefix"") && _str[STRLEN(prefix)] != '\0'; \
+ g_str_has_prefix ( _str, ""prefix"") && _str[NM_STRLEN(prefix)] != '\0'; \
})
/************************************************************************/
@@ -431,7 +431,7 @@ _merge_keyfiles (GKeyFile *keyfile_user, GKeyFile *keyfile_intern)
if ( !is_intern && !is_atomic
&& _HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
- const char *key_base = &key[STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_WAS)];
+ const char *key_base = &key[NM_STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_WAS)];
if (!g_key_file_has_key (keyfile_intern, group, key_base, NULL))
g_key_file_remove_key (keyfile, group, key_base, NULL);
@@ -474,8 +474,8 @@ _nm_config_data_log_sort (const char **pa, const char **pb, gpointer dummy)
if (a_is_connection && b_is_connection) {
/* if both are connection groups, we want the explicit [connection] group first. */
- a_is_connection = a[STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION)] == '\0';
- b_is_connection = b[STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION)] == '\0';
+ a_is_connection = a[NM_STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION)] == '\0';
+ b_is_connection = b[NM_STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION)] == '\0';
if (a_is_connection != b_is_connection) {
if (a_is_connection)
@@ -1127,7 +1127,7 @@ _get_connection_infos (GKeyFile *keyfile)
else if (ngroups > 0) {
for (i = 0, j = 0; i < ngroups; i++) {
if (g_str_has_prefix (groups[i], NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION)) {
- if (groups[i][STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION)] == '\0')
+ if (groups[i][NM_STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION)] == '\0')
connection_tag = groups[i];
else
groups[j++] = groups[i];
diff --git a/src/nm-config.c b/src/nm-config.c
index 15ef886..2eb27a9 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -117,7 +117,7 @@ static void _set_config_data (NMConfig *self, NMConfigData *new_data, int signal
#define _HAS_PREFIX(str, prefix) \
({ \
const char *_str = (str); \
- g_str_has_prefix ( _str, ""prefix"") && _str[STRLEN(prefix)] != '\0'; \
+ g_str_has_prefix ( _str, ""prefix"") && _str[NM_STRLEN(prefix)] != '\0'; \
})
/************************************************************************/
@@ -1188,7 +1188,7 @@ intern_config_read (const char *filename,
continue;
g_key_file_set_value (keyfile_intern, group, key, value_set);
} else if (_HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET)) {
- const char *key_base = &key[STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_SET)];
+ const char *key_base = &key[NM_STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_SET)];
gs_free char *value_was = NULL;
gs_free char *value_conf = NULL;
gs_free char *key_was = g_strdup_printf (NM_CONFIG_KEYFILE_KEYPREFIX_WAS"%s",
key_base);
@@ -1208,7 +1208,7 @@ intern_config_read (const char *filename,
has_intern = TRUE;
g_key_file_set_value (keyfile_intern, group, key_base, value_set);
} else if (_HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
- const char *key_base = &key[STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_WAS)];
+ const char *key_base = &key[NM_STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_WAS)];
gs_free char *key_set = g_strdup_printf (NM_CONFIG_KEYFILE_KEYPREFIX_SET"%s",
key_base);
gs_free char *value_was = NULL;
gs_free char *value_conf = NULL;
@@ -1252,7 +1252,7 @@ out:
needs_rewrite = TRUE;
for (g = 0; groups && groups[g]; g++) {
if ( g_str_has_prefix (groups[g],
NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN)
- && groups[g][STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN)]) {
+ && groups[g][NM_STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN)])
{
g_key_file_remove_group (keyfile_intern, groups[g], NULL);
needs_rewrite = TRUE;
}
@@ -1391,7 +1391,7 @@ intern_config_write (const char *filename,
* Why did this happen?? */
g_warn_if_reached ();
} else if (_HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
- const char *key_base = &key[STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_WAS)];
+ const char *key_base = &key[NM_STRLEN
(NM_CONFIG_KEYFILE_KEYPREFIX_WAS)];
if ( _HAS_PREFIX (key_base, NM_CONFIG_KEYFILE_KEYPREFIX_SET)
|| _HAS_PREFIX (key_base, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
diff --git a/src/nm-dispatcher.c b/src/nm-dispatcher.c
index dad4852..c226ce7 100644
--- a/src/nm-dispatcher.c
+++ b/src/nm-dispatcher.c
@@ -58,7 +58,7 @@ enum {
};
static Monitor monitors[3] = {
-#define MONITORS_INIT_SET(INDEX, USE, SCRIPT_DIR) [INDEX] = { .dir_len = STRLEN (SCRIPT_DIR), .dir =
SCRIPT_DIR, .description = ("" USE), .has_scripts = TRUE }
+#define MONITORS_INIT_SET(INDEX, USE, SCRIPT_DIR) [INDEX] = { .dir_len = NM_STRLEN (SCRIPT_DIR), .dir =
SCRIPT_DIR, .description = ("" USE), .has_scripts = TRUE }
MONITORS_INIT_SET (MONITOR_INDEX_DEFAULT, "default", NMD_SCRIPT_DIR_DEFAULT),
MONITORS_INIT_SET (MONITOR_INDEX_PRE_UP, "pre-up", NMD_SCRIPT_DIR_PRE_UP),
MONITORS_INIT_SET (MONITOR_INDEX_PRE_DOWN, "pre-down", NMD_SCRIPT_DIR_PRE_DOWN),
diff --git a/src/nm-logging.c b/src/nm-logging.c
index 159d83f..9d156db 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -455,7 +455,7 @@ _iovec_set_string (struct iovec *iov, gboolean *iov_free, int i, const char *str
iov[i].iov_len = len;
iov_free[i] = FALSE;
}
-#define _iovec_set_literal_string(iov, iov_free, i, str) _iovec_set_string ((iov), (iov_free), (i),
(""str""), STRLEN (str))
+#define _iovec_set_literal_string(iov, iov_free, i, str) _iovec_set_string ((iov), (iov_free), (i),
(""str""), NM_STRLEN (str))
#endif
void
diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c
index 5af0b91..a9d6f0c 100644
--- a/src/nm-route-manager.c
+++ b/src/nm-route-manager.c
@@ -134,7 +134,7 @@ static const VTableIP vtable_v4, vtable_v6;
if ((self) != singleton_instance) \
g_snprintf (__prefix, sizeof (__prefix), "%s%c[%p]", _NMLOG_PREFIX_NAME, __ch, (self)); \
else \
- __prefix[STRLEN (_NMLOG_PREFIX_NAME)] = __ch; \
+ __prefix[NM_STRLEN (_NMLOG_PREFIX_NAME)] = __ch; \
_nm_log ((level), (__domain), 0, \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
__prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 7d0ca9c..1ea6783 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -636,8 +636,8 @@ _linktype_read_devtype (const char *sysfs_path)
end = strpbrk (cont, "\r\n");
if (end)
*end++ = '\0';
- if (strncmp (cont, DEVTYPE_PREFIX, STRLEN (DEVTYPE_PREFIX)) == 0) {
- cont += STRLEN (DEVTYPE_PREFIX);
+ if (strncmp (cont, DEVTYPE_PREFIX, NM_STRLEN (DEVTYPE_PREFIX)) == 0) {
+ cont += NM_STRLEN (DEVTYPE_PREFIX);
memmove (contents, cont, strlen (cont) + 1);
return contents;
}
diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
index b0b0b56..8a1bca1 100644
--- a/src/platform/nm-platform-utils.c
+++ b/src/platform/nm-platform-utils.c
@@ -503,13 +503,13 @@ gboolean
nmp_utils_device_exists (const char *name)
{
#define SYS_CLASS_NET "/sys/class/net/"
- char sysdir[STRLEN (SYS_CLASS_NET) + IFNAMSIZ] = SYS_CLASS_NET;
+ char sysdir[NM_STRLEN (SYS_CLASS_NET) + IFNAMSIZ] = SYS_CLASS_NET;
if ( !name
|| strlen (name) >= IFNAMSIZ
|| !nm_utils_is_valid_path_component (name))
g_return_val_if_reached (FALSE);
- strcpy (&sysdir[STRLEN (SYS_CLASS_NET)], name);
+ strcpy (&sysdir[NM_STRLEN (SYS_CLASS_NET)], name);
return g_file_test (sysdir, G_FILE_TEST_EXISTS);
}
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 59c655b..123086e 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -3490,11 +3490,11 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *bu
_to_string_dev (NULL, address->ifindex, str_dev, sizeof (str_dev));
- nm_platform_addr_flags2str (address->flags, &s_flags[STRLEN (S_FLAGS_PREFIX)], sizeof (s_flags) -
STRLEN (S_FLAGS_PREFIX));
- if (s_flags[STRLEN (S_FLAGS_PREFIX)] == '\0')
+ nm_platform_addr_flags2str (address->flags, &s_flags[NM_STRLEN (S_FLAGS_PREFIX)], sizeof (s_flags) -
NM_STRLEN (S_FLAGS_PREFIX));
+ if (s_flags[NM_STRLEN (S_FLAGS_PREFIX)] == '\0')
s_flags[0] = '\0';
else
- memcpy (s_flags, S_FLAGS_PREFIX, STRLEN (S_FLAGS_PREFIX));
+ memcpy (s_flags, S_FLAGS_PREFIX, NM_STRLEN (S_FLAGS_PREFIX));
str_lft_p = _lifetime_to_string (address->timestamp,
address->lifetime ? address->lifetime :
NM_PLATFORM_LIFETIME_PERMANENT,
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index 80c7d23..49697f7 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -489,7 +489,7 @@ read_hostname_gentoo (const char *path)
if (all_lines[i][0] == '#' || all_lines[i][0] == '\0')
continue;
if (g_str_has_prefix (all_lines[i], "hostname=")) {
- tmp = &all_lines[i][STRLEN ("hostname=")];
+ tmp = &all_lines[i][NM_STRLEN ("hostname=")];
result = g_shell_unquote (tmp, NULL);
break;
}
@@ -516,7 +516,7 @@ hostname_is_dynamic (void)
if (str) {
g_strstrip (str);
if (g_str_has_prefix (str, "DHCLIENT_SET_HOSTNAME="))
- dynamic = strcmp (&str[STRLEN ("DHCLIENT_SET_HOSTNAME=")], "\"yes\"") == 0;
+ dynamic = strcmp (&str[NM_STRLEN ("DHCLIENT_SET_HOSTNAME=")], "\"yes\"") == 0;
g_free (str);
}
}
diff --git a/src/settings/plugins/ibft/reader.c b/src/settings/plugins/ibft/reader.c
index 195c264..bd21a57 100644
--- a/src/settings/plugins/ibft/reader.c
+++ b/src/settings/plugins/ibft/reader.c
@@ -138,14 +138,14 @@ read_ibft_blocks (const char *iscsiadm_path,
if (!*iter[0])
continue;
- if (!g_ascii_strncasecmp (*iter, TAG_BEGIN, STRLEN (TAG_BEGIN))) {
+ if (!g_ascii_strncasecmp (*iter, TAG_BEGIN, NM_STRLEN (TAG_BEGIN))) {
if (block_lines) {
PARSE_WARNING ("malformed iscsiadm record: missing END RECORD.");
g_ptr_array_unref (block_lines);
}
/* Start new record */
block_lines = g_ptr_array_new_full (15, g_free);
- } else if (!g_ascii_strncasecmp (*iter, TAG_END, STRLEN (TAG_END))) {
+ } else if (!g_ascii_strncasecmp (*iter, TAG_END, NM_STRLEN (TAG_END))) {
if (block_lines) {
if (block_lines->len)
blocks = g_slist_prepend (blocks, block_lines);
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index 1da55c5..7596ba2 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -2819,7 +2819,7 @@ eap_ttls_reader (const char *eap_method,
|| !strcmp (*iter, "eap-gtc")) {
if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error))
goto done;
- g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, (*iter + STRLEN ("eap-")),
NULL);
+ g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, (*iter + NM_STRLEN
("eap-")), NULL);
} else {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c
index 599e3a4..8692c61 100644
--- a/src/settings/plugins/ifcfg-rh/utils.c
+++ b/src/settings/plugins/ifcfg-rh/utils.c
@@ -214,8 +214,8 @@ utils_get_ifcfg_name (const char *file, gboolean only_ifcfg)
#define MATCH_TAG_AND_RETURN(name, TAG) \
G_STMT_START { \
- if (strncmp (name, TAG, STRLEN (TAG)) == 0) { \
- name += STRLEN (TAG); \
+ if (strncmp (name, TAG, NM_STRLEN (TAG)) == 0) { \
+ name += NM_STRLEN (TAG); \
if (name[0] == '\0') \
return NULL; \
else \
@@ -436,8 +436,8 @@ utils_detect_ifcfg_path (const char *path, gboolean only_ifcfg)
base = g_path_get_basename (path);
- if (strncmp (base, IFCFG_TAG, STRLEN (IFCFG_TAG)) == 0) {
- if (base[STRLEN (IFCFG_TAG)] == '\0')
+ if (strncmp (base, IFCFG_TAG, NM_STRLEN (IFCFG_TAG)) == 0) {
+ if (base[NM_STRLEN (IFCFG_TAG)] == '\0')
return NULL;
if (utils_is_ifcfg_alias_file (base, NULL)) {
ifcfg = g_strdup (path);
diff --git a/src/settings/plugins/ifnet/net_utils.c b/src/settings/plugins/ifnet/net_utils.c
index 1c72e0b..e61c652 100644
--- a/src/settings/plugins/ifnet/net_utils.c
+++ b/src/settings/plugins/ifnet/net_utils.c
@@ -712,7 +712,7 @@ _has_prefix_impl (char *str, const char *prefix, gsize prefix_len)
} while (g_ascii_isspace (str[0]));
return str;
}
-#define _has_prefix(STR, PREFIX) _has_prefix_impl (STR, PREFIX, STRLEN (PREFIX))
+#define _has_prefix(STR, PREFIX) _has_prefix_impl (STR, PREFIX, NM_STRLEN (PREFIX))
void
get_dhcp_hostname_and_client_id (char **hostname, char **client_id)
diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c
b/src/settings/plugins/keyfile/tests/test-keyfile.c
index f03e922..d7b0ecc 100644
--- a/src/settings/plugins/keyfile/tests/test-keyfile.c
+++ b/src/settings/plugins/keyfile/tests/test-keyfile.c
@@ -1931,7 +1931,7 @@ test_write_wired_8021x_tls_connection_blob (void)
s_8021x = nm_connection_get_setting_802_1x (connection);
g_assert (s_8021x);
- password_raw = g_bytes_new (PASSWORD_RAW, STRLEN (PASSWORD_RAW));
+ password_raw = g_bytes_new (PASSWORD_RAW, NM_STRLEN (PASSWORD_RAW));
g_object_set (s_8021x,
NM_SETTING_802_1X_PASSWORD_RAW,
password_raw,
@@ -1982,8 +1982,8 @@ test_write_wired_8021x_tls_connection_blob (void)
password_raw = nm_setting_802_1x_get_password_raw (s_8021x);
g_assert (password_raw);
- g_assert (g_bytes_get_size (password_raw) == STRLEN (PASSWORD_RAW));
- g_assert (!memcmp (g_bytes_get_data (password_raw, NULL), PASSWORD_RAW, STRLEN (PASSWORD_RAW)));
+ g_assert (g_bytes_get_size (password_raw) == NM_STRLEN (PASSWORD_RAW));
+ g_assert (!memcmp (g_bytes_get_data (password_raw, NULL), PASSWORD_RAW, NM_STRLEN (PASSWORD_RAW)));
unlink (testfile);
g_free (testfile);
diff --git a/src/tests/test-general.c b/src/tests/test-general.c
index 4d97994..ffbeae1 100644
--- a/src/tests/test-general.c
+++ b/src/tests/test-general.c
@@ -1121,8 +1121,8 @@ test_nm_utils_strbuf_append (void)
#define STR_ORIG "abcdefghijklmnopqrstuvwxyz"
int buf_len;
int rep;
- char buf[STRLEN (BUF_ORIG) + 1];
- char str[STRLEN (BUF_ORIG) + 1];
+ char buf[NM_STRLEN (BUF_ORIG) + 1];
+ char str[NM_STRLEN (BUF_ORIG) + 1];
for (buf_len = 0; buf_len < 10; buf_len++) {
for (rep = 0; rep < 50; rep++) {
--
2.5.0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]