]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
treewide: explicit conversions to/from void* in (some) headers
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 20 May 2025 06:28:32 +0000 (08:28 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 20 May 2025 06:28:32 +0000 (08:28 +0200)
They're not needed in C, but they are in C++.  While -fpermissive can
downgrade these to warnings, it's still more troublesome than a fix.

contrib/mempattern.h
contrib/ucw/mempool.h
lib/generic/pack.h

index 7cb2bae89e29102c3fe5523fb4d08ee28711456b..105d48331eed2711fec7c1034249555eb4e79b24 100644 (file)
@@ -64,7 +64,7 @@ static inline void mm_ctx_delete(knot_mm_t *mm)
 {
        /* The mp_alloc comparison bears a risk of missing the private symbol from knot. */
        if (mm && mm->ctx && mm->alloc == (knot_mm_alloc_t)mp_alloc)
-               mp_delete(mm->ctx);
+               mp_delete((struct mempool *)mm->ctx);
 }
 
 /*! \brief Readability: avoid const-casts in code. */
index 0315138141c7ed39a6347c8938023a52fe876006..28be73d187061f41cce4fd810acbe90204192906 100644 (file)
@@ -341,7 +341,7 @@ static inline void *mp_spread(struct mempool *pool, void *p, size_t size)
  **/
 static inline char *mp_append_char(struct mempool *pool, char *p, uint c)
 {
-  p = mp_spread(pool, p, 1);
+  p = (char *)mp_spread(pool, p, 1);
   *p++ = c;
   return p;
 }
@@ -353,7 +353,7 @@ static inline char *mp_append_char(struct mempool *pool, char *p, uint c)
  **/
 static inline void *mp_append_block(struct mempool *pool, void *p, const void *block, size_t size)
 {
-  char *q = mp_spread(pool, p, size);
+  char *q = (char *)mp_spread(pool, p, size);
   memcpy(q, block, size);
   return q + size;
 }
@@ -385,8 +385,8 @@ static inline void *mp_end(struct mempool *pool, void *end)
  **/
 static inline char *mp_end_string(struct mempool *pool, void *end)
 {
-  end = mp_append_char(pool, end, 0);
-  return mp_end(pool, end);
+  end = mp_append_char(pool, (char *)end, 0);
+  return (char *)mp_end(pool, end);
 }
 
 /**
index 18d57db51ecaf1a73ab5c950b95e3b1a00507d6f..5741e27742aa7d082c54669e44dbd255ea56c3ca 100644 (file)
@@ -198,7 +198,7 @@ static inline int pack_clone(pack_t **dst, const pack_t *src, knot_mm_t *pool)
                return kr_error(EINVAL);
        /* Get a valid pack_t. */
        if (!*dst) {
-               *dst = mm_alloc(pool, sizeof(pack_t));
+               *dst = (pack_t *)mm_alloc(pool, sizeof(pack_t));
                if (!*dst) return kr_error(ENOMEM);
                pack_init(**dst);
                /* Clone data only if needed */