]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #25783 from keszybz/trivial-cleanups
authorLennart Poettering <lennart@poettering.net>
Mon, 19 Dec 2022 16:01:51 +0000 (17:01 +0100)
committerGitHub <noreply@github.com>
Mon, 19 Dec 2022 16:01:51 +0000 (17:01 +0100)
Trivial cleanups

src/basic/hashmap.c
src/boot/efi/util.h
src/shared/dns-domain.c
src/shared/userdb.c

index de7d16c3970ad99cf55537a3b5df5445bf16f689..cdf7db612c8454166d4c216168f40077ae8275ea 100644 (file)
@@ -774,7 +774,7 @@ static struct HashmapBase* hashmap_base_new(const struct hash_ops *hash_ops, enu
         HashmapBase *h;
         const struct hashmap_type_info *hi = &hashmap_type_info[type];
 
-        bool use_pool = mempool_enabled && mempool_enabled();
+        bool use_pool = mempool_enabled && mempool_enabled();  /* mempool_enabled is a weak symbol */
 
         h = use_pool ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
         if (!h)
index 699f1a2c7cf6ae5203b25a29bb4c918686ad37b6..cc750d7cca3ff6c2a044e445eb477e97832f82b0 100644 (file)
@@ -84,12 +84,12 @@ static inline void *xmalloc_multiply(size_t size, size_t n) {
 /* Use malloc attribute as this never returns p like userspace realloc. */
 _malloc_ _alloc_(3) _returns_nonnull_ _warn_unused_result_
 static inline void *xrealloc(void *p, size_t old_size, size_t new_size) {
-        void *r = xmalloc(new_size);
+        void *t = xmalloc(new_size);
         new_size = MIN(old_size, new_size);
         if (new_size > 0)
-                memcpy(r, p, new_size);
+                memcpy(t, p, new_size);
         free(p);
-        return r;
+        return t;
 }
 
 #define xpool_print(fmt, ...) ((char16_t *) ASSERT_SE_PTR(PoolPrint((fmt), ##__VA_ARGS__)))
index a071976442310d58237155b6eea223a9d20cf287..d209e17f952dc91cc305e8a28cb0e0135508c1b4 100644 (file)
@@ -297,7 +297,6 @@ int dns_label_escape_new(const char *p, size_t l, char **ret) {
 int dns_label_apply_idna(const char *encoded, size_t encoded_size, char *decoded, size_t decoded_max) {
         _cleanup_free_ uint32_t *input = NULL;
         size_t input_size, l;
-        const char *p;
         bool contains_8bit = false;
         char buffer[DNS_LABEL_MAX+1];
         int r;
@@ -314,7 +313,7 @@ int dns_label_apply_idna(const char *encoded, size_t encoded_size, char *decoded
         if (encoded_size <= 0)
                 return -EINVAL;
 
-        for (p = encoded; p < encoded + encoded_size; p++)
+        for (const char *p = encoded; p < encoded + encoded_size; p++)
                 if ((uint8_t) *p > 127)
                         contains_8bit = true;
 
@@ -756,9 +755,8 @@ int dns_name_address(const char *p, int *ret_family, union in_addr_union *ret_ad
                 return r;
         if (r > 0) {
                 uint8_t a[4];
-                unsigned i;
 
-                for (i = 0; i < ELEMENTSOF(a); i++) {
+                for (size_t i = 0; i < ELEMENTSOF(a); i++) {
                         char label[DNS_LABEL_MAX+1];
 
                         r = dns_label_unescape(&p, label, sizeof label, 0);
@@ -792,9 +790,8 @@ int dns_name_address(const char *p, int *ret_family, union in_addr_union *ret_ad
                 return r;
         if (r > 0) {
                 struct in6_addr a;
-                unsigned i;
 
-                for (i = 0; i < ELEMENTSOF(a.s6_addr); i++) {
+                for (size_t i = 0; i < ELEMENTSOF(a.s6_addr); i++) {
                         char label[DNS_LABEL_MAX+1];
                         int x, y;
 
@@ -906,8 +903,6 @@ int dns_name_to_wire_format(const char *domain, uint8_t *buffer, size_t len, boo
 }
 
 static bool srv_type_label_is_valid(const char *label, size_t n) {
-        size_t k;
-
         assert(label);
 
         if (n < 2) /* Label needs to be at least 2 chars long */
@@ -921,12 +916,11 @@ static bool srv_type_label_is_valid(const char *label, size_t n) {
                 return false;
 
         /* Third and further chars must be alphanumeric or a hyphen */
-        for (k = 2; k < n; k++) {
+        for (size_t k = 2; k < n; k++)
                 if (!ascii_isalpha(label[k]) &&
                     !ascii_isdigit(label[k]) &&
                     label[k] != '-')
                         return false;
-        }
 
         return true;
 }
@@ -1122,14 +1116,12 @@ finish:
 }
 
 static int dns_name_build_suffix_table(const char *name, const char *table[]) {
-        const char *p;
+        const char *p = ASSERT_PTR(name);
         unsigned n = 0;
         int r;
 
-        assert(name);
         assert(table);
 
-        p = name;
         for (;;) {
                 if (n > DNS_N_LABELS_MAX)
                         return -EINVAL;
index de7eef687e2212438ae7b659e226bced7b452e7c..aa55cc00ae453092db307d294554243b29382ab0 100644 (file)
@@ -469,7 +469,7 @@ static int userdb_start_query(
                     streq(de->d_name, "io.systemd.DynamicUser"))
                         continue;
 
-                /* Avoid NSS is this is requested. Note that we also skip NSS when we were asked to skip the
+                /* Avoid NSS if this is requested. Note that we also skip NSS when we were asked to skip the
                  * multiplexer, since in that case it's safer to do NSS in the client side emulation below
                  * (and when we run as part of systemd-userdbd.service we don't want to talk to ourselves
                  * anyway). */