]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix alloc-size and calloc-transposed-args compiler warnings.
authorYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Fri, 6 Sep 2024 14:01:30 +0000 (16:01 +0200)
committerYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Fri, 6 Sep 2024 14:01:30 +0000 (16:01 +0200)
doc/Changelog
libunbound/context.c
testcode/perf.c
testcode/testbound.c
validator/validator.c

index e2ab5ccf85092543825bf07d8e5bae74beae4c11..6b9d799a1c3cfe6462c6332984ebf9b0e38a4a5a 100644 (file)
@@ -1,3 +1,6 @@
+6 September 2024: Yorgos
+       - Fix alloc-size and calloc-transposed-args compiler warnings.
+
 5 September 2024: Wouter
        - Fix config file read for dnstap-sample-rate.
 
index 05f57987a40435571c061d05784588ffc8692ebd..a1a4adf98f0e8808948d12449778c74892786ce5 100644 (file)
@@ -395,7 +395,7 @@ context_serialize_cancel(struct ctx_query* q, uint32_t* len)
        /* format of cancel:
         *      o uint32 cmd
         *      o uint32 async-id */
-       uint8_t* p = (uint8_t*)reallocarray(NULL, sizeof(uint32_t), 2);
+       uint8_t* p = (uint8_t*)reallocarray(NULL, 2, sizeof(uint32_t));
        if(!p) return NULL;
        *len = 2*sizeof(uint32_t);
        sldns_write_uint32(p, UB_LIBCMD_CANCEL);
index 2be86c4bf597c11f1939302ce9c7811a2acc1473..0a4ff1726f6b4dfe72a59214564db252b918c052 100644 (file)
@@ -220,7 +220,7 @@ perfsetup(struct perfinfo* info)
 #endif
                signal(SIGTERM, perf_sigh) == SIG_ERR)
                fatal_exit("could not bind to signal");
-       info->io = (struct perfio*)calloc(sizeof(struct perfio), info->io_num);
+       info->io = (struct perfio*)calloc(info->io_num, sizeof(struct perfio));
        if(!info->io) fatal_exit("out of memory");
 #ifndef S_SPLINT_S
        FD_ZERO(&info->rset);
@@ -501,8 +501,8 @@ qlist_grow_capacity(struct perfinfo* info)
 {
        size_t newcap = (size_t)((info->qlist_capacity==0)?16:
                info->qlist_capacity*2);
-       uint8_t** d = (uint8_t**)calloc(sizeof(uint8_t*), newcap);
-       size_t* l = (size_t*)calloc(sizeof(size_t), newcap);
+       uint8_t** d = (uint8_t**)calloc(newcap, sizeof(uint8_t*));
+       size_t* l = (size_t*)calloc(newcap, sizeof(size_t));
        if(!d || !l) fatal_exit("out of memory");
        if(info->qlist_data && info->qlist_capacity)
                memcpy(d, info->qlist_data, sizeof(uint8_t*)*
index 123fe0d4e46f4e510a13db2ae0ac82b34b865e35..70feb79727beaf3554148978fe1bfc63a5b1487d 100644 (file)
@@ -502,7 +502,7 @@ struct listen_port* daemon_remote_open_ports(struct config_file*
 
 struct daemon_remote* daemon_remote_create(struct config_file* ATTR_UNUSED(cfg))
 {
-       return (struct daemon_remote*)calloc(1,1);
+       return (struct daemon_remote*)calloc(1, sizeof(struct daemon_remote));
 }
 
 void daemon_remote_delete(struct daemon_remote* rc)
index 57cd3031a77a5409b342ffdbb716d3d6b427f896..da921588356406a05fa772441c980cb4ce0efbc2 100644 (file)
@@ -97,8 +97,8 @@ fill_nsec3_iter(struct val_env* ve, char* s, int c)
        int i;
        free(ve->nsec3_keysize);
        free(ve->nsec3_maxiter);
-       ve->nsec3_keysize = (size_t*)calloc(sizeof(size_t), (size_t)c);
-       ve->nsec3_maxiter = (size_t*)calloc(sizeof(size_t), (size_t)c);
+       ve->nsec3_keysize = (size_t*)calloc((size_t)c, sizeof(size_t));
+       ve->nsec3_maxiter = (size_t*)calloc((size_t)c, sizeof(size_t));
        if(!ve->nsec3_keysize || !ve->nsec3_maxiter) {
                log_err("out of memory");
                return 0;