]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tidy-up: drop stray casts for allocated pointers
authorViktor Szakats <commit@vsz.me>
Thu, 4 Jun 2026 23:23:06 +0000 (01:23 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 5 Jun 2026 10:24:01 +0000 (12:24 +0200)
Closes #21865

16 files changed:
docs/FAQ.md
docs/examples/multi-event.c
docs/examples/multi-uv.c
lib/content_encoding.c
lib/mime.c
lib/vquic/cf-ngtcp2.c
lib/vtls/schannel.c
lib/vtls/schannel_verify.c
projects/OS400/ccsidcurl.c
projects/OS400/curlcl.c
projects/OS400/curlmain.c
src/mkhelp.pl
src/tool_cb_wrt.c
src/tool_formparse.c
src/tool_operate.c
tests/libtest/lib2302.c

index 96f6d7a0541b70e45f1c0a008f6ba99222bc0eae..e3aee06f277a04aef92807ef471e0332065a716b 100644 (file)
@@ -1017,7 +1017,7 @@ WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
   size_t realsize = size * nmemb;
   struct MemoryStruct *mem = (struct MemoryStruct *)data;
 
-  mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
+  mem->memory = realloc(mem->memory, mem->size + realsize + 1);
   if(mem->memory) {
     memcpy(&(mem->memory[mem->size]), ptr, realsize);
     mem->size += realsize;
index 4c52cbe3b3adfc12cda3848aee6d5f18643fda71..58744b6e2e6fa01a9a1bd8f5d2adb6350afdb9dc 100644 (file)
@@ -99,9 +99,7 @@ static void curl_perform(int fd, short event, void *arg)
 
 static struct curl_context *create_curl_context(curl_socket_t sockfd)
 {
-  struct curl_context *context;
-
-  context = (struct curl_context *)malloc(sizeof(*context));
+  struct curl_context *context = malloc(sizeof(*context));
 
   context->sockfd = sockfd;
 
index 8d6227fc7e7897e6c62b76688654e0d396ec92de..094df35105ca38a2014d5d63000c1d24d969e0b4 100644 (file)
@@ -58,9 +58,7 @@ struct curl_context {
 static struct curl_context *create_curl_context(curl_socket_t sockfd,
                                                 struct datauv *uv)
 {
-  struct curl_context *context;
-
-  context = (struct curl_context *)malloc(sizeof(*context));
+  struct curl_context *context = malloc(sizeof(*context));
 
   context->sockfd = sockfd;
   context->uv = uv;
index 889271bdffce3fa3fc7c5ef37c4d3e4f9c5dbb75..a3a5877bfae63c08cf8ea565966f0168117214a7 100644 (file)
@@ -89,7 +89,7 @@ static voidpf zalloc_cb(voidpf opaque, unsigned int items, unsigned int size)
 {
   (void)opaque;
   /* not a typo, keep it curlx_calloc() */
-  return (voidpf)curlx_calloc(items, size);
+  return curlx_calloc(items, size);
 }
 
 static void zfree_cb(voidpf opaque, voidpf ptr)
index c15807a2e94e338d271ed6dc3efc16f997908564..c41b852e486b168c2c7ce8c150c7d4d77c0da063 100644 (file)
@@ -1202,9 +1202,7 @@ CURLcode Curl_mime_duppart(struct Curl_easy *data,
 /* Create a mime handle. */
 curl_mime *curl_mime_init(void *easy)
 {
-  curl_mime *mime;
-
-  mime = (curl_mime *)curlx_malloc(sizeof(*mime));
+  curl_mime *mime = curlx_malloc(sizeof(*mime));
 
   if(mime) {
     mime->parent = NULL;
@@ -1241,7 +1239,7 @@ curl_mimepart *curl_mime_addpart(curl_mime *mime)
   if(!mime)
     return NULL;
 
-  part = (curl_mimepart *)curlx_malloc(sizeof(*part));
+  part = curlx_malloc(sizeof(*part));
 
   if(part) {
     Curl_mime_initpart(part);
index d27ffeaca036d80485fbba20fe9fa59f3e2c3b4e..ad0c9e582f6872c5ea7b3c97b9924cf8b2dc3063 100644 (file)
@@ -1938,8 +1938,8 @@ static CURLcode cf_progress_ingress(struct Curl_cfilter *cf,
     }
 
     if(ctx->tunnel_inbuf_len < max_udp_payload) {
-      unsigned char *newbuf =
-        (unsigned char *)curlx_realloc(ctx->tunnel_inbuf, max_udp_payload);
+      unsigned char *newbuf = curlx_realloc(ctx->tunnel_inbuf,
+                                            max_udp_payload);
       if(!newbuf)
         return CURLE_OUT_OF_MEMORY;
       ctx->tunnel_inbuf = newbuf;
index 0298b2b65fc68e860f47d0a44213da80dfc902a9..3782593c8ba75b767207667a5b32884a89ae1df2 100644 (file)
@@ -468,7 +468,7 @@ static CURLcode get_client_cert(struct Curl_easy *data,
 
       if(data->set.ssl.primary.key_passwd)
         pwd_len = strlen(data->set.ssl.primary.key_passwd);
-      pszPassword = (WCHAR *)curlx_malloc(sizeof(WCHAR) * (pwd_len + 1));
+      pszPassword = curlx_malloc(sizeof(WCHAR) * (pwd_len + 1));
       if(pszPassword) {
         int str_w_len = 0;
         if(pwd_len > 0)
@@ -2001,7 +2001,7 @@ static CURLcode schannel_send(struct Curl_cfilter *cf, struct Curl_easy *data,
   /* calculate the complete message length and allocate a buffer for it */
   data_len = backend->stream_sizes.cbHeader + len +
     backend->stream_sizes.cbTrailer;
-  ptr = (unsigned char *)curlx_malloc(data_len);
+  ptr = curlx_malloc(data_len);
   if(!ptr) {
     return CURLE_OUT_OF_MEMORY;
   }
index f2f4218e388469e26f275cfe5c6226d443a5ca55..127fcf2b3f60fa7dfbcedbf83ffee07e4caff89a 100644 (file)
@@ -295,7 +295,7 @@ static CURLcode add_certs_file_to_store(HCERTSTORE trust_store,
     goto cleanup;
   }
 
-  ca_file_buffer = (char *)curlx_malloc(ca_file_bufsize + 1);
+  ca_file_buffer = curlx_malloc(ca_file_bufsize + 1);
   if(!ca_file_buffer) {
     result = CURLE_OUT_OF_MEMORY;
     goto cleanup;
@@ -568,7 +568,7 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf, struct Curl_easy *data)
     /* CertGetNameString guarantees that the returned name does not contain
      * embedded null bytes. This appears to be undocumented behavior.
      */
-    cert_hostname_buff = (LPTSTR)curlx_malloc(len * sizeof(TCHAR));
+    cert_hostname_buff = curlx_malloc(len * sizeof(TCHAR));
     if(!cert_hostname_buff) {
       result = CURLE_OUT_OF_MEMORY;
       goto cleanup;
index a25197c1f2d02e59ee256eee702f979fe59443bb..cba89f8642eabe002b163552c8e99fe29d43cedb 100644 (file)
@@ -576,13 +576,12 @@ CURLcode curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...)
       case CURLINFO_CERTINFO:
         cipf = *(struct curl_certinfo **)paramp;
         if(cipf) {
-          cipt = (struct curl_certinfo *)malloc(sizeof(*cipt));
+          cipt = malloc(sizeof(*cipt));
           if(!cipt)
             result = CURLE_OUT_OF_MEMORY;
           else {
-            cipt->certinfo =
-              (struct curl_slist **)calloc(cipf->num_of_certs + 1,
-                                           sizeof(struct curl_slist *));
+            cipt->certinfo = calloc(cipf->num_of_certs + 1,
+                                    sizeof(struct curl_slist *));
             if(!cipt->certinfo)
               result = CURLE_OUT_OF_MEMORY;
             else {
index 7a7f3c6459d6a35d2eb044c4e9b7c59f392d22a7..8085307f31ca39d0443c6a939ac19ba827db823a 100644 (file)
@@ -149,7 +149,7 @@ int main(int argsc, struct arguments *args)
 
   if(!exitcode) {
     /* Allocate space for parsed arguments. */
-    argv = (char **)malloc((argc + 1) * sizeof(*argv) + argsize);
+    argv = malloc((argc + 1) * sizeof(*argv) + argsize);
     if(!argv) {
       fputs("Memory allocation error\n", stderr);
       exitcode = -2;
index 54ca865264ddae74dad0f9aea66737fdb6b618d6..649d98a17daa8b772ff77364ff1912958f047abf 100644 (file)
@@ -86,7 +86,7 @@ int main(int argc, char **argv)
   }
 
   /* Allocate memory for the ASCII arguments and vector. */
-  argv = (char **)malloc((argc + 1) * sizeof(*argv) + bytecount);
+  argv = malloc((argc + 1) * sizeof(*argv) + bytecount);
 
   /* Build the vector and convert argument encoding. */
   outbuf = (char *)(argv + argc + 1);
index 053f741776190e42253e4d42795e87cf9720523b..89a4a9a1f205a88213cc9e356c711782dbb782a3 100755 (executable)
@@ -105,7 +105,7 @@ static voidpf zalloc_func(voidpf opaque, unsigned int items, unsigned int size)
 {
   (void)opaque;
   /* not a typo, keep it curlx_calloc() */
-  return (voidpf)curlx_calloc(items, size);
+  return curlx_calloc(items, size);
 }
 static void zfree_func(voidpf opaque, voidpf ptr)
 {
index d412a1ea88d70b18a8ecc076b5e772d6396ffced..d514e34966ef6e65fca927ffde1da43b3e48b9bd 100644 (file)
@@ -213,8 +213,7 @@ static size_t win_console(intptr_t fhnd, struct OutStruct *outs,
 
     /* grow the buffer if needed */
     if(len > global->term.len) {
-      wchar_t *buf = (wchar_t *)curlx_realloc(global->term.buf,
-                                              len * sizeof(wchar_t));
+      wchar_t *buf = curlx_realloc(global->term.buf, len * sizeof(wchar_t));
       if(!buf)
         return CURL_WRITEFUNC_ERROR;
       global->term.len = len;
index d93e8a68d0af9fbf15de1fb20359cfbaa1e67bfa..7e6d625cb2515bb4245edbc2d43c46731d6ab713 100644 (file)
@@ -33,7 +33,7 @@
 static struct tool_mime *tool_mime_new(struct tool_mime *parent,
                                        toolmimekind kind)
 {
-  struct tool_mime *m = (struct tool_mime *)curlx_calloc(1, sizeof(*m));
+  struct tool_mime *m = curlx_calloc(1, sizeof(*m));
 
   if(m) {
     m->kind = kind;
index dbf4ceea73d8c5c725851409dc7470ad6bcf9fb2..c4272cf567b1862ba73546cec898dac9ae77674f 100644 (file)
@@ -1709,9 +1709,7 @@ static int cb_timeout(CURLM *multi, long timeout_ms, void *userp)
 static struct contextuv *create_context(curl_socket_t sockfd,
                                         struct datauv *uv)
 {
-  struct contextuv *c;
-
-  c = (struct contextuv *)curlx_malloc(sizeof(*c));
+  struct contextuv *c = curlx_malloc(sizeof(*c));
 
   c->sockfd = sockfd;
   c->uv = uv;
index 7eb4931c5c2744b5d9e5b529fe4a5d7afd0d9fc4..01185bf0c329937d5af296c09c577998ef1e993e 100644 (file)
@@ -102,7 +102,7 @@ static CURLcode test_lib2302(const char *URL)
   global_init(CURL_GLOBAL_ALL);
 
   memset(&ws_data, 0, sizeof(ws_data));
-  ws_data.buf = (char *)curlx_calloc(LIB2302_BUFSIZE, 1);
+  ws_data.buf = curlx_calloc(LIB2302_BUFSIZE, 1);
   if(ws_data.buf) {
     curl = curl_easy_init();
     if(curl) {