]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/set: constify operations which don't modify Set
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 8 Jul 2019 15:31:30 +0000 (17:31 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Jul 2019 14:51:14 +0000 (16:51 +0200)
No functional change, but it's nicer to the reader.

src/basic/hashmap.c
src/basic/set.h
src/shared/dropin.c
src/shared/dropin.h

index c33e00fc598050e1c26024af2771f0ed2e3e1e88..3bd94a1320d41bac26bf073586fc79c2025a1736 100644 (file)
@@ -733,8 +733,8 @@ bool internal_hashmap_iterate(HashmapBase *h, Iterator *i, void **value, const v
         return true;
 }
 
-bool set_iterate(Set *s, Iterator *i, void **value) {
-        return internal_hashmap_iterate(HASHMAP_BASE(s), i, value, NULL);
+bool set_iterate(const Set *s, Iterator *i, void **value) {
+        return internal_hashmap_iterate(HASHMAP_BASE((Set*) s), i, value, NULL);
 }
 
 #define HASHMAP_FOREACH_IDX(idx, h, i) \
index 2a80632b79fb218f7f95cb769c00d82b21a1bdc0..2bb26c68b8c6a9e6d5efc1419bab8f995d5d8d0e 100644 (file)
@@ -28,13 +28,13 @@ int internal_set_ensure_allocated(Set **s, const struct hash_ops *hash_ops HASHM
 int set_put(Set *s, const void *key);
 /* no set_update */
 /* no set_replace */
-static inline void *set_get(Set *s, void *key) {
-        return internal_hashmap_get(HASHMAP_BASE(s), key);
+static inline void *set_get(const Set *s, void *key) {
+        return internal_hashmap_get(HASHMAP_BASE((Set *) s), key);
 }
 /* no set_get2 */
 
-static inline bool set_contains(Set *s, const void *key) {
-        return internal_hashmap_contains(HASHMAP_BASE(s), key);
+static inline bool set_contains(const Set *s, const void *key) {
+        return internal_hashmap_contains(HASHMAP_BASE((Set *) s), key);
 }
 
 static inline void *set_remove(Set *s, const void *key) {
@@ -59,19 +59,19 @@ static inline int set_move_one(Set *s, Set *other, const void *key) {
         return internal_hashmap_move_one(HASHMAP_BASE(s), HASHMAP_BASE(other), key);
 }
 
-static inline unsigned set_size(Set *s) {
-        return internal_hashmap_size(HASHMAP_BASE(s));
+static inline unsigned set_size(const Set *s) {
+        return internal_hashmap_size(HASHMAP_BASE((Set *) s));
 }
 
-static inline bool set_isempty(Set *s) {
+static inline bool set_isempty(const Set *s) {
         return set_size(s) == 0;
 }
 
-static inline unsigned set_buckets(Set *s) {
-        return internal_hashmap_buckets(HASHMAP_BASE(s));
+static inline unsigned set_buckets(const Set *s) {
+        return internal_hashmap_buckets(HASHMAP_BASE((Set *) s));
 }
 
-bool set_iterate(Set *s, Iterator *i, void **value);
+bool set_iterate(const Set *s, Iterator *i, void **value);
 
 static inline void set_clear(Set *s) {
         internal_hashmap_clear(HASHMAP_BASE(s), NULL, NULL);
index 409eef21ff4151ab764a5d24e6933beb9f671637..411f1c2f1cf6c070374d810f331d8eaa02f441ea 100644 (file)
@@ -228,7 +228,7 @@ int unit_file_find_dropin_paths(
                 Set *unit_path_cache,
                 const char *dir_suffix,
                 const char *file_suffix,
-                Set *names,
+                const Set *names,
                 char ***ret) {
 
         _cleanup_strv_free_ char **dirs = NULL;
index 88e1674c52db30539a14b3dfecfb25dfcf41f0d5..89a2ab1098b7f0ed70147b0975ad1b9b03fc4ee9 100644 (file)
@@ -21,5 +21,5 @@ int unit_file_find_dropin_paths(
                 Set *unit_path_cache,
                 const char *dir_suffix,
                 const char *file_suffix,
-                Set *names,
+                const Set *names,
                 char ***paths);