diff options
Diffstat (limited to 'src/libnm-glib-aux')
| -rw-r--r-- | src/libnm-glib-aux/README.md | 16 | ||||
| -rw-r--r-- | src/libnm-glib-aux/nm-macros-internal.h | 6 | ||||
| -rw-r--r-- | src/libnm-glib-aux/nm-uuid.c | 9 |
3 files changed, 23 insertions, 8 deletions
diff --git a/src/libnm-glib-aux/README.md b/src/libnm-glib-aux/README.md new file mode 100644 index 00000000..cb43e87c --- /dev/null +++ b/src/libnm-glib-aux/README.md @@ -0,0 +1,16 @@ +libnm-glib-aux +============== + +A static helper library with general purpose helpers on top +of glib. + +This is similar to libnm-std-aux (on which this library depends). +The difference is that libnm-std-aux only requires standard C (C11), +while this has a dependency on glib. + +As this has no additional dependencies, we should have all our glib code +use this internal helper library. It contains helpers that should be +available (and used) in all our C/glib applications/libraries. + +Parts of this library are usually already included via the `nm-default*.h` +headers. diff --git a/src/libnm-glib-aux/nm-macros-internal.h b/src/libnm-glib-aux/nm-macros-internal.h index 1c8c85e6..0b39271e 100644 --- a/src/libnm-glib-aux/nm-macros-internal.h +++ b/src/libnm-glib-aux/nm-macros-internal.h @@ -964,8 +964,8 @@ nm_g_variant_equal(GVariant *a, GVariant *b) /* check if @flags has exactly one flag (@check) set. You should call this * only with @check being a compile time constant and a power of two. */ -#define NM_FLAGS_HAS(flags, check) \ - (G_STATIC_ASSERT_EXPR((check) > 0 && ((check) & ((check) -1)) == 0), \ +#define NM_FLAGS_HAS(flags, check) \ + (G_STATIC_ASSERT_EXPR((check) > 0 && ((check) & ((check) - 1)) == 0), \ NM_FLAGS_ANY((flags), (check))) #define NM_FLAGS_ANY(flags, check) (((flags) & (check)) != 0) @@ -1695,7 +1695,7 @@ nm_decode_version(guint version, guint *major, guint *minor, guint *micro) /*****************************************************************************/ -#define NM_PID_T_INVAL ((pid_t) -1) +#define NM_PID_T_INVAL ((pid_t) - 1) /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-uuid.c b/src/libnm-glib-aux/nm-uuid.c index df1b10c0..e39d2ea5 100644 --- a/src/libnm-glib-aux/nm-uuid.c +++ b/src/libnm-glib-aux/nm-uuid.c @@ -415,8 +415,7 @@ nm_uuid_generate_from_string_str(const char *s, * case the result is different from an empty array. * @len: if negative, @strv is a NULL terminated array. Otherwise, * it is the length of the strv array. In the latter case it may - * also contain NULL strings. The result hashes differently depending - * on whether we have a NULL terminated strv array or given length. + * also contain NULL strings. * * Returns a @uuid_type UUID based on the concatenated C strings. * It does not simply concatenate them, but also includes the @@ -436,7 +435,7 @@ nm_uuid_generate_from_strings_strv(NMUuidType uuid_type, gsize slen; const char *s; - if (len >= 0) { + if (len > 0) { gboolean has_nulls = FALSE; gssize i; @@ -471,14 +470,14 @@ nm_uuid_generate_from_strings_strv(NMUuidType uuid_type, * in the other cases). */ slen = 1; s = "x"; - } else if (!strv[0]) { + } else if (!strv[0] || len == 0) { slen = 0; s = ""; } else if (!strv[1]) { slen = strlen(strv[0]) + 1u; s = strv[0]; } else { - /* We concatenate the NUL termiated string, including the NUL + /* We concatenate the NUL terminated string, including the NUL * character. This way, ("a","a"), ("aa"), ("aa","") all hash * differently. */ for (; strv[0]; strv++) |