diff options
Diffstat (limited to 'shared')
37 files changed, 744 insertions, 744 deletions
diff --git a/shared/nm-glib-aux/nm-dbus-aux.h b/shared/nm-glib-aux/nm-dbus-aux.h index b6436855cc..65d497579a 100644 --- a/shared/nm-glib-aux/nm-dbus-aux.h +++ b/shared/nm-glib-aux/nm-dbus-aux.h @@ -97,10 +97,10 @@ nm_dbus_connection_signal_subscribe_properties_changed(GDBusConnection * dbus_ nm_assert(bus_name); /* it seems that using a non-unique name causes problems that we get signals - * also from unrelated senders. Usually, you are anyway monitoring the name-owner, - * so you should have the unique name at hand. - * - * If not, investigate this, ensure that it works, and lift this restriction. */ + * also from unrelated senders. Usually, you are anyway monitoring the name-owner, + * so you should have the unique name at hand. + * + * If not, investigate this, ensure that it works, and lift this restriction. */ nm_assert(g_dbus_is_unique_name(bus_name)); return g_dbus_connection_signal_subscribe(dbus_connection, diff --git a/shared/nm-glib-aux/nm-dedup-multi.c b/shared/nm-glib-aux/nm-dedup-multi.c index 774213f499..b750417921 100644 --- a/shared/nm-glib-aux/nm-dedup-multi.c +++ b/shared/nm-glib-aux/nm-dedup-multi.c @@ -14,12 +14,12 @@ typedef struct { /* the stack-allocated lookup entry. It has a compatible - * memory layout with NMDedupMultiEntry and NMDedupMultiHeadEntry. - * - * It is recognizable by having lst_entries_sentinel.next set to NULL. - * Contrary to the other entries, which have lst_entries.next - * always non-NULL. - * */ + * memory layout with NMDedupMultiEntry and NMDedupMultiHeadEntry. + * + * It is recognizable by having lst_entries_sentinel.next set to NULL. + * Contrary to the other entries, which have lst_entries.next + * always non-NULL. + * */ CList lst_entries_sentinel; const NMDedupMultiObj * obj; const NMDedupMultiIdxType *idx_type; @@ -150,8 +150,8 @@ _entry_unpack(const NMDedupMultiEntry * entry, ASSERT_idx_type(*out_idx_type); /* for lookup of the head, we allow to omit object, but only - * if the idx_type does not partition the objects. Otherwise, we - * require a obj to compare. */ + * if the idx_type does not partition the objects. Otherwise, we + * require a obj to compare. */ nm_assert(!*out_lookup_head || (*out_obj || !(*out_idx_type)->klass->idx_obj_partition_equal)); /* lookup of the object requires always an object. */ @@ -602,8 +602,8 @@ nm_dedup_multi_index_remove_obj(NMDedupMultiIndex * sel } /* since we are about to remove the object, we obviously pass - * a reference to @out_obj, the caller MUST unref the object, - * if he chooses to provide @out_obj. */ + * a reference to @out_obj, the caller MUST unref the object, + * if he chooses to provide @out_obj. */ NM_SET_OUT(out_obj, nm_dedup_multi_obj_ref(entry->obj)); _remove_entry(self, (NMDedupMultiEntry *) entry, NULL); @@ -844,7 +844,7 @@ again: if (--(((NMDedupMultiObj *) obj)->_ref_count) <= 0) { if (obj->_multi_idx) { /* restore the ref-count to 1 and release the object first - * from the index. Then, retry again to unref. */ + * from the index. Then, retry again to unref. */ ((NMDedupMultiObj *) obj)->_ref_count++; nm_dedup_multi_index_obj_release(obj->_multi_idx, obj); nm_assert(obj->_ref_count == 1); diff --git a/shared/nm-glib-aux/nm-dedup-multi.h b/shared/nm-glib-aux/nm-dedup-multi.h index bb2101d32e..fea5049195 100644 --- a/shared/nm-glib-aux/nm-dedup-multi.h +++ b/shared/nm-glib-aux/nm-dedup-multi.h @@ -27,11 +27,11 @@ typedef enum _NMDedupMultiIdxMode { NM_DEDUP_MULTI_IDX_MODE_PREPEND_FORCE, /* append new objects to the end of the list. - * If the object is already in the cache, don't move it. */ + * If the object is already in the cache, don't move it. */ NM_DEDUP_MULTI_IDX_MODE_APPEND, /* like NM_DEDUP_MULTI_IDX_MODE_APPEND, but if the object - * is already in the cache, move it to the end. */ + * is already in the cache, move it to the end. */ NM_DEDUP_MULTI_IDX_MODE_APPEND_FORCE, } NMDedupMultiIdxMode; @@ -56,7 +56,7 @@ struct _NMDedupMultiObjClass { void (*obj_destroy)(NMDedupMultiObj *obj); /* the NMDedupMultiObj can be deduplicated. For that the obj_full_hash_update() - * and obj_full_equal() compare *all* fields of the object, even minor ones. */ + * and obj_full_equal() compare *all* fields of the object, even minor ones. */ void (*obj_full_hash_update)(const NMDedupMultiObj *obj, struct _NMHashState *h); gboolean (*obj_full_equal)(const NMDedupMultiObj *obj_a, const NMDedupMultiObj *obj_b); }; @@ -67,9 +67,9 @@ static inline const NMDedupMultiObj * nm_dedup_multi_obj_ref(const NMDedupMultiObj *obj) { /* ref and unref accept const pointers. Objects is supposed to be shared - * and kept immutable. Disallowing to take/return a reference to a const - * NMPObject is cumbersome, because callers are precisely expected to - * keep a ref on the otherwise immutable object. */ + * and kept immutable. Disallowing to take/return a reference to a const + * NMPObject is cumbersome, because callers are precisely expected to + * keep a ref on the otherwise immutable object. */ nm_assert(obj); nm_assert(obj->_ref_count != NM_OBJ_REF_COUNT_STACKINIT); @@ -146,12 +146,12 @@ struct _NMDedupMultiIdxTypeClass { const NMDedupMultiObj * obj_b); /* an NMDedupMultiIdxTypeClass which implements partitioning of the - * tracked objects, must implement the idx_obj_partition*() functions. - * - * idx_obj_partitionable() may return NULL if the object cannot be tracked. - * For example, a index for routes by ifindex, may not want to track any - * routes that don't have a valid ifindex. If the idx-type says that the - * object is not partitionable, it is never added to the NMDedupMultiIndex. */ + * tracked objects, must implement the idx_obj_partition*() functions. + * + * idx_obj_partitionable() may return NULL if the object cannot be tracked. + * For example, a index for routes by ifindex, may not want to track any + * routes that don't have a valid ifindex. If the idx-type says that the + * object is not partitionable, it is never added to the NMDedupMultiIndex. */ gboolean (*idx_obj_partitionable)(const NMDedupMultiIdxType *idx_type, const NMDedupMultiObj * obj); void (*idx_obj_partition_hash_update)(const NMDedupMultiIdxType *idx_type, @@ -189,7 +189,7 @@ nm_dedup_multi_idx_type_partition_equal(const NMDedupMultiIdxType * struct _NMDedupMultiEntry { /* this is the list of all entries that share the same head entry. - * All entries compare equal according to idx_obj_partition_equal(). */ + * All entries compare equal according to idx_obj_partition_equal(). */ CList lst_entries; /* const NMDedupMultiObj * */ gconstpointer obj; @@ -202,7 +202,7 @@ struct _NMDedupMultiEntry { struct _NMDedupMultiHeadEntry { /* this is the list of all entries that share the same head entry. - * All entries compare equal according to idx_obj_partition_equal(). */ + * All entries compare equal according to idx_obj_partition_equal(). */ CList lst_entries_head; const NMDedupMultiIdxType *idx_type; @@ -220,7 +220,7 @@ static inline gconstpointer nm_dedup_multi_entry_get_obj(const NMDedupMultiEntry *entry) { /* convenience method that allows to skip the %NULL check on - * @entry. Think of the NULL-conditional operator ?. of C# */ + * @entry. Think of the NULL-conditional operator ?. of C# */ return entry ? entry->obj : NULL; } @@ -230,10 +230,10 @@ static inline void nm_dedup_multi_entry_set_dirty(const NMDedupMultiEntry *entry, gboolean dirty) { /* NMDedupMultiEntry is always exposed as a const object, because it is not - * supposed to be modified outside NMDedupMultiIndex API. Except the "dirty" - * flag. In C++ speak, it is a mutable field. - * - * Add this inline function, to cast-away constness and set the dirty flag. */ + * supposed to be modified outside NMDedupMultiIndex API. Except the "dirty" + * flag. In C++ speak, it is a mutable field. + * + * Add this inline function, to cast-away constness and set the dirty flag. */ nm_assert(entry); ((NMDedupMultiEntry *) entry)->dirty = dirty; } @@ -338,7 +338,7 @@ nm_dedup_multi_iter_next(NMDedupMultiIter *iter) return FALSE; /* we always look ahead for the next. This way, the user - * may delete the current entry (but no other entries). */ + * may delete the current entry (but no other entries). */ iter->current = c_list_entry(iter->_next, NMDedupMultiEntry, lst_entries); if (iter->_next->next == iter->_head) iter->_next = NULL; @@ -392,8 +392,8 @@ nm_dedup_multi_head_entry_sort(const NMDedupMultiHeadEntry *head_entry, { if (head_entry) { /* the head entry can be sorted directly without messing up the - * index to which it belongs. Of course, this does mess up any - * NMDedupMultiIter instances. */ + * index to which it belongs. Of course, this does mess up any + * NMDedupMultiIter instances. */ c_list_sort((CList *) &head_entry->lst_entries_head, cmp, user_data); } } diff --git a/shared/nm-glib-aux/nm-enum-utils.c b/shared/nm-glib-aux/nm-enum-utils.c index 95596af06a..34430ae688 100644 --- a/shared/nm-glib-aux/nm-enum-utils.c +++ b/shared/nm-glib-aux/nm-enum-utils.c @@ -41,25 +41,25 @@ _ASSERT_enum_values_info(GType type, const NMUtilsEnumValueInfo *value_infos) enum_value = g_enum_get_value_by_nick(G_ENUM_CLASS(klass), value_infos->nick); if (enum_value) { /* we do allow specifying the same name via @value_infos and @type. - * That might make sense, if @type comes from a library where older versions - * of the library don't yet support the value. In this case, the caller can - * provide the nick via @value_infos, to support the older library version. - * And then, when actually running against a newer library version where - * @type knows the nick, we have this situation. - * - * Another reason for specifying a nick both in @value_infos and @type, - * is to specify an alias which is not used with highest preference. For - * example, if you add an alias "disabled" for "none" (both numerically - * equal), then the first alias in @value_infos will be preferred over - * the name from @type. So, to still use "none" as preferred name, you may - * explicitly specify the "none" alias in @value_infos before "disabled". - * - * However, what never is allowed, is to use a name (nick) to re-number - * the value. That is, if both @value_infos and @type contain a particular - * nick, their numeric values must agree as well. - * Allowing this, would be very confusing, because the name would have a different - * value from the regular GLib GEnum API. - */ + * That might make sense, if @type comes from a library where older versions + * of the library don't yet support the value. In this case, the caller can + * provide the nick via @value_infos, to support the older library version. + * And then, when actually running against a newer library version where + * @type knows the nick, we have this situation. + * + * Another reason for specifying a nick both in @value_infos and @type, + * is to specify an alias which is not used with highest preference. For + * example, if you add an alias "disabled" for "none" (both numerically + * equal), then the first alias in @value_infos will be preferred over + * the name from @type. So, to still use "none" as preferred name, you may + * explicitly specify the "none" alias in @value_infos before "disabled". + * + * However, what never is allowed, is to use a name (nick) to re-number + * the value. That is, if both @value_infos and @type contain a particular + * nick, their numeric values must agree as well. + * Allowing this, would be very confusing, because the name would have a different + * value from the regular GLib GEnum API. + */ g_assert(enum_value->value == value_infos->value); } } else { diff --git a/shared/nm-glib-aux/nm-enum-utils.h b/shared/nm-glib-aux/nm-enum-utils.h index 403c01fb0e..82e3e48367 100644 --- a/shared/nm-glib-aux/nm-enum-utils.h +++ b/shared/nm-glib-aux/nm-enum-utils.h @@ -10,7 +10,7 @@ typedef struct _NMUtilsEnumValueInfo { /* currently, this is only used for _nm_utils_enum_from_str_full() to - * declare additional aliases for values. */ + * declare additional aliases for values. */ const char *nick; int value; } NMUtilsEnumValueInfo; diff --git a/shared/nm-glib-aux/nm-errno.c b/shared/nm-glib-aux/nm-errno.c index d4ebb866f1..fa9c50db77 100644 --- a/shared/nm-glib-aux/nm-errno.c +++ b/shared/nm-glib-aux/nm-errno.c @@ -170,8 +170,8 @@ nm_strerror_native(int errsv) if (pthread_key_create(&key, g_free) != 0 || pthread_setspecific(key, buf) != 0) { /* Failure. We will leak the buffer when the thread exits. - * - * Nothing we can do about it really. For Debug builds we fail with an assertion. */ + * + * Nothing we can do about it really. For Debug builds we fail with an assertion. */ nm_assert_not_reached(); } errno = errno_saved; diff --git a/shared/nm-glib-aux/nm-errno.h b/shared/nm-glib-aux/nm-errno.h index a8a6385077..ca791c5e93 100644 --- a/shared/nm-glib-aux/nm-errno.h +++ b/shared/nm-glib-aux/nm-errno.h @@ -16,25 +16,25 @@ enum _NMErrno { _NM_ERRNO_RESERVED_FIRST = 100000, /* when we cannot represent a number as positive number, we resort to this - * number. Basically, the values G_MININT, -NME_ERRNO_SUCCESS, NME_ERRNO_SUCCESS - * and G_MAXINT all map to the same value. */ + * number. Basically, the values G_MININT, -NME_ERRNO_SUCCESS, NME_ERRNO_SUCCESS + * and G_MAXINT all map to the same value. */ NME_ERRNO_OUT_OF_RANGE = G_MAXINT, /* Indicate that the original errno was zero. Zero denotes *no error*, but we know something - * went wrong and we want to report some error. This is a placeholder to mean, something - * was wrong, but errno was zero. */ + * went wrong and we want to report some error. This is a placeholder to mean, something + * was wrong, but errno was zero. */ NME_ERRNO_SUCCESS = G_MAXINT - 1, /* an unspecified error. */ NME_UNSPEC = _NM_ERRNO_RESERVED_FIRST, /* A bug, for example when an assertion failed. - * Should never happen. */ + * Should never happen. */ NME_BUG, /* a native error number (from <errno.h>) cannot be mapped as - * an nm-error, because it is in the range [_NM_ERRNO_RESERVED_FIRST, - * _NM_ERRNO_RESERVED_LAST]. */ + * an nm-error, because it is in the range [_NM_ERRNO_RESERVED_FIRST, + * _NM_ERRNO_RESERVED_LAST]. */ NME_NATIVE_ERRNO, /* netlink errors. */ diff --git a/shared/nm-glib-aux/nm-glib.h b/shared/nm-glib-aux/nm-glib.h index 70c3d77af7..5290bf93bc 100644 --- a/shared/nm-glib-aux/nm-glib.h +++ b/shared/nm-glib-aux/nm-glib.h @@ -225,7 +225,7 @@ static inline gboolean nm_g_hash_table_replace(GHashTable *hash, gpointer key, gpointer value) { /* glib 2.40 added a return value indicating whether the key already existed - * (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */ + * (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */ #if GLIB_CHECK_VERSION(2, 40, 0) return g_hash_table_replace(hash, key, value); #else @@ -240,7 +240,7 @@ static inline gboolean nm_g_hash_table_insert(GHashTable *hash, gpointer key, gpointer value) { /* glib 2.40 added a return value indicating whether the key already existed - * (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */ + * (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */ #if GLIB_CHECK_VERSION(2, 40, 0) return g_hash_table_insert(hash, key, value); #else @@ -255,7 +255,7 @@ static inline gboolean nm_g_hash_table_add(GHashTable *hash, gpointer key) { /* glib 2.40 added a return value indicating whether the key already existed - * (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */ + * (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */ #if GLIB_CHECK_VERSION(2, 40, 0) return g_hash_table_add(hash, key); #else @@ -639,7 +639,7 @@ g_hash_table_steal_extended(GHashTable * hash_table, gpointer *_stolen_value = (stolen_value); \ \ /* we cannot allow NULL arguments, because then we would leak the values in - * the compat implementation. */ \ + * the compat implementation. */ \ g_assert(_stolen_key); \ g_assert(_stolen_value); \ \ diff --git a/shared/nm-glib-aux/nm-hash-utils.c b/shared/nm-glib-aux/nm-hash-utils.c index 87ec164d2b..c2df5a88a5 100644 --- a/shared/nm-glib-aux/nm-hash-utils.c +++ b/shared/nm-glib-aux/nm-hash-utils.c @@ -25,7 +25,7 @@ static const guint8 * _get_hash_key_init(void) { /* the returned hash is aligned to guin64, hence, it is safe - * to use it as guint* or guint64* pointer. */ + * to use it as guint* or guint64* pointer. */ static union { guint8 v8[HASH_KEY_SIZE]; guint _align_as_uint; @@ -48,14 +48,14 @@ again: nm_utils_random_bytes(&t_arr, sizeof(t_arr)); /* We only initialize one random hash key. So we can spend some effort - * of getting this right. For one, we collect more random bytes than - * necessary. - * - * Then, the first guint of the seed should have all the entropy that we could - * obtain in sizeof(t_arr). For that, siphash(t_arr) and xor the first guint - * with hash. - * The first guint is especially interesting for nm_hash_static() below that - * doesn't use siphash itself. */ + * of getting this right. For one, we collect more random bytes than + * necessary. + * + * Then, the first guint of the seed should have all the entropy that we could + * obtain in sizeof(t_arr). For that, siphash(t_arr) and xor the first guint + * with hash. + * The first guint is especially interesting for nm_hash_static() below that + * doesn't use siphash itself. */ h = c_siphash_hash(t_arr.v8, (const guint8 *) &t_arr, sizeof(t_arr)); if (sizeof(h) > sizeof(guint)) t_arr.vuint = t_arr.vuint ^ ((guint)(h & G_MAXUINT)) ^ ((guint)(h >> 32)); @@ -91,21 +91,21 @@ guint nm_hash_static(guint static_seed) { /* Note that we only xor the static_seed with the first guint of the key. - * - * We don't use siphash, which would mix the bits better with _get_hash_key(). - * Note that nm_hash_static() isn't used to hash the static_seed. Instead, it - * is used to get a unique hash value in a static context. That means, every - * caller is responsible to choose a static_seed that is sufficiently - * distinct from all other callers. In other words, static_seed should be a - * unique constant with good entropy. - * - * Note that _get_hash_key_init() already xored the first guint of the - * key with the siphash of the entire static key. That means, even if - * we got bad randomness for the first guint, the first guint is also - * mixed with the randomness of the entire random key. - * - * Also, ensure that we don't return zero (like for nm_hash_complete()). - */ + * + * We don't use siphash, which would mix the bits better with _get_hash_key(). + * Note that nm_hash_static() isn't used to hash the static_seed. Instead, it + * is used to get a unique hash value in a static context. That means, every + * caller is responsible to choose a static_seed that is sufficiently + * distinct from all other callers. In other words, static_seed should be a + * unique constant with good entropy. + * + * Note that _get_hash_key_init() already xored the first guint of the + * key with the siphash of the entire static key. That means, even if + * we got bad randomness for the first guint, the first guint is also + * mixed with the randomness of the entire random key. + * + * Also, ensure that we don't return zero (like for nm_hash_complete()). + */ return ((*((const guint *) _get_hash_key())) ^ static_seed) ?: 3679500967u; } diff --git a/shared/nm-glib-aux/nm-hash-utils.h b/shared/nm-glib-aux/nm-hash-utils.h index ff529d224c..543389975a 100644 --- a/shared/nm-glib-aux/nm-hash-utils.h +++ b/shared/nm-glib-aux/nm-hash-utils.h @@ -67,14 +67,14 @@ nm_hash_complete_u64(NMHashState *state) nm_assert(state); /* this returns the native u64 hash value. Note that this differs - * from nm_hash_complete() in two ways: - * - * - the type, guint64 vs. guint. - * - nm_hash_complete() never returns zero. - * - * In practice, nm_hash*() API is implemented via siphash24, so this returns - * the siphash24 value. But that is not guaranteed by the API, and if you need - * siphash24 directly, use c_siphash_*() and nm_hash_siphash42*() API. */ + * from nm_hash_complete() in two ways: + * + * - the type, guint64 vs. guint. + * - nm_hash_complete() never returns zero. + * + * In practice, nm_hash*() API is implemented via siphash24, so this returns + * the siphash24 value. But that is not guaranteed by the API, and if you need + * siphash24 directly, use c_siphash_*() and nm_hash_siphash42*() API. */ return c_siphash_finalize(&state->_state); } @@ -86,8 +86,8 @@ nm_hash_complete(NMHashState *state) h = nm_hash_complete_u64(state); /* we don't ever want to return a zero hash. - * - * NMPObject requires that in _idx_obj_part(), and it's just a good idea. */ + * + * NMPObject requires that in _idx_obj_part(), and it's just a good idea. */ return (((guint)(h >> 32)) ^ ((guint) h)) ?: 1396707757u; } @@ -98,10 +98,10 @@ nm_hash_update(NMHashState *state, const void *ptr, gsize n) nm_assert(n == 0 || ptr); /* Note: the data passed in here might be sensitive data (secrets), - * that we should nm_explicit_bzero() afterwards. However, since - * we are using siphash24 with a random key, that is not really - * necessary. Something to keep in mind, if we ever move away from - * this hash implementation. */ + * that we should nm_explicit_bzero() afterwards. However, since + * we are using siphash24 with a random key, that is not really + * necessary. Something to keep in mind, if we ever move away from + * this hash implementation. */ c_siphash_append(&state->_state, ptr, n); } @@ -270,12 +270,12 @@ static inline void nm_hash_update_mem(NMHashState *state, const void *ptr, gsize n) { /* This also hashes the length of the data. That means, - * hashing two consecutive binary fields (of arbitrary - * length), will hash differently. That is, - * [[1,1], []] differs from [[1],[1]]. - * - * If you have a constant length (sizeof), use nm_hash_update() - * instead. */ + * hashing two consecutive binary fields (of arbitrary + * length), will hash differently. That is, + * [[1,1], []] differs from [[1],[1]]. + * + * If you have a constant length (sizeof), use nm_hash_update() + * instead. */ nm_hash_update(state, &n, sizeof(n)); if (n > 0) nm_hash_update(state, ptr, n); diff --git a/shared/nm-glib-aux/nm-io-utils.c b/shared/nm-glib-aux/nm-io-utils.c index db7ed0d000..784ab5f771 100644 --- a/shared/nm-glib-aux/nm-io-utils.c +++ b/shared/nm-glib-aux/nm-io-utils.c @@ -385,11 +385,11 @@ nm_utils_file_set_contents(const char *filename, } /* If the final destination exists and is > 0 bytes, we want to sync the - * newly written file to ensure the data is on disk when we rename over - * the destination. Otherwise, if we get a system crash we can lose both - * the new and the old file on some filesystems. (I.E. those that don't - * guarantee the data is written to the disk before the metadata.) - */ + * newly written file to ensure the data is on disk when we rename over + * the destination. Otherwise, if we get a system crash we can lose both + * the new and the old file on some filesystems. (I.E. those that don't + * guarantee the data is written to the disk before the metadata.) + */ if (lstat(filename, &statbuf) == 0 && statbuf.st_size > 0) { if (fsync(fd) != 0) { errsv = NM_ERRNO_NATIVE(errno); @@ -457,10 +457,10 @@ nm_utils_fd_read(int fd, NMStrBuf *out_string) g_return_val_if_fail(out_string, -1); /* If the buffer size is 0, we allocate NM_UTILS_GET_NEXT_REALLOC_SIZE_1000 (1000 bytes) - * the first time. Afterwards, the buffer grows exponentially. - * - * Note that with @buf_available, we always would read as much buffer as we actually - * have reserved. */ + * the first time. Afterwards, the buffer grows exponentially. + * + * Note that with @buf_available, we always would read as much buffer as we actually + * have reserved. */ nm_str_buf_maybe_expand(out_string, NM_UTILS_GET_NEXT_REALLOC_SIZE_1000, FALSE); buf_available = out_string->allocated - out_string->len; diff --git a/shared/nm-glib-aux/nm-json-aux.c b/shared/nm-glib-aux/nm-json-aux.c index 1d1e456cba..e344b3d4bd 100644 --- a/shared/nm-glib-aux/nm-json-aux.c +++ b/shared/nm-glib-aux/nm-json-aux.c @@ -82,18 +82,18 @@ _gstr_append_string_len(GString *gstr, const char *str, gsize len) if (end[0] == '\0') { /* there is a NUL byte in the string. Technically this is valid UTF-8, so we - * encode it there. However, this will likely result in a truncated string when - * parsing. */ + * encode it there. However, this will likely result in a truncated string when + * parsing. */ g_string_append(gstr, "\\u0000"); } else { /* the character is not valid UTF-8. There is nothing we can do about it, because - * JSON can only contain UTF-8 and even the escape sequences can only escape Unicode - * codepoints (but not binary). - * - * The argument is not a string (in any known encoding), hence we cannot represent - * it as a JSON string (which are unicode strings). - * - * Print an underscore instead of the invalid char :) */ + * JSON can only contain UTF-8 and even the escape sequences can only escape Unicode + * codepoints (but not binary). + * + * The argument is not a string (in any known encoding), hence we cannot represent + * it as a JSON string (which are unicode strings). + * + * Print an underscore instead of the invalid char :) */ g_string_append_c(gstr, '_'); } diff --git a/shared/nm-glib-aux/nm-json-aux.h b/shared/nm-glib-aux/nm-json-aux.h index 5f8a69c22d..4e349e647d 100644 --- a/shared/nm-glib-aux/nm-json-aux.h +++ b/shared/nm-glib-aux/nm-json-aux.h @@ -141,8 +141,8 @@ static inline void nm_json_decref(const NMJsonVt *vt, nm_json_t *json) { /* Our ref-counting is not threadsafe, unlike libjansson's. But we never - * share one json_t instance between threads, and if we would, we would very likely - * wrap a mutex around it. */ + * share one json_t instance between threads, and if we would, we would very likely + * wrap a mutex around it. */ if (json && json->refcount != (size_t) -1 && --json->refcount == 0) vt->nm_json_delete(json); } @@ -296,7 +296,7 @@ nm_value_type_from_json(const NMJsonVt * vt, return (nm_jansson_json_as_int(vt, elem, out_val) > 0); /* warning: this overwrites/leaks the previous value. You better have *out_val - * point to uninitialized memory or NULL. */ + * point to uninitialized memory or NULL. */ case NM_VALUE_TYPE_STRING: return (nm_jansson_json_as_string(vt, elem, out_val) > 0); diff --git a/shared/nm-glib-aux/nm-logging-base.h b/shared/nm-glib-aux/nm-logging-base.h index e838d08f95..63e7ddddd5 100644 --- a/shared/nm-glib-aux/nm-logging-base.h +++ b/shared/nm-glib-aux/nm-logging-base.h @@ -10,12 +10,12 @@ typedef struct { const char *level_str; /* nm-logging uses syslog internally. Note that the three most-verbose syslog levels - * are LOG_DEBUG, LOG_INFO and LOG_NOTICE. Journal already highlights LOG_NOTICE - * as special. - * - * On the other hand, we have three levels LOGL_TRACE, LOGL_DEBUG and LOGL_INFO, - * which are regular messages not to be highlighted. For that reason, we must map - * LOGL_TRACE and LOGL_DEBUG both to syslog level LOG_DEBUG. */ + * are LOG_DEBUG, LOG_INFO and LOG_NOTICE. Journal already highlights LOG_NOTICE + * as special. + * + * On the other hand, we have three levels LOGL_TRACE, LOGL_DEBUG and LOGL_INFO, + * which are regular messages not to be highlighted. For that reason, we must map + * LOGL_TRACE and LOGL_DEBUG both to syslog level LOG_DEBUG. */ int syslog_level; GLogLevelFlags g_log_level; diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h index 47e544f512..4ba280dbe3 100644 --- a/shared/nm-glib-aux/nm-macros-internal.h +++ b/shared/nm-glib-aux/nm-macros-internal.h @@ -811,15 +811,15 @@ nm_str_realloc(char *str) gs_free char *s = str; /* Returns a new clone of @str and frees @str. The point is that @str - * possibly points to a larger chunck of memory. We want to freshly allocate - * a buffer. - * - * We could use realloc(), but that might not do anything or leave - * @str in its memory pool for chunks of a different size (bad for - * fragmentation). - * - * This is only useful when we want to keep the buffer around for a long - * time and want to re-allocate a more optimal buffer. */ + * possibly points to a larger chunck of memory. We want to freshly allocate + * a buffer. + * + * We could use realloc(), but that might not do anything or leave + * @str in its memory pool for chunks of a different size (bad for + * fragmentation). + * + * This is only useful when we want to keep the buffer around for a long + * time and want to re-allocate a more optimal buffer. */ return g_strdup(s); } @@ -970,9 +970,9 @@ static inline void nm_g_object_unref(gpointer obj) { /* g_object_unref() doesn't accept NULL. Usually, we workaround that - * by using g_clear_object(), but sometimes that is not convenient - * (for example as destroy function for a hash table that can contain - * NULL values). */ + * by using g_clear_object(), but sometimes that is not convenient + * (for example as destroy function for a hash table that can contain + * NULL values). */ if (obj) g_object_unref(obj); } @@ -1697,7 +1697,7 @@ nm_decode_version(guint version, guint *major, guint *minor, guint *micro) int _buf_len; \ \ /* some static assert trying to ensure that the buffer is statically allocated. - * It disallows a buffer size of sizeof(gpointer) to catch that. */ \ + * It disallows a buffer size of sizeof(gpointer) to catch that. */ \ G_STATIC_ASSERT(G_N_ELEMENTS(buf) == sizeof(buf) && sizeof(buf) != sizeof(char *)); \ _buf_len = g_snprintf(_buf, sizeof(buf), "" format "", ##__VA_ARGS__); \ nm_assert(_buf_len < sizeof(buf)); \ diff --git a/shared/nm-glib-aux/nm-obj.h b/shared/nm-glib-aux/nm-obj.h index f1addf8a0b..bc2f6da93c 100644 --- a/shared/nm-glib-aux/nm-obj.h +++ b/shared/nm-glib-aux/nm-obj.h @@ -15,20 +15,20 @@ typedef struct _NMObjBaseClass NMObjBaseClass; struct _NMObjBaseInst { /* The first field of NMObjBaseInst is compatible with GObject. - * Basically, NMObjBaseInst is an abstract base type of GTypeInstance. - * - * If you do it right, you may derive a type of NMObjBaseInst as a proper GTypeInstance. - * That involves allocating a GType for it, which can be inconvenient because - * a GType is dynamically created (and the class can no longer be immutable - * memory). - * - * Even if your implementation of NMObjBaseInst is not a full fledged GType(Instance), - * you still can use GTypeInstances in the same context as you can decide based on the - * NMObjBaseClass with what kind of object you are dealing with. - * - * Basically, the only thing NMObjBaseInst gives you is access to an - * NMObjBaseClass instance. - */ + * Basically, NMObjBaseInst is an abstract base type of GTypeInstance. + * + * If you do it right, you may derive a type of NMObjBaseInst as a proper GTypeInstance. + * That involves allocating a GType for it, which can be inconvenient because + * a GType is dynamically created (and the class can no longer be immutable + * memory). + * + * Even if your implementation of NMObjBaseInst is not a full fledged GType(Instance), + * you still can use GTypeInstances in the same context as you can decide based on the + * NMObjBaseClass with what kind of object you are dealing with. + * + * Basically, the only thing NMObjBaseInst gives you is access to an + * NMObjBaseClass instance. + */ union { const NMObjBaseClass *klass; GTypeInstance g_type_instance; @@ -37,24 +37,24 @@ struct _NMObjBaseInst { struct _NMObjBaseClass { /* NMObjBaseClass is the base class of all NMObjBaseInst implementations. - * Note that it is also an abstract super class of GTypeInstance, that means - * you may implement a NMObjBaseClass as a subtype of GTypeClass. - * - * For that to work, you must properly set the GTypeClass instance (and its - * GType). - * - * Note that to implement a NMObjBaseClass that is *not* a GTypeClass, you wouldn't - * set the GType. Hence, this field is only useful for type implementations that actually - * extend GTypeClass. - * - * In a way it is wrong that NMObjBaseClass has the GType member, because it is - * a base class of GTypeClass and doesn't necessarily use the GType. However, - * it is here so that G_TYPE_CHECK_INSTANCE_TYPE() and friends work correctly - * on any NMObjectClass. That means, while not necessary, it is convenient that - * a NMObjBaseClass has all members of GTypeClass. - * Also note that usually you have only one instance of a certain type, so this - * wastes just a few bytes for the unneeded GType. - */ + * Note that it is also an abstract super class of GTypeInstance, that means + * you may implement a NMObjBaseClass as a subtype of GTypeClass. + * + * For that to work, you must properly set the GTypeClass instance (and its + * GType). + * + * Note that to implement a NMObjBaseClass that is *not* a GTypeClass, you wouldn't + * set the GType. Hence, this field is only useful for type implementations that actually + * extend GTypeClass. + * + * In a way it is wrong that NMObjBaseClass has the GType member, because it is + * a base class of GTypeClass and doesn't necessarily use the GType. However, + * it is here so that G_TYPE_CHECK_INSTANCE_TYPE() and friends work correctly + * on any NMObjectClass. That means, while not necessary, it is convenient that + * a NMObjBaseClass has all members of GTypeClass. + * Also note that usually you have only one instance of a certain type, so this + * wastes just a few bytes for the unneeded GType. + */ union { GType g_type; GTypeClass g_type_class; diff --git a/shared/nm-glib-aux/nm-random-utils.c b/shared/nm-glib-aux/nm-random-utils.c index 93c943ab66..83d620dcaa 100644 --- a/shared/nm-glib-aux/nm-random-utils.c +++ b/shared/nm-glib-aux/nm-random-utils.c @@ -64,29 +64,29 @@ nm_utils_random_bytes(void *p, size_t n) return TRUE; /* no or partial read. There is not enough entropy. - * Fill the rest reading from urandom, and remember that - * some bits are not high quality. */ + * Fill the rest reading from urandom, and remember that + * some bits are not high quality. */ nm_assert(r < n); buf += r; n -= r; has_high_quality = FALSE; /* At this point, we don't want to read /dev/urandom, because - * the entropy pool is low (early boot?), and asking for more - * entropy causes kernel messages to be logged. - * - * We use our fallback via GRand. Note that g_rand_new() also - * tries to seed itself with data from /dev/urandom, but since - * we reuse the instance, it shouldn't matter. */ + * the entropy pool is low (early boot?), and asking for more + * entropy causes kernel messages to be logged. + * + * We use our fallback via GRand. Note that g_rand_new() also + * tries to seed itself with data from /dev/urandom, but since + * we reuse the instance, it shouldn't matter. */ avoid_urandom = TRUE; } else { if (errno == ENOSYS) { /* no support for getrandom(). We don't know whether - * we urandom will give us good quality. Assume yes. */ + * we urandom will give us good quality. Assume yes. */ have_syscall = FALSE; } else { /* unknown error. We'll read urandom below, but we don't have - * high-quality randomness. */ + * high-quality randomness. */ has_high_quality = FALSE; } } @@ -116,10 +116,10 @@ fd_open: int j; /* we failed to fill the bytes reading from urandom. - * Fill the bits using GRand pseudo random numbers. - * - * We don't have good quality. - */ + * Fill the bits using GRand pseudo random numbers. + * + * We don't have good quality. + */ has_high_quality = FALSE; if (G_UNLIKELY(!rand)) diff --git a/shared/nm-glib-aux/nm-ref-string.c b/shared/nm-glib-aux/nm-ref-string.c index bc40c63d44..fcd8d6441d 100644 --- a/shared/nm-glib-aux/nm-ref-string.c +++ b/shared/nm-glib-aux/nm-ref-string.c @@ -177,7 +177,7 @@ _nm_ref_string_unref_non_null(NMRefString *rstr) G_LOCK(gl_lock); /* in the fast-path above, we already decremented the ref-count to zero. - * We need recheck that the ref-count is still zero. */ + * We need recheck that the ref-count is still zero. */ if (g_atomic_int_get(&rstr0->ref_count) == 0) { if (!g_hash_table_remove(gl_hash, rstr0)) diff --git a/shared/nm-glib-aux/nm-ref-string.h b/shared/nm-glib-aux/nm-ref-string.h index 11733589ac..b70f7728a4 100644 --- a/shared/nm-glib-aux/nm-ref-string.h +++ b/shared/nm-glib-aux/nm-ref-string.h @@ -51,8 +51,8 @@ static inline gboolean nm_ref_string_equals_str(NMRefString *rstr, const char *s) { /* Note that rstr->len might be greater than strlen(rstr->str). This function does - * not cover that and would ignore everything after the first NUL byte. If you need - * that distinction, this function is not for you. */ + * not cover that and would ignore everything after the first NUL byte. If you need + * that distinction, this function is not for you. */ return rstr ? (s && nm_streq(rstr->str, s)) : (s == NULL); } @@ -70,9 +70,9 @@ NM_IS_REF_STRING(const NMRefString *rstr) #endif /* Technically, %NULL is also a valid NMRefString (according to nm_ref_string_new(), - * nm_ref_string_get_str() and nm_ref_string_unref()). However, NM_IS_REF_STRING() - * does not think so. If callers want to allow %NULL, they need to check - * separately. */ + * nm_ref_string_get_str() and nm_ref_string_unref()). However, NM_IS_REF_STRING() + * does not think so. If callers want to allow %NULL, they need to check + * separately. */ return !!rstr; } diff --git a/shared/nm-glib-aux/nm-secret-utils.c b/shared/nm-glib-aux/nm-secret-utils.c index b51082b8b6..9c2c3cca8e 100644 --- a/shared/nm-glib-aux/nm-secret-utils.c +++ b/shared/nm-glib-aux/nm-secret-utils.c @@ -44,11 +44,11 @@ nm_free_secret(char *secret) #if GLIB_CHECK_VERSION(2, 44, 0) /* Here we mix malloc() and g_malloc() API. Usually we avoid this, - * however since glib 2.44.0 we are in fact guaranteed that g_malloc()/g_free() - * just wraps malloc()/free(), so this is actually fine. - * - * See https://gitlab.gnome.org/GNOME/glib/commit/3be6ed60aa58095691bd697344765e715a327fc1 - */ + * however since glib 2.44.0 we are in fact guaranteed that g_malloc()/g_free() + * just wraps malloc()/free(), so this is actually fine. + * + * See https://gitlab.gnome.org/GNOME/glib/commit/3be6ed60aa58095691bd697344765e715a327fc1 + */ len = malloc_usable_size(secret); #else len = strlen(secret); @@ -68,9 +68,9 @@ nm_secret_strchomp(char *secret) g_return_val_if_fail(secret, NULL); /* it's actually identical to g_strchomp(). However, - * the glib function does not document, that it clears the - * memory. For @secret, we don't only want to truncate trailing - * spaces, we want to overwrite them with NUL. */ + * the glib function does not document, that it clears the + * memory. For @secret, we don't only want to truncate trailing + * spaces, we want to overwrite them with NUL. */ len = strlen(secret); while (len--) { @@ -96,16 +96,16 @@ nm_secret_copy_to_gbytes(gconstpointer mem, gsize mem_len) nm_assert(mem); /* NUL terminate the buffer. - * - * The entire buffer is already malloc'ed and likely has some room for padding. - * Thus, in many situations, this additional byte will cause no overhead in - * practice. - * - * Even if it causes an overhead, do it just for safety. Yes, the returned - * bytes is not a NUL terminated string and no user must rely on this. Do - * not treat binary data as NUL terminated strings, unless you know what - * you are doing. Anyway, defensive FTW. - */ + * + * The entire buffer is already malloc'ed and likely has some room for padding. + * Thus, in many situations, this additional byte will cause no overhead in + * practice. + * + * Even if it causes an overhead, do it just for safety. Yes, the returned + * bytes is not a NUL terminated string and no user must rely on this. Do + * not treat binary data as NUL terminated strings, unless you know what + * you are doing. Anyway, defensive FTW. + */ b = nm_secret_buf_new(mem_len + 1); memcpy(b->bin, mem, mem_len); diff --git a/shared/nm-glib-aux/nm-secret-utils.h b/shared/nm-glib-aux/nm-secret-utils.h index 67a5f10d49..a8f33ce812 100644 --- a/shared/nm-glib-aux/nm-secret-utils.h +++ b/shared/nm-glib-aux/nm-secret-utils.h @@ -44,7 +44,7 @@ typedef struct { gsize len; /* the data pointer. This pointer must be allocated with malloc (at least - * when used with nm_secret_ptr_clear()). */ + * when used with nm_secret_ptr_clear()). */ union { char * str; void * ptr; diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index f8bddff548..d2ad22f8a3 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -58,7 +58,7 @@ nm_ip_addr_set_from_untrusted(int addr_family, case AF_UNSPEC: if (!out_addr_family) { /* when the callers allow undefined @addr_family, they must provide - * an @out_addr_family argument. */ + * an @out_addr_family argument. */ nm_assert_not_reached(); return FALSE; } @@ -83,7 +83,7 @@ nm_ip_addr_set_from_untrusted(int addr_family, break; default: /* when the callers allow undefined @addr_family, they must provide - * an @out_addr_family argument. */ + * an @out_addr_family argument. */ nm_assert(out_addr_family); return FALSE; } @@ -130,7 +130,7 @@ _nm_assert_on_main_thread(void) if (G_LIKELY(tid == seen_tid)) { /* we don't care about false positives (when the process forked, and the thread-id - * is accidentally re-used) . It's for assertions only. */ + * is accidentally re-used) . It's for assertions only. */ success = TRUE; } else { pid = getpid(); @@ -138,7 +138,7 @@ _nm_assert_on_main_thread(void) if (seen_tid == 0 || seen_pid != pid) { /* either this is the first time we call the function, or the process - * forked. In both cases, remember the thread-id. */ + * forked. In both cases, remember the thread-id. */ seen_tid = tid; seen_pid = pid; success = TRUE; @@ -333,8 +333,8 @@ nm_utils_strbuf_seek_end(char **buf, gsize *len) truncate: /* hm, no NUL character within len bytes. - * Just NUL terminate the array and consume them - * all. */ + * Just NUL terminate the array and consume them + * all. */ *buf += *len; (*buf)[-1] = '\0'; *len = 0; @@ -379,7 +379,7 @@ nm_utils_gbytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len) if (!bytes) { /* as a special case, let %NULL GBytes compare identical - * to an empty array. */ + * to an empty array. */ return (mem_len == 0); } @@ -531,7 +531,7 @@ nm_strquote(char *buf, gsize buf_len, const char *str) nm_utils_strbuf_append_str(&buf, &buf_len, str); /* if the string was too long we indicate truncation with a - * '^' instead of a closing quote. */ + * '^' instead of a closing quote. */ if (G_UNLIKELY(buf_len <= 1)) { switch (buf_len) { case 1: @@ -781,7 +781,7 @@ nm_utils_ip_is_site_local(int addr_family, const void *address) switch (addr_family) { case AF_INET: /* RFC1918 private addresses - * 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 */ + * 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 */ addr4 = ntohl(*((const in_addr_t *) address)); return (addr4 & 0xff000000) == 0x0a000000 || (addr4 & 0xfff00000) == 0xac100000 || (addr4 & 0xffff0000) == 0xc0a80000; @@ -812,16 +812,16 @@ _parse_legacy_addr4(const char *text, in_addr_t *out_addr, GError **error) } /* OK, inet_aton() accepted the format. That's good, because we want - * to accept IPv4 addresses in octal format, like 255.255.000.000. - * That's what "legacy" means here. inet_pton() doesn't accept those. - * - * But inet_aton() also ignores trailing garbage and formats with fewer than - * 4 digits. That is just too crazy and we don't do that. Perform additional checks - * and reject some forms that inet_aton() accepted. - * - * Note that we still should (of course) accept everything that inet_pton() - * accepts. However this code never gets called if inet_pton() succeeds - * (see below, aside the assertion code). */ + * to accept IPv4 addresses in octal format, like 255.255.000.000. + * That's what "legacy" means here. inet_pton() doesn't accept those. + * + * But inet_aton() also ignores trailing garbage and formats with fewer than + * 4 digits. That is just too crazy and we don't do that. Perform additional checks + * and reject some forms that inet_aton() accepted. + * + * Note that we still should (of course) accept everything that inet_pton() + * accepts. However this code never gets called if inet_pton() succeeds + * (see below, aside the assertion code). */ if (NM_STRCHAR_ANY(text, ch, (!(ch >= '0' && ch <= '9') && !NM_IN_SET(ch, '.', 'x')))) { /* We only accepts '.', digits, and 'x' for "0x". */ @@ -846,7 +846,7 @@ _parse_legacy_addr4(const char *text, in_addr_t *out_addr, GError **error) if ((i == G_N_ELEMENTS(bin) - 1) != (s == NULL)) { /* Exactly for the last digit, we expect to have no more following token. - * But this isn't the case. Abort. */ + * But this isn't the case. Abort. */ g_set_error(error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT, @@ -861,7 +861,7 @@ _parse_legacy_addr4(const char *text, in_addr_t *out_addr, GError **error) int errsv = errno; /* we do accept octal and hex (even with leading "0x"). But something - * about this token is wrong. */ + * about this token is wrong. */ g_set_error(error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT, @@ -877,7 +877,7 @@ _parse_legacy_addr4(const char *text, in_addr_t *out_addr, GError **error) if (memcmp(bin, &a1, sizeof(bin)) != 0) { /* our parsing did not agree with what inet_aton() gave. Something - * is wrong. Abort. */ + * is wrong. Abort. */ g_set_error( error, NM_UTILS_ERROR, @@ -916,7 +916,7 @@ nm_utils_parse_inaddr_bin_full(int addr_family, if (accept_legacy && addr_family == AF_INET && _parse_legacy_addr4(text, &addrbin.addr4, NULL)) { /* The address is in some legacy format which inet_aton() accepts, but not inet_pton(). - * Most likely octal digits (leading zeros). We accept the address. */ + * Most likely octal digits (leading zeros). We accept the address. */ } else return FALSE; } @@ -927,7 +927,7 @@ nm_utils_parse_inaddr_bin_full(int addr_family, in_addr_t a; /* The legacy parser should accept everything that inet_pton() accepts too. Meaning, - * it should strictly parse *more* formats. And of course, parse it the same way. */ + * it should strictly parse *more* formats. And of course, parse it the same way. */ if (!_parse_legacy_addr4(text, &a, &error)) { char buf[INET_ADDRSTRLEN]; @@ -1000,7 +1000,7 @@ nm_utils_parse_inaddr_prefix_bin(int addr_family, if (slash) { /* For IPv4, `ip addr add` supports the prefix-length as a netmask. We don't - * do that. */ + * do that. */ prefix = _nm_utils_ascii_str_to_int64(&slash[1], 10, 0, addr_family == AF_INET ? 32 : 128, -1); if (prefix == -1) @@ -1052,7 +1052,7 @@ nm_utils_parse_next_line(const char **inout_ptr, for (line_len = 0;; line_len++) { if (line_len >= *inout_len) { /* if we consumed the entire line, we place the pointer at - * one character after the end. */ + * one character after the end. */ *inout_ptr = &line_start[line_len]; *inout_len = 0; goto done; @@ -1245,7 +1245,7 @@ again: #endif /* Not really much else to do. Return the parsed value and leave errno set - * to the unexpected value. */ + * to the unexpected value. */ return v; } @@ -1335,7 +1335,7 @@ _nm_utils_ascii_str_to_uint64(const char *str, if (v != 0 && str[0] == '-') { /* As documented, g_ascii_strtoull() accepts negative values, and returns their - * absolute value. We don't. */ + * absolute value. We don't. */ errno = ERANGE; return fallback; } @@ -1405,11 +1405,11 @@ int nm_cmp_int2ptr_p_with_data(gconstpointer p_a, gconstpointer p_b, gpointer user_data) { /* p_a and p_b are two pointers to a pointer, where the pointer is - * interpreted as a integer using GPOINTER_TO_INT(). - * - * That is the case of a hash-table that uses GINT_TO_POINTER() to - * convert integers as pointers, and the resulting keys-as-array - * array. */ + * interpreted as a integer using GPOINTER_TO_INT(). + * + * That is the case of a hash-table that uses GINT_TO_POINTER() to + * convert integers as pointers, and the resulting keys-as-array + * array. */ const int a = GPOINTER_TO_INT(*((gconstpointer *) p_a)); const int b = GPOINTER_TO_INT(*((gconstpointer *) p_b)); @@ -1439,10 +1439,10 @@ _dbus_path_component_as_num(const char *p) gint64 n; /* no odd stuff. No leading zeros, only a non-negative, decimal integer. - * - * Otherwise, there would be multiple ways to encode the same number "10" - * and "010". That is just confusing. A number has no leading zeros, - * if it has, it's not a number (as far as we are concerned here). */ + * + * Otherwise, there would be multiple ways to encode the same number "10" + * and "010". That is just confusing. A number has no leading zeros, + * if it has, it's not a number (as far as we are concerned here). */ if (p[0] == '0') { if (p[1] != '\0') return -1; @@ -1466,14 +1466,14 @@ nm_utils_dbus_path_cmp(const char *dbus_path_a, const char *dbus_path_b) gint64 n_a, n_b; /* compare function for two D-Bus paths. It behaves like - * strcmp(), except, if both paths have the same prefix, - * and both end in a (positive) number, then the paths - * will be sorted by number. */ + * strcmp(), except, if both paths have the same prefix, + * and both end in a (positive) number, then the paths + * will be sorted by number. */ NM_CMP_SELF(dbus_path_a, dbus_path_b); /* if one or both paths have no slash (and no last component) - * compare the full paths directly. */ + * compare the full paths directly. */ if (!(l_a = nm_utils_dbus_path_get_last_component(dbus_path_a)) || !(l_b = nm_utils_dbus_path_get_last_component(dbus_path_b))) goto comp_full; @@ -1490,20 +1490,20 @@ nm_utils_dbus_path_cmp(const char *dbus_path_a, const char *dbus_path_b) goto comp_l; /* both components must be convertible to a number. If they are not, - * (and only one of them is), then we must always strictly sort numeric parts - * after non-numeric components. If we wouldn't, we wouldn't have - * a total order. - * - * An example of a not total ordering would be: - * "8" < "010" (numeric) - * "0x" < "8" (lexical) - * "0x" > "010" (lexical) - * We avoid this, by forcing that a non-numeric entry "0x" always sorts - * before numeric entries. - * - * Additionally, _dbus_path_component_as_num() would also reject "010" as - * not a valid number. - */ + * (and only one of them is), then we must always strictly sort numeric parts + * after non-numeric components. If we wouldn't, we wouldn't have + * a total order. + * + * An example of a not total ordering would be: + * "8" < "010" (numeric) + * "0x" < "8" (lexical) + * "0x" > "010" (lexical) + * We avoid this, by forcing that a non-numeric entry "0x" always sorts + * before numeric entries. + * + * Additionally, _dbus_path_component_as_num() would also reject "010" as + * not a valid number. + */ if (n_a == -1) return -1; if (n_b == -1) @@ -1558,8 +1558,8 @@ static gboolean _char_lookup_has(const CharLookupTable *lookup, char ch) { /* with some optimization levels, the compiler thinks this code - * might access uninitialized @lookup. It is not -- when you look at the - * callers of this function. */ + * might access uninitialized @lookup. It is not -- when you look at the + * callers of this function. */ NM_PRAGMA_WARNING_DISABLE("-Wmaybe-uninitialized") nm_assert(lookup->table[(guint8) '\0'] == 0); return lookup->table[(guint8) ch] != 0; @@ -1638,9 +1638,9 @@ nm_utils_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsp if (!str[0]) { /* We return %NULL here, also with NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY. - * That makes nm_utils_strsplit_set_full() with NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY - * different from g_strsplit_set(), which would in this case return an empty array. - * If you need to handle %NULL, and "" specially, then check the input string first. */ + * That makes nm_utils_strsplit_set_full() with NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY + * different from g_strsplit_set(), which would in this case return an empty array. + * If you need to handle %NULL, and "" specially, then check the input string first. */ return NULL; } @@ -1665,8 +1665,8 @@ nm_utils_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsp } /* we assume escapings are not frequent. After we found - * this delimiter, check whether it was escaped by counting - * the backslashed before. */ + * this delimiter, check whether it was escaped by counting + * the backslashed before. */ if (f_allow_escaping && _char_is_escaped(str, c_str)) { /* the delimiter is escaped. This was not an accepted delimiter. */ c_str++; @@ -1770,7 +1770,7 @@ done2: gsize i, j; /* We no longer need ch_lookup for its original purpose. Modify it, so it - * can detect the delimiters, '\\', and (optionally) whitespaces. */ + * can detect the delimiters, '\\', and (optionally) whitespaces. */ _char_lookup_table_set_one(&ch_lookup, '\\'); if (f_strstrip) _char_lookup_table_set_all(&ch_lookup, NM_ASCII_SPACES); @@ -1846,7 +1846,7 @@ nm_utils_escaped_tokens_escape_full(const char * str, | NM_UTILS_ESCAPED_TOKENS_ESCAPE_FLAGS_ESCAPE_TRAILING_SPACE) && !_char_lookup_has_all(&ch_lookup, NM_ASCII_SPACES)) { /* ESCAPE_LEADING_SPACE and ESCAPE_TRAILING_SPACE implies that we escape backslash - * before whitespaces. */ + * before whitespaces. */ if (!has_ch_lookup_as_needed) { has_ch_lookup_as_needed = TRUE; _char_lookup_table_init(&ch_lookup_as_needed, NULL); @@ -1981,8 +1981,8 @@ nm_utils_escaped_tokens_options_split(char *str, const char **out_key, const cha i++; } else if (str[i] == '=') { /* Encounter an unescaped '=' character. When we still parse the key, this - * is the separator we were waiting for. If we are parsing the value, - * we take the character verbatim. */ + * is the separator we were waiting for. If we are parsing the value, + * we take the character verbatim. */ if (!val) { if (last_space_has) { str[last_space_idx] = '\0'; @@ -2101,7 +2101,7 @@ nm_utils_strsplit_quoted(const char *str) g_ptr_array_add(arr, NULL); /* We want to return an optimally sized strv array, with no excess - * memory allocated. Hence, clone once more. */ + * memory allocated. Hence, clone once more. */ return nm_memdup(arr->pdata, sizeof(char *) * arr->len); } @@ -2166,7 +2166,7 @@ _nm_utils_strv_cleanup(char ** strv, if (strip_whitespace) { /* we only modify the strings pointed to by @strv if @strip_whitespace is - * requested. Otherwise, the strings themselves are untouched. */ + * requested. Otherwise, the strings themselves are untouched. */ for (i = 0; strv[i]; i++) g_strstrip(strv[i]); } @@ -2304,7 +2304,7 @@ nm_g_object_set_property(GObject * object, g_return_val_if_fail(!error || !*error, FALSE); /* g_object_class_find_property() does g_param_spec_get_redirect_target(), - * where we differ from a plain g_object_set_property(). */ + * where we differ from a plain g_object_set_property(). */ pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(object), property_name); if (!pspec) { @@ -2432,10 +2432,10 @@ nm_g_object_set_property_char(GObject * object, GError ** error) { /* glib says about G_TYPE_CHAR: - * - * The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed integer. - * - * This is always a (signed!) char. */ + * + * The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed integer. + * + * This is always a (signed!) char. */ _set_property(object, property_name, G_TYPE_CHAR, g_value_set_schar, value, error); } @@ -2678,8 +2678,8 @@ nm_utils_buf_utf8safe_unescape(const char * str, ch = (++str)[0]; if (ch >= '0' && ch <= '7') { /* technically, escape sequences larger than \3FF are out of range - * and invalid. We don't check for that, and do the same as - * g_strcompress(): silently clip the value with & 0xFF. */ + * and invalid. We don't check for that, and do the same as + * g_strcompress(): silently clip the value with & 0xFF. */ v = v * 8 + (ch - '0'); ++str; } @@ -2707,7 +2707,7 @@ nm_utils_buf_utf8safe_unescape(const char * str, break; default: /* Here we handle "\\\\", but all other unexpected escape sequences are really a bug. - * Take them literally, after removing the escape character */ + * Take them literally, after removing the escape character */ break; } str++; @@ -2732,8 +2732,8 @@ nm_utils_buf_utf8safe_unescape(const char * str, } /* assert that no reallocation was necessary. For one, unescaping should - * never result in a longer string than the input. Also, when unescaping - * secrets, we want to ensure that we don't leak secrets in memory. */ + * never result in a longer string than the input. Also, when unescaping + * secrets, we want to ensure that we don't leak secrets in memory. */ nm_assert(strbuf.allocated == len + 1u); return (*to_free = nm_str_buf_finalize(&strbuf, out_len)); @@ -2800,7 +2800,7 @@ nm_utils_buf_utf8safe_escape(gconstpointer buf, if (g_utf8_validate(str, buflen, &p) && nul_terminated) { /* note that g_utf8_validate() does not allow NUL character inside @str. Good. - * We can treat @str like a NUL terminated string. */ + * We can treat @str like a NUL terminated string. */ if (!NM_STRCHAR_ANY( str, ch, @@ -3009,7 +3009,7 @@ nm_utils_fd_read_loop(int fd, void *buf, size_t nbytes, bool do_poll) g_return_val_if_fail(buf, -EINVAL); /* If called with nbytes == 0, let's call read() at least - * once, to validate the operation */ + * once, to validate the operation */ if (nbytes > (size_t) SSIZE_MAX) return -EINVAL; @@ -3026,8 +3026,8 @@ nm_utils_fd_read_loop(int fd, void *buf, size_t nbytes, bool do_poll) if (errsv == EAGAIN && do_poll) { /* We knowingly ignore any return value here, - * and expect that any error/EOF is reported - * via read() */ + * and expect that any error/EOF is reported + * via read() */ (void) nm_utils_fd_wait_for_event(fd, POLLIN, -1); continue; @@ -3215,7 +3215,7 @@ nm_utils_hash_keys_to_array(GHashTable * hash, gpointer *keys; /* by convention, we never return an empty array. In that - * case, always %NULL. */ + * case, always %NULL. */ if (!hash || g_hash_table_size(hash) == 0) { NM_SET_OUT(out_len, 0); return NULL; @@ -3279,9 +3279,9 @@ _utils_hashtable_equal(GHashTable * hash_a, nm_assert(g_hash_table_size(hash_a) == g_hash_table_size(hash_b)); /* We rely on both hashes to have the same hash/equal function. Otherwise, we would have to iterate - * both hashes and check whether all keys/values are present in the respective other hash (which - * would be O(n^2), since we couldn't use the plain lookup function. That is not a useful thing - * for this function. */ + * both hashes and check whether all keys/values are present in the respective other hash (which + * would be O(n^2), since we couldn't use the plain lookup function. That is not a useful thing + * for this function. */ g_hash_table_iter_init(&h, hash_a); while (g_hash_table_iter_next(&h, &a_key, &a_val)) { @@ -3426,12 +3426,12 @@ nm_utils_hashtable_cmp(const GHashTable *a, gboolean same; /* we expect that the hashes are equal and the caller ensures us that they - * use the same hash/equal functions. Do a fast path check first... - * - * It's unclear whether this is worth it. The full comparison is O(n*ln(n)), - * while the fast check (using the hash lookup) is O(n). But then, the pre-check - * makes additional requirements on the hash's hash/equal functions -- the - * full comparison does not make such requirements. */ + * use the same hash/equal functions. Do a fast path check first... + * + * It's unclear whether this is worth it. The full comparison is O(n*ln(n)), + * while the fast check (using the hash lookup) is O(n). But then, the pre-check + * makes additional requirements on the hash's hash/equal functions -- the + * full comparison does not make such requirements. */ same = _utils_hashtable_equal(hash_a, hash_b, cmp_values, user_data); #if NM_MORE_ASSERTS > 5 nm_assert(same == _utils_hashtable_equal(hash_b, hash_a, cmp_values, user_data)); @@ -3510,8 +3510,8 @@ nm_utils_strv_make_deep_copied(const char **strv) gsize i; /* it takes a strv list, and copies each - * strings. Note that this updates @strv *in-place* - * and returns it. */ + * strings. Note that this updates @strv *in-place* + * and returns it. */ if (!strv) return NULL; @@ -3527,8 +3527,8 @@ nm_utils_strv_make_deep_copied_n(const char **strv, gsize len) gsize i; /* it takes a strv array with len elements, and copies each - * strings. Note that this updates @strv *in-place* - * and returns it. */ + * strings. Note that this updates @strv *in-place* + * and returns it. */ if (!strv) return NULL; @@ -3576,7 +3576,7 @@ _nm_utils_strv_dup(const char *const *strv, gssize len, gboolean deep_copied) l = len; if (l == 0) { /* this function never returns an empty strv array. If you - * need that, handle it yourself. */ + * need that, handle it yourself. */ return NULL; } @@ -3584,7 +3584,7 @@ _nm_utils_strv_dup(const char *const *strv, gssize len, gboolean deep_copied) for (i = 0; i < l; i++) { if (G_UNLIKELY(!strv[i])) { /* NULL strings are not allowed. Clear the remainder of the array - * and return it (with assertion failure). */ + * and return it (with assertion failure). */ l++; for (; i < l; i++) v[i] = NULL; @@ -3618,7 +3618,7 @@ _nm_utils_strv_dup_packed(const char *const *strv, gssize len) if (G_LIKELY(len < 0)) { if (!strv || !strv[0]) { /* This function never returns an empty strv array. If you need that, handle it - * yourself. */ + * yourself. */ return NULL; } len2 = NM_PTRARRAY_LEN(strv); @@ -3655,10 +3655,10 @@ _nm_utils_strv_dup_packed(const char *const *strv, gssize len) if (G_UNLIKELY(!strv[i])) { /* Technically there is no problem with accepting NULL strings. But that - * does not really result in a strv array, and likely this only happens due - * to a bug. We want to catch such bugs by asserting. - * - * We clear the remainder of the buffer and fail with an assertion. */ + * does not really result in a strv array, and likely this only happens due + * to a bug. We want to catch such bugs by asserting. + * + * We clear the remainder of the buffer and fail with an assertion. */ len2++; for (; i < len2; i++) result[i] = NULL; @@ -3705,9 +3705,9 @@ nm_utils_ptrarray_find_binary_search(gconstpointer * list, cmp = cmpfcn(list[imid], needle, user_data); if (cmp == 0) { /* we found a matching entry at index imid. - * - * Does the caller request the first/last index as well (in case that - * there are multiple entries which compare equal). */ + * + * Does the caller request the first/last index as well (in case that + * there are multiple entries which compare equal). */ if (out_idx_first) { i2min = imin; @@ -3752,7 +3752,7 @@ nm_utils_ptrarray_find_binary_search(gconstpointer * list, } /* return the inverse of @imin. This is a negative number, but - * also is ~imin the position where the value should be inserted. */ + * also is ~imin the position where the value should be inserted. */ imin = ~imin; NM_SET_OUT(out_idx_first, imin); NM_SET_OUT(out_idx_last, imin); @@ -3820,7 +3820,7 @@ nm_utils_array_find_binary_search(gconstpointer list, } /* return the inverse of @imin. This is a negative number, but - * also is ~imin the position where the value should be inserted. */ + * also is ~imin the position where the value should be inserted. */ return ~imin; } @@ -3921,9 +3921,9 @@ nm_utils_get_start_time_for_pid(pid_t pid, char *out_state, pid_t *out_ppid) goto fail; /* start time is the token at index 19 after the '(process name)' entry - since only this - * field can contain the ')' character, search backwards for this to avoid malicious - * processes trying to fool us - */ + * field can contain the ')' character, search backwards for this to avoid malicious + * processes trying to fool us + */ p = strrchr(contents, ')'); if (!p) goto fail; @@ -4213,16 +4213,16 @@ _nm_utils_invoke_on_idle_start(gboolean use_timeout, if (cancellable) { if (g_cancellable_is_cancelled(cancellable)) { /* the cancellable is already cancelled. We ignore the timeout - * and always schedule an idle action. */ + * and always schedule an idle action. */ use_timeout = FALSE; } else { /* if we are passed a non-cancelled cancellable, we register to the "cancelled" - * signal an invoke the callback synchronously (from the signal handler). - * - * We don't do that, - * - if the cancellable is already cancelled (because we don't want to invoke - * the callback synchronously from the caller). - * - if we have no cancellable at hand. */ + * signal an invoke the callback synchronously (from the signal handler). + * + * We don't do that, + * - if the cancellable is already cancelled (because we don't want to invoke + * the callback synchronously from the caller). + * - if we have no cancellable at hand. */ data->cancelled_id = g_signal_connect(cancellable, "cancelled", G_CALLBACK(_nm_utils_invoke_on_idle_cb_cancelled), @@ -4303,7 +4303,7 @@ nm_utils_memeqzero(gconstpointer data, gsize length) int len; /* Taken from https://github.com/rustyrussell/ccan/blob/9d2d2c49f053018724bcc6e37029da10b7c3d60d/ccan/mem/mem.c#L92, - * CC-0 licensed. */ + * CC-0 licensed. */ /* Check first 16 bytes manually */ for (len = 0; len < 16; len++) { @@ -4361,7 +4361,7 @@ nm_utils_bin2hexstr_full(gconstpointer addr, } /* @out must contain at least @length*3 bytes if @delimiter is set, - * otherwise, @length*2+1. */ + * otherwise, @length*2+1. */ if (length > 0) { nm_assert(in); @@ -4771,14 +4771,14 @@ _ctx_integ_source_reacquire(CtxIntegSource *ctx_src) return; /* the parent context now iterates on a different thread. - * We need to release and reacquire the inner context. */ + * We need to release and reacquire the inner context. */ if (ctx_src->acquired) g_main_context_release(ctx_src->context); if (G_UNLIKELY(!g_main_context_acquire(ctx_src->context))) { /* Nobody is supposed to reacquire the context while we use it. This is a bug - * of the user. */ + * of the user. */ ctx_src->acquired = FALSE; g_return_if_reached(); } @@ -4874,8 +4874,8 @@ _ctx_integ_source_prepare(GSource *source, int *out_timeout) } /* How odd. We have duplicate FDs. In fact, currently g_main_context_query() always - * coalesces the FDs and this cannot happen. However, that is not documented behavior, - * so we should not rely on that. So we need to keep a list of indexes... */ + * coalesces the FDs and this cannot happen. However, that is not documented behavior, + * so we should not rely on that. So we need to keep a list of indexes... */ poll_data->events |= fd->events; if (!poll_data->has_many_idx) { int idx0; @@ -5065,10 +5065,10 @@ nm_utils_g_main_context_create_integrate_source(GMainContext *inner_context) if (!g_main_context_acquire(inner_context)) { /* We require to acquire the context while it's integrated. We need to keep it acquired - * for the entire duration. - * - * This is also necessary because g_source_attach() only wakes up the context, if - * the context is currently acquired. */ + * for the entire duration. + * + * This is also necessary because g_source_attach() only wakes up the context, if + * the context is currently acquired. */ g_return_val_if_reached(NULL); } @@ -5094,8 +5094,8 @@ nm_utils_ifname_valid_kernel(const char *name, GError **error) int i; /* This function follows kernel's interface validation - * function dev_valid_name() in net/core/dev.c. - */ + * function dev_valid_name() in net/core/dev.c. + */ if (!name) { g_set_error_literal(error, @@ -5152,14 +5152,14 @@ _nm_utils_ifname_valid_kernel(const char *name, GError **error) if (strchr(name, '%')) { /* Kernel's dev_valid_name() accepts (almost) any binary up to 15 chars. - * However, '%' is treated special as a format specifier. Try - * - * ip link add 'dummy%dx' type dummy - * - * Don't allow that for "connection.interface-name", which either - * matches an existing netdev name (thus, it cannot have a '%') or - * is used to configure a name (in which case we don't want kernel - * to replace the format specifier). */ + * However, '%' is treated special as a format specifier. Try + * + * ip link add 'dummy%dx' type dummy + * + * Don't allow that for "connection.interface-name", which either + * matches an existing netdev name (thus, it cannot have a '%') or + * is used to configure a name (in which case we don't want kernel + * to replace the format specifier). */ g_set_error_literal(error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, @@ -5169,10 +5169,10 @@ _nm_utils_ifname_valid_kernel(const char *name, GError **error) if (NM_IN_STRSET(name, "all", "default", "bonding_masters")) { /* Certain names are not allowed. The "all" and "default" names are reserved - * due to their directories in "/proc/sys/net/ipv4/conf/" and "/proc/sys/net/ipv6/conf/". - * - * Also, there is "/sys/class/net/bonding_masters" file. - */ + * due to their directories in "/proc/sys/net/ipv4/conf/" and "/proc/sys/net/ipv6/conf/". + * + * Also, there is "/sys/class/net/bonding_masters" file. + */ nm_utils_error_set(error, NM_UTILS_ERROR_UNKNOWN, _("'%s' is not allowed as interface name"), @@ -5191,7 +5191,7 @@ _nm_utils_ifname_valid_ovs(const char *name, GError **error) /* OVS actually accepts a wider range of chars (all printable UTF-8 chars), NetworkManager restricts this to ASCII char as it's a safer option for now since OVS is not well documented on this matter. - */ + */ for (ch = name; *ch; ++ch) { if (*ch == '\\' || *ch == '/' || !g_ascii_isgraph(*ch)) { g_set_error_literal(error, @@ -5398,7 +5398,7 @@ _nm_utils_format_variant_attributes_full(GString * st value = g_variant_get_string(variant, NULL); else if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BYTESTRING)) { /* FIXME: there is no guarantee that the byte array - * is valid UTF-8.*/ + * is valid UTF-8.*/ value = g_variant_get_bytestring(variant); } else continue; @@ -5474,9 +5474,9 @@ nm_utils_is_localhost(const char *name) return FALSE; /* This tries to identify local host and domain names - * described in RFC6761 plus the redhatism of localdomain. - * - * Similar to systemd's is_localhost(). */ + * described in RFC6761 plus the redhatism of localdomain. + * + * Similar to systemd's is_localhost(). */ name_len = strlen(name); @@ -5502,7 +5502,7 @@ nm_utils_is_localhost(const char *name) continue; /* we accept the name if it is equal to one of the well-known names, - * or if it is some prefix, a '.' and the well-known name. */ + * or if it is some prefix, a '.' and the well-known name. */ if (s == 0) return TRUE; if (name[s - 1] == '.') @@ -5520,7 +5520,7 @@ nm_utils_is_specific_hostname(const char *name) if (nm_streq(name, "(none)")) { /* This is not a special hostname. Probably an artefact by somebody wrongly - * printing NULL. */ + * printing NULL. */ return FALSE; } diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index 00338e1960..85c18a9e6d 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -42,16 +42,16 @@ static inline gboolean _NM_INT_NOT_NEGATIVE(gssize val) { /* whether an enum (without negative values) is a signed int, depends on compiler options - * and compiler implementation. - * - * When using such an enum for accessing an array, one naturally wants to check - * that the enum is not negative. However, the compiler doesn't like a plain - * comparison "enum_val >= 0", because (if the enum is unsigned), it will warn - * that the expression is always true *duh*. Not even a cast to a signed - * type helps to avoid the compiler warning in any case. - * - * The sole purpose of this function is to avoid a compiler warning, when checking - * that an enum is not negative. */ + * and compiler implementation. + * + * When using such an enum for accessing an array, one naturally wants to check + * that the enum is not negative. However, the compiler doesn't like a plain + * comparison "enum_val >= 0", because (if the enum is unsigned), it will warn + * that the expression is always true *duh*. Not even a cast to a signed + * type helps to avoid the compiler warning in any case. + * + * The sole purpose of this function is to avoid a compiler warning, when checking + * that an enum is not negative. */ return val >= 0; } @@ -104,8 +104,8 @@ typedef struct { struct in6_addr addr6; /* NMIPAddr is really a union for IP addresses. - * However, as ethernet addresses fit in here nicely, use - * it also for an ethernet MAC address. */ + * However, as ethernet addresses fit in here nicely, use + * it also for an ethernet MAC address. */ guint8 addr_eth[6 /*ETH_ALEN*/]; guint8 array[sizeof(struct in6_addr)]; @@ -467,61 +467,61 @@ typedef enum { NM_UTILS_STRSPLIT_SET_FLAGS_NONE = 0, /* by default, strsplit will coalesce consecutive delimiters and remove - * them from the result. If this flag is present, empty values are preserved - * and returned. - * - * When combined with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, if a value gets - * empty after strstrip(), it also gets removed. */ + * them from the result. If this flag is present, empty values are preserved + * and returned. + * + * When combined with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, if a value gets + * empty after strstrip(), it also gets removed. */ NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY = (1u << 0), /* %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING means that delimiters prefixed - * by a backslash are not treated as a separator. Such delimiters and their escape - * character are copied to the current word without unescaping them. In general, - * nm_utils_strsplit_set_full() does not remove any backslash escape characters - * and does no unescaping. It only considers them for skipping to split at - * an escaped delimiter. - * - * If this is combined with (or implied by %NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED), then - * the backslash escapes are removed from the result. - */ + * by a backslash are not treated as a separator. Such delimiters and their escape + * character are copied to the current word without unescaping them. In general, + * nm_utils_strsplit_set_full() does not remove any backslash escape characters + * and does no unescaping. It only considers them for skipping to split at + * an escaped delimiter. + * + * If this is combined with (or implied by %NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED), then + * the backslash escapes are removed from the result. + */ NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING = (1u << 1), /* If flag is set, does the same as g_strstrip() on the returned tokens. - * This will remove leading and trailing ascii whitespaces (g_ascii_isspace() - * and NM_ASCII_SPACES). - * - * - when combined with !%NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, - * empty tokens will be removed (and %NULL will be returned if that - * results in an empty string array). - * - when combined with %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING, - * trailing whitespace escaped by backslash are not stripped. */ + * This will remove leading and trailing ascii whitespaces (g_ascii_isspace() + * and NM_ASCII_SPACES). + * + * - when combined with !%NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, + * empty tokens will be removed (and %NULL will be returned if that + * results in an empty string array). + * - when combined with %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING, + * trailing whitespace escaped by backslash are not stripped. */ NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP = (1u << 2), /* This implies %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING. - * - * This will do a final run over all tokens and remove all backslash - * escape characters that - * - precede a delimiter. - * - precede a backslash. - * - preceed a whitespace (with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP). - * - * Note that with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, it is only - * necessary to escape the very last whitespace (if the delimiters - * are not whitespace themself). So, technically, it would be sufficient - * to only unescape a backslash before the last whitespace and the user - * still could express everything. However, such a rule would be complicated - * to understand, so when using backslash escaping with nm_utils_strsplit_set_full(), - * then all characters (including backslash) are treated verbatim, except: - * - * - "\\$DELIMITER" (escaped delimiter) - * - "\\\\" (escaped backslash) - * - "\\$SPACE" (escaped space) (with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP). - * - * Note that all other escapes like "\\n" or "\\001" are left alone. - * That makes the escaping/unescaping rules simple. Also, for the most part - * a text is just taken as-is, with little additional rules. Only backslashes - * need extra care, and then only if they proceed one of the relevant characters. - */ + * + * This will do a final run over all tokens and remove all backslash + * escape characters that + * - precede a delimiter. + * - precede a backslash. + * - preceed a whitespace (with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP). + * + * Note that with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, it is only + * necessary to escape the very last whitespace (if the delimiters + * are not whitespace themself). So, technically, it would be sufficient + * to only unescape a backslash before the last whitespace and the user + * still could express everything. However, such a rule would be complicated + * to understand, so when using backslash escaping with nm_utils_strsplit_set_full(), + * then all characters (including backslash) are treated verbatim, except: + * + * - "\\$DELIMITER" (escaped delimiter) + * - "\\\\" (escaped backslash) + * - "\\$SPACE" (escaped space) (with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP). + * + * Note that all other escapes like "\\n" or "\\001" are left alone. + * That makes the escaping/unescaping rules simple. Also, for the most part + * a text is just taken as-is, with little additional rules. Only backslashes + * need extra care, and then only if they proceed one of the relevant characters. + */ NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED = (1u << 3), } NMUtilsStrsplitSetFlags; @@ -533,9 +533,9 @@ static inline const char ** nm_utils_strsplit_set_with_empty(const char *str, const char *delimiters) { /* this returns the same result as g_strsplit_set(str, delimiters, -1), except - * it does not deep-clone the strv array. - * Also, for @str == "", this returns %NULL while g_strsplit_set() would return - * an empty strv array. */ + * it does not deep-clone the strv array. + * Also, for @str == "", this returns %NULL while g_strsplit_set() would return + * an empty strv array. */ return nm_utils_strsplit_set_full(str, delimiters, NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY); } @@ -578,35 +578,35 @@ typedef enum { NM_UTILS_ESCAPED_TOKENS_ESCAPE_FLAGS_ESCAPE_TRAILING_SPACE = (1ull << 2), /* Backslash characters will be escaped as "\\\\" if they precede another - * character that makes it necessary. Such characters are: - * - * 1) before another '\\' backslash. - * 2) before any delimiter in @delimiters. - * 3) before any delimiter in @delimiters_as_needed. - * 4) before a white space, if ESCAPE_LEADING_SPACE or ESCAPE_TRAILING_SPACE is set. - * 5) before the end of the word - * - * Rule 4) is an extension. It's not immediately clear why with ESCAPE_LEADING_SPACE - * and ESCAPE_TRAILING_SPACE we want *all* backslashes before a white space escaped. - * The reason is, that we obviously want to use ESCAPE_LEADING_SPACE and ESCAPE_TRAILING_SPACE - * in cases, where we later parse the backslash escaped strings back, but allowing to strip - * unescaped white spaces. That means, we want that " a " gets escaped as "\\ a\\ ". - * On the other hand, we also want that " a\\ b " gets escaped as "\\ a\\\\ b\\ ", - * and not "\\ a\\ b\\ ". Because otherwise, the parser would need to treat "\\ " - * differently depending on whether the sequence is at the beginning, end or middle - * of the word. - * - * Rule 5) is also not immediately obvious. When used with ESCAPE_TRAILING_SPACE, - * we clearly want to allow that an escaped word can have arbitrary - * whitespace suffixes. That's why this mode exists. So we must escape "a\\" as - * "a\\\\", so that appending " " does not change the meaning. - * Also without ESCAPE_TRAILING_SPACE, we want in general that we can concatenate - * two escaped words without changing their meaning. If the words would be "a\\" - * and "," (with ',' being a delimiter), then the result must be "a\\\\" and "\\," - * so that the concatenated word ("a\\\\\\,") is still the same. If we would escape - * them instead as "a\\" + "\\,", then the concatenated word would be "a\\\\," and - * different. - * */ + * character that makes it necessary. Such characters are: + * + * 1) before another '\\' backslash. + * 2) before any delimiter in @delimiters. + * 3) before any delimiter in @delimiters_as_needed. + * 4) before a white space, if ESCAPE_LEADING_SPACE or ESCAPE_TRAILING_SPACE is set. + * 5) before the end of the word + * + * Rule 4) is an extension. It's not immediately clear why with ESCAPE_LEADING_SPACE + * and ESCAPE_TRAILING_SPACE we want *all* backslashes before a white space escaped. + * The reason is, that we obviously want to use ESCAPE_LEADING_SPACE and ESCAPE_TRAILING_SPACE + * in cases, where we later parse the backslash escaped strings back, but allowing to strip + * unescaped white spaces. That means, we want that " a " gets escaped as "\\ a\\ ". + * On the other hand, we also want that " a\\ b " gets escaped as "\\ a\\\\ b\\ ", + * and not "\\ a\\ b\\ ". Because otherwise, the parser would need to treat "\\ " + * differently depending on whether the sequence is at the beginning, end or middle + * of the word. + * + * Rule 5) is also not immediately obvious. When used with ESCAPE_TRAILING_SPACE, + * we clearly want to allow that an escaped word can have arbitrary + * whitespace suffixes. That's why this mode exists. So we must escape "a\\" as + * "a\\\\", so that appending " " does not change the meaning. + * Also without ESCAPE_TRAILING_SPACE, we want in general that we can concatenate + * two escaped words without changing their meaning. If the words would be "a\\" + * and "," (with ',' being a delimiter), then the result must be "a\\\\" and "\\," + * so that the concatenated word ("a\\\\\\,") is still the same. If we would escape + * them instead as "a\\" + "\\,", then the concatenated word would be "a\\\\," and + * different. + * */ NM_UTILS_ESCAPED_TOKENS_ESCAPE_FLAGS_ESCAPE_BACKSLASH_AS_NEEDED = (1ull << 3), NM_UTILS_ESCAPED_TOKENS_ESCAPE_FLAGS_ESCAPE_BACKSLASH_ALWAYS = (1ull << 4), @@ -919,8 +919,8 @@ _nm_g_slice_free_fcn_define(1) _nm_g_slice_free_fcn_define(2) _nm_g_slice_free_f void (*_fcn)(gpointer); \ \ /* If mem_size is a compile time constant, the compiler - * will be able to optimize this. Hence, you don't want - * to call this with a non-constant size argument. */ \ + * will be able to optimize this. Hence, you don't want + * to call this with a non-constant size argument. */ \ G_STATIC_ASSERT_EXPR(((mem_size) == 1) || ((mem_size) == 2) || ((mem_size) == 4) \ || ((mem_size) == 8) || ((mem_size) == 10) || ((mem_size) == 12) \ || ((mem_size) == 16) || ((mem_size) == 32)); \ @@ -1041,16 +1041,16 @@ typedef enum { NM_UTILS_ERROR_INVALID_ARGUMENT, /*< nick=InvalidArgument >*/ /* the following codes have a special meaning and are exactly used for - * nm_device_check_connection_compatible() and nm_device_check_connection_available(). - * - * Actually, their meaning is not very important (so, don't think too - * hard about the name of these error codes). What is important, is their - * relative order (i.e. the integer value of the codes). When manager - * searches for a suitable device, it will check all devices whether - * a profile can be activated. If they all fail, it will pick the error - * message from the device that returned the *highest* error code, - * in the hope that this message makes the most sense for the caller. - * */ + * nm_device_check_connection_compatible() and nm_device_check_connection_available(). + * + * Actually, their meaning is not very important (so, don't think too + * hard about the name of these error codes). What is important, is their + * relative order (i.e. the integer value of the codes). When manager + * searches for a suitable device, it will check all devices whether + * a profile can be activated. If they all fail, it will pick the error + * message from the device that returned the *highest* error code, + * in the hope that this message makes the most sense for the caller. + * */ NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE, NM_UTILS_ERROR_CONNECTION_AVAILABLE_UNMANAGED_DEVICE, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY, @@ -1239,18 +1239,18 @@ typedef enum { NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_NON_ASCII = 0x0002, /* This flag only has an effect during escaping to ensure we - * don't leak secrets in memory. Note that during unescape we - * know the maximum result size from the beginning, and no - * reallocation happens. Thus, unescape always avoids leaking - * secrets already. */ + * don't leak secrets in memory. Note that during unescape we + * know the maximum result size from the beginning, and no + * reallocation happens. Thus, unescape always avoids leaking + * secrets already. */ NM_UTILS_STR_UTF8_SAFE_FLAG_SECRET = 0x0004, /* This flag only has an effect during unescaping. It means - * that non-escaped whitespaces (g_ascii_isspace()) will be - * stripped from the front and end of the string. Note that - * this flag is only useful for gracefully accepting user input - * with spaces. With this flag, escape and unescape may no longer - * yield the original input. */ + * that non-escaped whitespaces (g_ascii_isspace()) will be + * stripped from the front and end of the string. Note that + * this flag is only useful for gracefully accepting user input + * with spaces. With this flag, escape and unescape may no longer + * yield the original input. */ NM_UTILS_STR_UTF8_SAFE_UNESCAPE_STRIP_SPACES = 0x0008, } NMUtilsStrUtf8SafeFlags; @@ -1283,15 +1283,15 @@ static inline void nm_g_variant_unref_floating(GVariant *var) { /* often a function wants to keep a reference to an input variant. - * It uses g_variant_ref_sink() to either increase the ref-count, - * or take ownership of a possibly floating reference. - * - * If the function doesn't actually want to do anything with the - * input variant, it still must make sure that a passed in floating - * reference is consumed. Hence, this helper which: - * - * - does nothing if @var is not floating - * - unrefs (consumes) @var if it is floating. */ + * It uses g_variant_ref_sink() to either increase the ref-count, + * or take ownership of a possibly floating reference. + * + * If the function doesn't actually want to do anything with the + * input variant, it still must make sure that a passed in floating + * reference is consumed. Hence, this helper which: + * + * - does nothing if @var is not floating + * - unrefs (consumes) @var if it is floating. */ if (g_variant_is_floating(var)) g_variant_unref(var); } @@ -1831,8 +1831,8 @@ static inline gboolean nm_utils_process_state_is_dead(char pstate) { /* "/proc/[pid]/stat" returns a state as the 3rd fields (see `man 5 proc`). - * Some of these states indicate the process is effectively dead (or a zombie). - */ + * Some of these states indicate the process is effectively dead (or a zombie). + */ return NM_IN_SET(pstate, 'Z', 'x', 'X'); } @@ -1882,9 +1882,9 @@ static inline const char *const * nm_strv_ptrarray_get_unsafe(GPtrArray *arr, guint *out_len) { /* warning: the GPtrArray is not NULL terminated. So, it - * isn't really a strv array (sorry the misnomer). That's why - * the function is potentially "unsafe" and you must provide a - * out_len parameter. */ + * isn't really a strv array (sorry the misnomer). That's why + * the function is potentially "unsafe" and you must provide a + * out_len parameter. */ if (!arr || arr->len == 0) { *out_len = 0; return NULL; @@ -1951,9 +1951,9 @@ static inline int nm_strv_ptrarray_cmp(const GPtrArray *a, const GPtrArray *b) { /* _nm_utils_strv_cmp_n() will treat NULL and empty arrays the same. - * That means, an empty strv array can both be represented by NULL - * and an array of length zero. - * If you need to distinguish between these case, do that yourself. */ + * That means, an empty strv array can both be represented by NULL + * and an array of length zero. + * If you need to distinguish between these case, do that yourself. */ return _nm_utils_strv_cmp_n((const char *const *) nm_g_ptr_array_pdata(a), nm_g_ptr_array_len(a), (const char *const *) nm_g_ptr_array_pdata(b), diff --git a/shared/nm-glib-aux/nm-str-buf.h b/shared/nm-glib-aux/nm-str-buf.h index 274bb09d66..898a0c3764 100644 --- a/shared/nm-glib-aux/nm-str-buf.h +++ b/shared/nm-glib-aux/nm-str-buf.h @@ -14,8 +14,8 @@ typedef struct _NMStrBuf { char *_priv_str; /* The unions only exist because we allow/encourage read-only access - * to the "len" and "allocated" fields, but modifying the fields is - * only allowed to the NMStrBuf implementation itself. */ + * to the "len" and "allocated" fields, but modifying the fields is + * only allowed to the NMStrBuf implementation itself. */ union { /*const*/ gsize len; gsize _priv_len; @@ -217,7 +217,7 @@ nm_str_buf_append_len0(NMStrBuf *strbuf, const char *str, gsize len) _nm_str_buf_assert(strbuf); /* this is basically like nm_str_buf_append_len() and - * nm_str_buf_get_str() in one. */ + * nm_str_buf_get_str() in one. */ nm_str_buf_maybe_expand(strbuf, len + 1u, FALSE); if (len > 0) { @@ -261,7 +261,7 @@ nm_str_buf_append_required_delimiter(NMStrBuf *strbuf, char delimiter) _nm_str_buf_assert(strbuf); /* appends the @delimiter if it is required (that is, if the - * string is not empty). */ + * string is not empty). */ if (strbuf->len > 0) nm_str_buf_append_c(strbuf, delimiter); return strbuf; @@ -387,7 +387,7 @@ nm_str_buf_finalize(NMStrBuf *strbuf, gsize *out_len) strbuf->_priv_str[strbuf->_priv_len] = '\0'; /* the buffer is in invalid state afterwards, however, we clear it - * so far, that nm_auto_str_buf and nm_str_buf_destroy() is happy. */ + * so far, that nm_auto_str_buf and nm_str_buf_destroy() is happy. */ return g_steal_pointer(&strbuf->_priv_str); } @@ -398,12 +398,12 @@ nm_str_buf_finalize_to_gbytes(NMStrBuf *strbuf) gsize l; /* this always returns a non-NULL, newly allocated GBytes instance. - * The data buffer always has an additional NUL character after - * the data, and the data is allocated with malloc. - * - * That means, the caller who takes ownership of the GBytes can - * safely modify the content of the buffer (including the additional - * NUL sentinel). */ + * The data buffer always has an additional NUL character after + * the data, and the data is allocated with malloc. + * + * That means, the caller who takes ownership of the GBytes can + * safely modify the content of the buffer (including the additional + * NUL sentinel). */ s = nm_str_buf_finalize(strbuf, &l); return g_bytes_new_take(s ?: g_new0(char, 1), l); } @@ -427,8 +427,8 @@ nm_str_buf_destroy(NMStrBuf *strbuf) g_free(strbuf->_priv_str); /* the buffer is in invalid state afterwards, however, we clear it - * so far, that nm_auto_str_buf is happy when calling - * nm_str_buf_destroy() again. */ + * so far, that nm_auto_str_buf is happy when calling + * nm_str_buf_destroy() again. */ strbuf->_priv_str = NULL; } diff --git a/shared/nm-glib-aux/nm-time-utils.c b/shared/nm-glib-aux/nm-time-utils.c index 3f2961318a..6112d73cc8 100644 --- a/shared/nm-glib-aux/nm-time-utils.c +++ b/shared/nm-glib-aux/nm-time-utils.c @@ -38,23 +38,23 @@ _t_init_global_state(void) } /* The only failure we tolerate is that CLOCK_BOOTTIME is not supported. - * Other than that, we rely on kernel to not fail on this. */ + * Other than that, we rely on kernel to not fail on this. */ g_assert(r == 0); g_assert(tp.tv_nsec >= 0 && tp.tv_nsec < NM_UTILS_NSEC_PER_SEC); /* Calculate an offset for the time stamp. - * - * We always want positive values, because then we can initialize - * a timestamp with 0 and be sure, that it will be less then any - * value nm_utils_get_monotonic_timestamp_*() might return. - * For this to be true also for nm_utils_get_monotonic_timestamp_sec() at - * early boot, we have to shift the timestamp to start counting at - * least from 1 second onward. - * - * Another advantage of shifting is, that this way we make use of the whole 31 bit - * range of signed int, before the time stamp for nm_utils_get_monotonic_timestamp_sec() - * wraps (~68 years). - **/ + * + * We always want positive values, because then we can initialize + * a timestamp with 0 and be sure, that it will be less then any + * value nm_utils_get_monotonic_timestamp_*() might return. + * For this to be true also for nm_utils_get_monotonic_timestamp_sec() at + * early boot, we have to shift the timestamp to start counting at + * least from 1 second onward. + * + * Another advantage of shifting is, that this way we make use of the whole 31 bit + * range of signed int, before the time stamp for nm_utils_get_monotonic_timestamp_sec() + * wraps (~68 years). + **/ offset_sec = (-((gint64) tp.tv_sec)) + 1; if (!g_once_init_enter(&init_once)) { @@ -124,9 +124,9 @@ nm_utils_get_monotonic_timestamp_nsec(void) p = _t_clock_gettime(&tp); /* Although the result will always be positive, we return a signed - * integer, which makes it easier to calculate time differences (when - * you want to subtract signed values). - **/ + * integer, which makes it easier to calculate time differences (when + * you want to subtract signed values). + **/ return (((gint64) tp.tv_sec) + p->offset_sec) * NM_UTILS_NSEC_PER_SEC + tp.tv_nsec; } @@ -151,9 +151,9 @@ nm_utils_get_monotonic_timestamp_usec(void) p = _t_clock_gettime(&tp); /* Although the result will always be positive, we return a signed - * integer, which makes it easier to calculate time differences (when - * you want to subtract signed values). - **/ + * integer, which makes it easier to calculate time differences (when + * you want to subtract signed values). + **/ return (((gint64) tp.tv_sec) + p->offset_sec) * ((gint64) G_USEC_PER_SEC) + (tp.tv_nsec / (NM_UTILS_NSEC_PER_SEC / G_USEC_PER_SEC)); } @@ -179,9 +179,9 @@ nm_utils_get_monotonic_timestamp_msec(void) p = _t_clock_gettime(&tp); /* Although the result will always be positive, we return a signed - * integer, which makes it easier to calculate time differences (when - * you want to subtract signed values). - **/ + * integer, which makes it easier to calculate time differences (when + * you want to subtract signed values). + **/ return (((gint64) tp.tv_sec) + p->offset_sec) * ((gint64) 1000) + (tp.tv_nsec / (NM_UTILS_NSEC_PER_SEC / 1000)); } @@ -243,7 +243,7 @@ nm_utils_monotonic_timestamp_as_boottime(gint64 timestamp, gint64 timestamp_nsec -1); /* if the caller didn't yet ever fetch a monotonic-timestamp, he cannot pass any meaningful - * value (because he has no idea what these timestamps would be). That would be a bug. */ + * value (because he has no idea what these timestamps would be). That would be a bug. */ nm_assert(g_atomic_pointer_get(&p_global_state)); p = _t_get_global_state(); diff --git a/shared/nm-glib-aux/nm-value-type.h b/shared/nm-glib-aux/nm-value-type.h index 943daf5ab2..fbe6ba1991 100644 --- a/shared/nm-glib-aux/nm-value-type.h +++ b/shared/nm-glib-aux/nm-value-type.h @@ -25,7 +25,7 @@ typedef union { const char *v_string; /* for convenience, also let the union contain other pointer types. These are - * for NM_VALUE_TYPE_UNSPEC. */ + * for NM_VALUE_TYPE_UNSPEC. */ gconstpointer * v_ptr; const GPtrArray *v_ptrarray; @@ -144,7 +144,7 @@ nm_value_type_get_from_variant(NMValueType value_type, case NM_VALUE_TYPE_INT: /* "int" also does not have a define variant type, because it's not - * clear how many bits we would need. */ + * clear how many bits we would need. */ /* fall-through */ case NM_VALUE_TYPE_UNSPEC: @@ -169,7 +169,7 @@ nm_value_type_to_variant(NMValueType value_type, gconstpointer src) case NM_VALUE_TYPE_INT: /* "int" also does not have a define variant type, because it's not - * clear how many bits we would need. */ + * clear how many bits we would need. */ /* fall-through */ case NM_VALUE_TYPE_UNSPEC: @@ -192,7 +192,7 @@ nm_value_type_get_variant_type(NMValueType value_type) case NM_VALUE_TYPE_INT: /* "int" also does not have a define variant type, because it's not - * clear how many bits we would need. */ + * clear how many bits we would need. */ /* fall-through */ case NM_VALUE_TYPE_UNSPEC: diff --git a/shared/nm-glib-aux/tests/test-shared-general.c b/shared/nm-glib-aux/tests/test-shared-general.c index a70d107a08..d03ab5353b 100644 --- a/shared/nm-glib-aux/tests/test-shared-general.c +++ b/shared/nm-glib-aux/tests/test-shared-general.c @@ -39,18 +39,18 @@ test_gpid(void) GPid pid = 42; /* We redefine G_PID_FORMAT, because it's only available since glib 2.53.5. - * - * Also, this is the format for GPid, which for glib is always a typedef - * for "int". Add a check for that here. - * - * G_PID_FORMAT is not about pid_t, which might be a smaller int, and which we would - * check with SIZEOF_PID_T. */ + * + * Also, this is the format for GPid, which for glib is always a typedef + * for "int". Add a check for that here. + * + * G_PID_FORMAT is not about pid_t, which might be a smaller int, and which we would + * check with SIZEOF_PID_T. */ G_STATIC_ASSERT(sizeof(GPid) == sizeof(int)); g_assert_cmpstr("" G_PID_FORMAT, ==, "i"); /* check that it's really "int". We will get a compiler warning, if that's not - * the case. */ + * the case. */ int_ptr = &pid; g_assert_cmpint(*int_ptr, ==, 42); } @@ -281,7 +281,7 @@ _strv_cmp_fuzz_input(const char *const * in, gsize i; /* Fuzz the input argument. It will return two output arrays that are semantically - * equal the input. */ + * equal the input. */ if (nmtst_get_rand_bool()) { char **ss; @@ -312,12 +312,12 @@ _strv_cmp_fuzz_input(const char *const * in, if (nmtst_get_rand_bool()) { /* randomly swap the original and the clone. That means, out_s1 is either - * the input argument (as-is) or the sementically equal clone. */ + * the input argument (as-is) or the sementically equal clone. */ NM_SWAP(out_s1, out_s2); } if (nmtst_get_rand_bool()) { /* randomly make s1 and s2 the same. This is for testing that - * comparing two identical pointers yields the same result. */ + * comparing two identical pointers yields the same result. */ *out_s2 = *out_s1; } } @@ -375,7 +375,7 @@ test_strv_cmp(void) } \ \ /* Compare with self. _strv_cmp_fuzz_input() randomly swapped the arguments (_a1 and _a1x). - * Either way, the arrays must compare equal to their semantically equal alternative. */ \ + * Either way, the arrays must compare equal to their semantically equal alternative. */ \ g_assert_cmpint(_nm_utils_strv_cmp_n(_a1, _l1, _a1x, _l1), ==, 0); \ g_assert_cmpint(_nm_utils_strv_cmp_n(_a2, _l2, _a2x, _l2), ==, 0); \ \ @@ -512,7 +512,7 @@ test_nm_utils_bin2hexstr(void) hexdigit_pairs_mangled = FALSE; if (delimiter && len > 1 && nmtst_get_rand_bool()) { /* randomly convert "0?" sequences to single digits, so we can get hexdigit_pairs_required - * parameter. */ + * parameter. */ g_assert(strlen(str_hex) >= 5); g_assert(str_hex[2] == delimiter); i = 0; @@ -570,7 +570,7 @@ test_nm_utils_bin2hexstr(void) if (hexdigit_pairs_mangled) { /* we mangled the hexstr to contain single digits. Trying to parse with - * hexdigit_pairs_required must now fail. */ + * hexdigit_pairs_required must now fail. */ bin2 = nm_utils_hexstr2bin_full( str_hex, nmtst_get_rand_bool(), @@ -888,7 +888,7 @@ test_nm_utils_parse_next_line(void) } /* join the list of random words with (random) line delimiters - * ("\0", "\n", "\r" or EOF). */ + * ("\0", "\n", "\r" or EOF). */ for (j = 0; j < strv_len; j++) { nm_str_buf_append(&strbuf, strv->pdata[j]); again: @@ -900,7 +900,7 @@ again: if (strbuf.len > 0 && (nm_str_buf_get_str_unsafe(&strbuf))[strbuf.len - 1] == '\r') { /* the previous line was empty and terminated by "\r". We - * must not join with "\n". Retry. */ + * must not join with "\n". Retry. */ goto again; } nm_str_buf_append_c(&strbuf, '\n'); @@ -913,7 +913,7 @@ again: break; case 4: /* the last word randomly is delimited or not, but not if the last - * word is "". */ + * word is "". */ if (j + 1 < strv_len) { /* it's not the last word. Retry. */ goto again; @@ -921,7 +921,7 @@ again: g_assert(j == strv_len - 1); if (((const char *) strv->pdata[j])[0] == '\0') { /* if the last word was "", we need a delimiter (to parse it back). - * Retry. */ + * Retry. */ goto again; } /* The final delimiter gets omitted. It's EOF. */ diff --git a/shared/nm-meta-setting.c b/shared/nm-meta-setting.c index 2c44f15467..3326a5393f 100644 --- a/shared/nm-meta-setting.c +++ b/shared/nm-meta-setting.c @@ -568,11 +568,11 @@ out_none: int i; /* this might hint to a bug, but it would be expected for NM_TYPE_SETTING - * and NM_TYPE_SETTING_IP_CONFIG. - * - * Assert that we didn't lookup for a gtype, which we would expect to find. - * An assertion failure here, hints to a bug in nm_setting_*_class_init(). - */ + * and NM_TYPE_SETTING_IP_CONFIG. + * + * Assert that we didn't lookup for a gtype, which we would expect to find. + * An assertion failure here, hints to a bug in nm_setting_*_class_init(). + */ for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) nm_assert(nm_meta_setting_infos[i].get_setting_gtype() != gtype); } diff --git a/shared/nm-meta-setting.h b/shared/nm-meta-setting.h index 6473b06699..138cc85076 100644 --- a/shared/nm-meta-setting.h +++ b/shared/nm-meta-setting.h @@ -96,10 +96,10 @@ extern const NMSetting8021xSchemeVtable typedef enum { /* the enum (and their numeric values) are internal API. Do not assign - * any meaning the numeric values, because they already have one: - * - * they are sorted in a way, that corresponds to the asciibetical sort - * order of the corresponding setting-name. */ + * any meaning the numeric values, because they already have one: + * + * they are sorted in a way, that corresponds to the asciibetical sort + * order of the corresponding setting-name. */ NM_META_SETTING_TYPE_6LOWPAN, NM_META_SETTING_TYPE_OLPC_MESH, diff --git a/shared/nm-std-aux/c-list-util.c b/shared/nm-std-aux/c-list-util.c index f298857154..f56347ccc3 100644 --- a/shared/nm-std-aux/c-list-util.c +++ b/shared/nm-std-aux/c-list-util.c @@ -71,8 +71,8 @@ _c_list_srt_merge(CList *ls1, CList *ls2, CListSortCmp cmp, const void *user_dat ls = &head; for (;;) { /* while invoking the @cmp function, the list - * elements are not properly linked. Don't try to access - * their next/prev pointers. */ + * elements are not properly linked. Don't try to access + * their next/prev pointers. */ if (cmp(ls1, ls2, user_data) <= 0) { ls->next = ls1; ls = ls1; @@ -102,16 +102,16 @@ static CList * _c_list_sort(CList *ls, CListSortCmp cmp, const void *user_data) { /* reserve a huge stack-size. We need roughly log2(n) entries, hence this - * is much more we will ever need. We don't guard for stack-overflow either. */ + * is much more we will ever need. We don't guard for stack-overflow either. */ SortStack stack_arr[70]; SortStack *stack_head = stack_arr; stack_arr[0].ls1 = ls; /* A simple top-down, non-recursive, stable merge-sort. - * - * Maybe natural merge-sort would be better, to do better for - * partially sorted lists. */ + * + * Maybe natural merge-sort would be better, to do better for + * partially sorted lists. */ _split: stack_head[0].ls2 = _c_list_srt_split(stack_head[0].ls1); if (stack_head[0].ls2) { diff --git a/shared/nm-std-aux/nm-std-aux.h b/shared/nm-std-aux/nm-std-aux.h index e85b8e89e1..4ccb2720b1 100644 --- a/shared/nm-std-aux/nm-std-aux.h +++ b/shared/nm-std-aux/nm-std-aux.h @@ -282,8 +282,8 @@ nm_strcmp0(const char *s1, const char *s2) int c; /* like g_strcmp0(), but this is inlinable. - * - * Also, it is guaranteed to return either -1, 0, or 1. */ + * + * Also, it is guaranteed to return either -1, 0, or 1. */ if (s1 == s2) return 0; if (!s1) @@ -686,13 +686,13 @@ _nm_auto_fclose(FILE **pfd) *_pp = NULL; \ \ /* g_clear_pointer() assigns @destroy first to a local variable, so that - * you can call "g_clear_pointer (pp, (GDestroyNotify) destroy);" without - * gcc emitting a warning. We don't do that, hence, you cannot cast - * "destroy" first. - * - * On the upside: you are not supposed to cast fcn, because the pointer - * types are preserved. If you really need a cast, you should cast @pp. - * But that is hardly ever necessary. */ \ + * you can call "g_clear_pointer (pp, (GDestroyNotify) destroy);" without + * gcc emitting a warning. We don't do that, hence, you cannot cast + * "destroy" first. + * + * On the upside: you are not supposed to cast fcn, because the pointer + * types are preserved. If you really need a cast, you should cast @pp. + * But that is hardly ever necessary. */ \ (destroy)(_p); \ \ _changed = true; \ diff --git a/shared/nm-std-aux/nm-std-utils.c b/shared/nm-std-aux/nm-std-utils.c index 606692a7b8..b2060e135b 100644 --- a/shared/nm-std-aux/nm-std-utils.c +++ b/shared/nm-std-aux/nm-std-utils.c @@ -17,8 +17,8 @@ nm_utils_get_next_realloc_size(bool true_realloc, size_t requested) if (requested <= 40) { /* small allocations. Increase in small steps of 8 bytes. - * - * We get thus sizes of 8, 16, 32, 40. */ + * + * We get thus sizes of 8, 16, 32, 40. */ if (requested <= 8) return 8; if (requested <= 16) @@ -27,27 +27,27 @@ nm_utils_get_next_realloc_size(bool true_realloc, size_t requested) return 32; /* The return values for < 104 are essentially hard-coded, and the choice here is - * made without very strong reasons. - * - * We want to stay 24 bytes below the power-of-two border 64. Hence, return 40 here. - * However, the next step then is already 104 (128 - 24). It's a larger gap than in - * the steps before. - * - * It's not clear whether some of the steps should be adjusted (or how exactly). */ + * made without very strong reasons. + * + * We want to stay 24 bytes below the power-of-two border 64. Hence, return 40 here. + * However, the next step then is already 104 (128 - 24). It's a larger gap than in + * the steps before. + * + * It's not clear whether some of the steps should be adjusted (or how exactly). */ return 40; } if (requested <= 0x2000u - 24u || NM_UNLIKELY(!true_realloc)) { /* mid sized allocations. Return next power of two, minus 24 bytes extra space - * at the beginning. - * That means, we double the size as we grow. - * - * With !true_realloc, it means that the caller does not intend to call - * realloc() but instead clone the buffer. This is for example the case, when we - * want to nm_explicit_bzero() the old buffer. In that case we really want to grow - * the buffer exponentially every time and not increment in page sizes of 4K (below). - * - * We get thus sizes of 104, 232, 488, 1000, 2024, 4072, 8168... */ + * at the beginning. + * That means, we double the size as we grow. + * + * With !true_realloc, it means that the caller does not intend to call + * realloc() but instead clone the buffer. This is for example the case, when we + * want to nm_explicit_bzero() the old buffer. In that case we really want to grow + * the buffer exponentially every time and not increment in page sizes of 4K (below). + * + * We get thus sizes of 104, 232, 488, 1000, 2024, 4072, 8168... */ if (NM_UNLIKELY(requested > SIZE_MAX / 2u - 24u)) return SIZE_MAX; @@ -67,8 +67,8 @@ nm_utils_get_next_realloc_size(bool true_realloc, size_t requested) return SIZE_MAX; /* For large allocations (with !true_realloc) we allocate memory in chunks of - * 4K (- 24 bytes extra), assuming that the memory gets mmapped and thus - * realloc() is efficient by just reordering pages. */ + * 4K (- 24 bytes extra), assuming that the memory gets mmapped and thus + * realloc() is efficient by just reordering pages. */ n = ((requested + (0x0FFFu + 24u)) & ~((size_t) 0x0FFFu)) - 24u; nm_assert(n >= requested); return n; diff --git a/shared/nm-test-utils-impl.c b/shared/nm-test-utils-impl.c index 99cd3effa8..e48841b41b 100644 --- a/shared/nm-test-utils-impl.c +++ b/shared/nm-test-utils-impl.c @@ -81,7 +81,7 @@ nmtstc_service_available(NMTstcServiceInfo *info) return info; /* This happens, when test-networkmanager-service.py exits with 77 status - * code. */ + * code. */ m = g_strdup_printf("missing dependency for running NetworkManager stub service %s", NMTSTC_NM_SERVICE); g_test_skip(m); @@ -101,9 +101,9 @@ nmtstc_service_init(void) g_assert_no_error(error); /* Spawn the test service. info->keepalive_fd will be a pipe to the service's - * stdin; if it closes, the service will exit immediately. We use this to - * make sure the service exits if the test program crashes. - */ + * stdin; if it closes, the service will exit immediately. We use this to + * make sure the service exits if the test program crashes. + */ g_spawn_async_with_pipes(NULL, (char **) args, NULL, @@ -154,9 +154,9 @@ nmtstc_service_init(void) if (WIFEXITED(data.exit_code) && WEXITSTATUS(data.exit_code) == 77) { /* If the stub service exited with status 77 it means that it decided - * that it cannot conduct the tests and the test should be (gracefully) - * skip. The likely reason for that, is that libnm is not available - * via pygobject. */ + * that it cannot conduct the tests and the test should be (gracefully) + * skip. The likely reason for that, is that libnm is not available + * via pygobject. */ return NULL; } g_error("test service %s exited with error code %d", NMTSTC_NM_SERVICE, data.exit_code); @@ -471,12 +471,12 @@ _context_object_new_do(GType gtype, GObject * obj; /* Create a GObject instance synchronously, and arbitrarily use either - * the sync or async constructor. - * - * Note that the sync and async construct differ in one important aspect: - * the async constructor iterates the current g_main_context_get_thread_default(), - * while the sync constructor does not! Aside from that, both should behave - * pretty much the same way. */ + * the sync or async constructor. + * + * Note that the sync and async construct differ in one important aspect: + * the async constructor iterates the current g_main_context_get_thread_default(), + * while the sync constructor does not! Aside from that, both should behave + * pretty much the same way. */ if (sync) { nm_auto_destroy_and_unref_gsource GSource *source = NULL; @@ -605,16 +605,16 @@ nmtstc_context_object_new_valist(GType gtype, inside_loop = FALSE; } else { /* The caller allows to iterate the main context. On that point, - * we can both use the synchronous and the asynchronous initialization, - * both should yield the same result. Choose one randomly. */ + * we can both use the synchronous and the asynchronous initialization, + * both should yield the same result. Choose one randomly. */ sync = nmtst_get_rand_bool(); inside_loop = ((nmtst_get_rand_uint32() % 3) == 0); } if (inside_loop) { /* Create the obj on an idle handler of the current context. - * In practice, it should make no difference, which this check - * tries to prove. */ + * In practice, it should make no difference, which this check + * tries to prove. */ return _context_object_new_inside_loop(gtype, sync, first_property_name, var_args); } diff --git a/shared/nm-utils/nm-test-utils.h b/shared/nm-utils/nm-test-utils.h index e90f16cb9c..559630cbca 100644 --- a/shared/nm-utils/nm-test-utils.h +++ b/shared/nm-utils/nm-test-utils.h @@ -381,7 +381,7 @@ __nmtst_init(int * argc, char **d_argv, **i_argv, *nmtst_debug_copy; /* By setting then NMTST_DEBUG variable, @is_debug is set automatically. - * This can be reverted with no-debug (on command line or environment variable). */ + * This can be reverted with no-debug (on command line or environment variable). */ is_debug = TRUE; nmtst_debug_copy = g_strdup(nmtst_debug); @@ -394,7 +394,7 @@ __nmtst_init(int * argc, is_debug = TRUE; else if (!g_ascii_strcasecmp(debug, "no-debug")) { /* when specifying the NMTST_DEBUG variable, we set is_debug to true. Use this flag to disable this - * (e.g. for only setting the log-level, but not is_debug). */ + * (e.g. for only setting the log-level, but not is_debug). */ is_debug = FALSE; } else if (!g_ascii_strncasecmp(debug, "log-level=", strlen("log-level="))) { g_free(c_log_level); @@ -470,17 +470,17 @@ __nmtst_init(int * argc, } } else { /* We're intentionally assigning a value to static variables - * s_tests_x and p_tests_x without using it afterwards, just - * so that valgrind doesn't complain about the leak. */ + * s_tests_x and p_tests_x without using it afterwards, just + * so that valgrind doesn't complain about the leak. */ NM_PRAGMA_WARNING_DISABLE("-Wunused-but-set-variable") /* g_test_init() is a variadic function, so we cannot pass it - * (variadic) arguments. If you need to pass additional parameters, - * call nmtst_init() with argc==NULL and call g_test_init() yourself. */ + * (variadic) arguments. If you need to pass additional parameters, + * call nmtst_init() with argc==NULL and call g_test_init() yourself. */ /* g_test_init() sets g_log_set_always_fatal() for G_LOG_LEVEL_WARNING - * and G_LOG_LEVEL_CRITICAL. So, beware that the test will fail if you - * have any WARN or ERR log messages -- unless you g_test_expect_message(). */ + * and G_LOG_LEVEL_CRITICAL. So, beware that the test will fail if you + * have any WARN or ERR log messages -- unless you g_test_expect_message(). */ GPtrArray * arg_array = g_ptr_array_new(); gs_free char **arg_array_c = NULL; int arg_array_n, j; @@ -519,7 +519,7 @@ __nmtst_init(int * argc, if (*argc > 1) { /* collaps argc/argv by removing the arguments detected - * by g_test_init(). */ + * by g_test_init(). */ for (i = 1, j = 1; i < *argc; i++) { if ((*argv)[i] == arg_array_c[j]) j++; @@ -570,7 +570,7 @@ __nmtst_init(int * argc, if (!log_level && log_domains) { /* if the log level is not specified (but the domain is), we assume - * the caller wants to set it depending on is_debug */ + * the caller wants to set it depending on is_debug */ log_level = is_debug ? "DEBUG" : "WARN"; } @@ -590,15 +590,15 @@ __nmtst_init(int * argc, #endif } else if (__nmtst_internal.no_expect_message) { /* We have a test that would be assert_logging, but the user specified no_expect_message. - * This transforms g_test_expect_message() into a NOP, but we also have to relax - * g_log_set_always_fatal(), which was set by g_test_init(). */ + * This transforms g_test_expect_message() into a NOP, but we also have to relax + * g_log_set_always_fatal(), which was set by g_test_init(). */ g_log_set_always_fatal(G_LOG_FATAL_MASK); #ifdef _NMTST_INSIDE_CORE if (c_log_domains || c_log_level) { /* Normally, tests with assert_logging do not overwrite the logging level/domains because - * the logging statements are part of the assertions. But if the test is run with - * no-expect-message *and* the logging is set explicitly via environment variables, - * we still reset the logging. */ + * the logging statements are part of the assertions. But if the test is run with + * no-expect-message *and* the logging is set explicitly via environment variables, + * we still reset the logging. */ gboolean success; success = nm_logging_setup(log_level, log_domains, NULL, NULL); @@ -609,8 +609,8 @@ __nmtst_init(int * argc, } else { #if GLIB_CHECK_VERSION(2, 34, 0) /* We were called not to set logging levels. This means, that the user - * expects to assert against (all) messages. - * Any uncaught message on >debug level is fatal. */ + * expects to assert against (all) messages. + * Any uncaught message on >debug level is fatal. */ g_log_set_always_fatal(G_LOG_LEVEL_MASK & ~G_LOG_LEVEL_DEBUG); #else /* g_test_expect_message() is a NOP, so allow any messages */ @@ -626,11 +626,11 @@ __nmtst_init(int * argc, || !g_ascii_strcasecmp(c_log_level, "TRACE")))) && !g_getenv("G_MESSAGES_DEBUG")) { /* if we are @is_debug or @log_level=="DEBUG" and - * G_MESSAGES_DEBUG is unset, we set G_MESSAGES_DEBUG=all. - * To disable this default behaviour, set G_MESSAGES_DEBUG='' */ + * G_MESSAGES_DEBUG is unset, we set G_MESSAGES_DEBUG=all. + * To disable this default behaviour, set G_MESSAGES_DEBUG='' */ /* Note that g_setenv is not thread safe, but you should anyway call - * nmtst_init() at the very start. */ + * nmtst_init() at the very start. */ g_setenv("G_MESSAGES_DEBUG", "all", TRUE); } @@ -1035,15 +1035,15 @@ nmtst_stable_rand(guint64 seed, gpointer buf, gsize len) } n; /* We want a stable random generator that is in our control and does not - * depend on glibc/glib versions. - * Use a linear congruential generator (x[n+1] = (A * x[n] + C) % M) - * https://en.wikipedia.org/wiki/Linear_congruential_generator - * - * We choose (Knuth’s LCG MMIX) - * A = 6364136223846793005llu - * C = 1442695040888963407llu - * M = 2^64 - */ + * depend on glibc/glib versions. + * Use a linear congruential generator (x[n+1] = (A * x[n] + C) % M) + * https://en.wikipedia.org/wiki/Linear_congruential_generator + * + * We choose (Knuth’s LCG MMIX) + * A = 6364136223846793005llu + * C = 1442695040888963407llu + * M = 2^64 + */ g_assert(len == 0 || buf); @@ -1053,7 +1053,7 @@ nmtst_stable_rand(guint64 seed, gpointer buf, gsize len) n.n = (A * n.n + C); /* let's combine the 64 bits randomness in one byte. By xor-ing, it's - * also independent of endianness. */ + * also independent of endianness. */ b[0] = n.a[0] ^ n.a[1] ^ n.a[2] ^ n.a[3] ^ n.a[4] ^ n.a[5] ^ n.a[6] ^ n.a[7]; } } @@ -1082,38 +1082,38 @@ nmtst_get_rand_word_length(GRand *rand) guint probability; /* The following python code implements a random sample with this - * distribution: - * - * def random_histogram(n_tries, scale = None): - * def probability(n_tok): - * import math - * return max(2, math.floor(100 / (2*(n_tok+1)))) - * def n_tokens(): - * import random - * n_tok = 0 - * while True: - * if random.randint(0, 0xFFFFFFFF) % probability(n_tok) == 0: - * return n_tok - * n_tok += 1 - * hist = [] - * i = 0; - * while i < n_tries: - * n_tok = n_tokens() - * while n_tok >= len(hist): - * hist.append(0) - * hist[n_tok] = hist[n_tok] + 1 - * i += 1 - * if scale is not None: - * hist = list([round(x / n_tries * scale) for x in hist]) - * return hist - * - * For example, random_histogram(n_tries = 1000000, scale = 1000) may give - * - * IDX: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] - * SEEN: [20, 39, 59, 73, 80, 91, 92, 90, 91, 73, 73, 54, 55, 36, 24, 16, 16, 8, 4, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0] - * - * which give a sense of the probability with this individual results are returned. - */ + * distribution: + * + * def random_histogram(n_tries, scale = None): + * def probability(n_tok): + * import math + * return max(2, math.floor(100 / (2*(n_tok+1)))) + * def n_tokens(): + * import random + * n_tok = 0 + * while True: + * if random.randint(0, 0xFFFFFFFF) % probability(n_tok) == 0: + * return n_tok + * n_tok += 1 + * hist = [] + * i = 0; + * while i < n_tries: + * n_tok = n_tokens() + * while n_tok >= len(hist): + * hist.append(0) + * hist[n_tok] = hist[n_tok] + 1 + * i += 1 + * if scale is not None: + * hist = list([round(x / n_tries * scale) for x in hist]) + * return hist + * + * For example, random_histogram(n_tries = 1000000, scale = 1000) may give + * + * IDX: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] + * SEEN: [20, 39, 59, 73, 80, 91, 92, 90, 91, 73, 73, 54, 55, 36, 24, 16, 16, 8, 4, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0] + * + * which give a sense of the probability with this individual results are returned. + */ probability = NM_MAX(2u, (100u / (2u * (n + 1u)))); if ((rnd % probability) == 0) return n; @@ -1602,7 +1602,7 @@ __nmtst_spawn_sync(const char *working_directory, if (assert_exit_status != -1) { /* exit status is a guint8 on success. Set @assert_exit_status to -1 - * not to check for the exit status. */ + * not to check for the exit status. */ g_assert(WIFEXITED(exit_status)); g_assert_cmpint(WEXITSTATUS(exit_status), ==, assert_exit_status); } @@ -1722,7 +1722,7 @@ _nmtst_assert_resolve_relative_path_equals(const char *f1, g_assert(p1 && *p1); /* Fixme: later we might need to coalesce repeated '/', "./", and "../". - * For now, it's good enough. */ + * For now, it's good enough. */ if (g_strcmp0(p1, p2) != 0) g_error("%s:%d : filenames don't match \"%s\" vs. \"%s\" // \"%s\" - \"%s\"", file, @@ -1746,12 +1746,12 @@ nmtst_logging_disable(gboolean always) g_assert(nmtst_initialized()); if (!always && __nmtst_internal.no_expect_message) { /* The caller does not want to @always suppress logging. Instead, - * the caller wants to suppress unexpected log messages that would - * fail assertions (since we possibly assert against all unexpected - * log messages). - * - * If the test is run with no-expect-message, then don't suppress - * the loggings, because they also wouldn't fail assertions. */ + * the caller wants to suppress unexpected log messages that would + * fail assertions (since we possibly assert against all unexpected + * log messages). + * + * If the test is run with no-expect-message, then don't suppress + * the loggings, because they also wouldn't fail assertions. */ return NULL; } @@ -2355,9 +2355,9 @@ nmtst_assert_hwaddr_equals(gconstpointer hwaddr1, g_assert(nm_utils_hwaddr_aton(expected, buf2, hwaddr2_len)); /* Manually check the entire hardware address instead of using - * nm_utils_hwaddr_matches() because that function doesn't compare - * entire InfiniBand addresses for various (legitimate) reasons. - */ + * nm_utils_hwaddr_matches() because that function doesn't compare + * entire InfiniBand addresses for various (legitimate) reasons. + */ success = (hwaddr1_len == hwaddr2_len); if (success) success = !memcmp(hwaddr1, buf2, hwaddr1_len); diff --git a/shared/nm-utils/nm-vpn-plugin-macros.h b/shared/nm-utils/nm-vpn-plugin-macros.h index 32f01bf237..f9dd45a402 100644 --- a/shared/nm-utils/nm-vpn-plugin-macros.h +++ b/shared/nm-utils/nm-vpn-plugin-macros.h @@ -12,24 +12,24 @@ static inline int nm_utils_syslog_coerce_from_nm(int syslog_level) { /* NetworkManager uses internally NMLogLevel levels. When spawning - * the VPN plugin, it maps those levels to syslog levels as follows: - * - * LOGL_INFO = LOG_NOTICE, - * LOGL_DEBUG = LOG_INFO, - * LOGL_TRACE = LOG_DEBUG, - * - * However, when actually printing to syslog, we don't want to print messages - * with LOGL_INFO level as LOG_NOTICE, because they are *not* to be highlighted. - * - * In other words: NetworkManager has 3 levels that should not require highlighting: - * LOGL_INFO, LOGL_DEBUG, LOGL_TRACE. syslog on the other hand has only LOG_INFO and LOG_DEBUG. - * - * So, coerce those values before printing to syslog. When you receive the syslog_level - * from NetworkManager, instead of calling - * syslog(syslog_level, ...) - * you should call - * syslog(nm_utils_syslog_coerce_from_nm(syslog_level), ...) - */ + * the VPN plugin, it maps those levels to syslog levels as follows: + * + * LOGL_INFO = LOG_NOTICE, + * LOGL_DEBUG = LOG_INFO, + * LOGL_TRACE = LOG_DEBUG, + * + * However, when actually printing to syslog, we don't want to print messages + * with LOGL_INFO level as LOG_NOTICE, because they are *not* to be highlighted. + * + * In other words: NetworkManager has 3 levels that should not require highlighting: + * LOGL_INFO, LOGL_DEBUG, LOGL_TRACE. syslog on the other hand has only LOG_INFO and LOG_DEBUG. + * + * So, coerce those values before printing to syslog. When you receive the syslog_level + * from NetworkManager, instead of calling + * syslog(syslog_level, ...) + * you should call + * syslog(nm_utils_syslog_coerce_from_nm(syslog_level), ...) + */ switch (syslog_level) { case LOG_INFO: return LOG_DEBUG; diff --git a/shared/nm-utils/nm-vpn-plugin-utils.c b/shared/nm-utils/nm-vpn-plugin-utils.c index 99ae5d013b..9627158db7 100644 --- a/shared/nm-utils/nm-vpn-plugin-utils.c +++ b/shared/nm-utils/nm-vpn-plugin-utils.c @@ -41,10 +41,10 @@ nm_vpn_plugin_utils_load_editor(const char * module_name, if (!g_path_is_absolute(module_name)) { /* - * Load an editor from the same directory this plugin is in. - * Ideally, we'd get our .so name from the NMVpnEditorPlugin if it - * would just have a property with it... - */ + * Load an editor from the same directory this plugin is in. + * Ideally, we'd get our .so name from the NMVpnEditorPlugin if it + * would just have a property with it... + */ if (!dladdr(nm_vpn_plugin_utils_load_editor, &plugin_info)) { /* Really a "can not happen" scenario. */ g_set_error(error, @@ -61,16 +61,16 @@ nm_vpn_plugin_utils_load_editor(const char * module_name, } /* we really expect this function to be called with unchanging @module_name - * and @factory_name. And we only want to load the module once, hence it would - * be more complicated to accept changing @module_name/@factory_name arguments. - * - * The reason for only loading once is that due to glib types, we cannot create a - * certain type-name more then once, so loading the same module or another version - * of the same module will fail horribly as both try to create a GType with the same - * name. - * - * Only support loading once, any future calls will reuse the handle. To simplify - * that, we enforce that the @factory_name and @module_name is the same. */ + * and @factory_name. And we only want to load the module once, hence it would + * be more complicated to accept changing @module_name/@factory_name arguments. + * + * The reason for only loading once is that due to glib types, we cannot create a + * certain type-name more then once, so loading the same module or another version + * of the same module will fail horribly as both try to create a GType with the same + * name. + * + * Only support loading once, any future calls will reuse the handle. To simplify + * that, we enforce that the @factory_name and @module_name is the same. */ if (cached.factory) { g_return_val_if_fail(cached.dl_module, NULL); g_return_val_if_fail(cached.factory_name && nm_streq0(cached.factory_name, factory_name), @@ -112,9 +112,9 @@ nm_vpn_plugin_utils_load_editor(const char * module_name, } /* we cannot ever unload the module because it creates glib types, which - * cannot be unregistered. - * - * Thus we just leak the dl_module handle indefinitely. */ + * cannot be unregistered. + * + * Thus we just leak the dl_module handle indefinitely. */ cached.factory = factory; cached.dl_module = dl_module; cached.module_name = g_strdup(module_name); diff --git a/shared/systemd/nm-sd-utils-shared.c b/shared/systemd/nm-sd-utils-shared.c index 2c72ba4d20..04b9c8c367 100644 --- a/shared/systemd/nm-sd-utils-shared.c +++ b/shared/systemd/nm-sd-utils-shared.c @@ -123,17 +123,17 @@ gboolean nm_sd_http_url_is_valid_https (const char *url) { /* We use this function to verify connection:mud-url property, it must thus - * not change behavior. - * - * Note that sd_dhcp_client_set_mud_url() and sd_dhcp6_client_set_request_mud_url() - * assert with http_url_is_valid() that the argument is valid. We thus must make - * sure to only pass URLs that are valid according to http_url_is_valid(). - * - * This is given, because our nm_sd_http_url_is_valid_https() is more strict - * than http_url_is_valid(). - * - * We only must make sure that this is also correct in the future, when we - * re-import systemd code. */ + * not change behavior. + * + * Note that sd_dhcp_client_set_mud_url() and sd_dhcp6_client_set_request_mud_url() + * assert with http_url_is_valid() that the argument is valid. We thus must make + * sure to only pass URLs that are valid according to http_url_is_valid(). + * + * This is given, because our nm_sd_http_url_is_valid_https() is more strict + * than http_url_is_valid(). + * + * We only must make sure that this is also correct in the future, when we + * re-import systemd code. */ nm_assert (_http_url_is_valid (url, FALSE) == http_url_is_valid (url)); return _http_url_is_valid (url, TRUE); } @@ -146,11 +146,11 @@ nmtst_systemd_extract_first_word_all (const char *str, char ***out_strv) gs_unref_ptrarray GPtrArray *arr = NULL; /* we implement a str split function to parse `/proc/cmdline`. This - * code should behave like systemd, which uses extract_first_word() - * for that. - * - * As we want to unit-test our implementation to match systemd, - * expose this function for testing. */ + * code should behave like systemd, which uses extract_first_word() + * for that. + * + * As we want to unit-test our implementation to match systemd, + * expose this function for testing. */ g_assert (out_strv); g_assert (!*out_strv); |