[hipl-commit] [trunk] Rev 4290: Do not cast the result of HIP_MALLOC.

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Thu, 15 Apr 2010 20:09:35 +0300

Committer: Diego Biurrun <diego@xxxxxxxxxx>
Date: 15/04/2010 at 20:09:35
Revision: 4290
Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Do not cast the result of HIP_MALLOC.
  
  HIP_MALLOC is just a thin wrapper around malloc, which returns void*.
  void* is compatible with any other pointer type.

Modified:
  M  firewall/cache.c
  M  firewall/firewalldb.c
  M  firewall/proxy.c
  M  hipd/cookie.c
  M  hipd/hadb.c
  M  hipd/hidb.c
  M  hipd/keymat.c
  M  lib/core/builder.c
  M  lib/core/hostid.c

=== modified file 'firewall/cache.c'
--- firewall/cache.c    2010-04-13 15:42:49 +0000
+++ firewall/cache.c    2010-04-15 17:06:57 +0000
@@ -33,7 +33,7 @@
     firewall_cache_hl_t *entry = NULL;
     int err = 0;
 
-    HIP_IFEL(!(entry = (firewall_cache_hl_t *) 
HIP_MALLOC(sizeof(firewall_cache_hl_t), 0)),
+    HIP_IFEL(!(entry = HIP_MALLOC(sizeof(firewall_cache_hl_t), 0)),
              -ENOMEM, "No memory available for firewall database entry\n");
     memset(entry, 0, sizeof(*entry));
 out_err:

=== modified file 'firewall/firewalldb.c'
--- firewall/firewalldb.c       2010-04-09 15:20:38 +0000
+++ firewall/firewalldb.c       2010-04-15 17:06:57 +0000
@@ -100,7 +100,7 @@
 {
     firewall_hl_t *entry = NULL;
     int err              = 0;
-    HIP_IFEL(!(entry = (firewall_hl_t *) HIP_MALLOC(sizeof(firewall_hl_t), 0)),
+    HIP_IFEL(!(entry = HIP_MALLOC(sizeof(firewall_hl_t), 0)),
              -ENOMEM, "No memory available for firewall database entry\n");
     memset(entry, 0, sizeof(*entry));
 out_err:

=== modified file 'firewall/proxy.c'
--- firewall/proxy.c    2010-04-13 16:39:45 +0000
+++ firewall/proxy.c    2010-04-15 17:06:57 +0000
@@ -676,7 +676,7 @@
         if (protocol == IPPROTO_TCP) {
             hip_raw_sock = hip_proxy_raw_sock_tcp_v4;
             sa_size      = sizeof(struct sockaddr_in);
-            msg          = (uint8_t *) HIP_MALLOC((len - sizeof(struct 
ip6_hdr) + sizeof(struct ip)), 0);
+            msg          = HIP_MALLOC((len - sizeof(struct ip6_hdr) + 
sizeof(struct ip)), 0);
             memset(msg, 0, (len - sizeof(struct ip6_hdr) + sizeof(struct ip)));
 
             HIP_DEBUG_INADDR("ipv4 src address  inbound: ", &src4->sin_addr);
@@ -691,7 +691,7 @@
         if (protocol == IPPROTO_UDP) {
             hip_raw_sock = hip_proxy_raw_sock_udp_v4;
             sa_size      = sizeof(struct sockaddr_in);
-            msg          = (uint8_t *) HIP_MALLOC((len - sizeof(struct 
ip6_hdr) + sizeof(struct ip)), 0);
+            msg          = HIP_MALLOC((len - sizeof(struct ip6_hdr) + 
sizeof(struct ip)), 0);
             memset(msg, 0, (len - sizeof(struct ip6_hdr) + sizeof(struct ip)));
 
             HIP_DEBUG_INADDR("ipv4 src address  inbound: ", &src4->sin_addr);
@@ -706,7 +706,7 @@
         if (protocol == IPPROTO_ICMP) {
             hip_raw_sock = hip_proxy_raw_sock_icmp_v4;
             sa_size      = sizeof(struct sockaddr_in);
-            msg          = (uint8_t *) HIP_MALLOC((len - sizeof(struct 
ip6_hdr) + sizeof(struct ip)), 0);
+            msg          = HIP_MALLOC((len - sizeof(struct ip6_hdr) + 
sizeof(struct ip)), 0);
             memset(msg, 0, (len - sizeof(struct ip6_hdr) + sizeof(struct ip)));
 
             HIP_DEBUG_INADDR("ipv4 src address  inbound: ", &src4->sin_addr);
@@ -723,7 +723,7 @@
             HIP_DEBUG("Using IPv6 raw socket (TCP)\n");
             hip_raw_sock = hip_proxy_raw_sock_tcp_v6;
             sa_size      = sizeof(struct sockaddr_in6);
-            msg          = (uint8_t *) HIP_MALLOC(len, 0);
+            msg          = HIP_MALLOC(len, 0);
             //memset(msg, 0, len);
             tcp->check   =  htons(0);
             tcp->check   = ipv6_checksum(IPPROTO_TCP, &(src6->sin6_addr), 
&(dst6->sin6_addr), tcp, (len - sizeof(struct ip6_hdr)));           //checksum 
is ok for ipv6
@@ -734,7 +734,7 @@
             HIP_DEBUG("Using IPv6 raw socket (UDP)\n");
             hip_raw_sock = hip_proxy_raw_sock_udp_v6;
             sa_size      = sizeof(struct sockaddr_in6);
-            msg          = (uint8_t *) HIP_MALLOC(len, 0);
+            msg          = HIP_MALLOC(len, 0);
             //memset(msg, 0, len);
             udp->check   =  htons(0);
             udp->check   = ipv6_checksum(IPPROTO_UDP, &(src6->sin6_addr), 
&(dst6->sin6_addr), udp, (len - sizeof(struct ip6_hdr)));           //checksum 
is ok for ipv6
@@ -745,7 +745,7 @@
             HIP_DEBUG("Using IPv6 raw socket (ICMPV6)\n");
             hip_raw_sock        = hip_proxy_raw_sock_icmp_v6;
             sa_size             = sizeof(struct sockaddr_in6);
-            msg                 = (uint8_t *) HIP_MALLOC(len, 0);
+            msg                 = HIP_MALLOC(len, 0);
             //memset(msg, 0, len);
             icmpv6->icmp6_cksum =  htons(0);
             icmpv6->icmp6_cksum = ipv6_checksum(IPPROTO_ICMPV6, 
&(src6->sin6_addr), &(dst6->sin6_addr), icmpv6, (len - sizeof(struct 
ip6_hdr)));             //checksum is ok for ipv6
@@ -1130,7 +1130,7 @@
                 err = 0;
             } else {
                 packet_length = m->data_len - hdr_size;
-                msg           = (uint8_t *) HIP_MALLOC(packet_length, 0);
+                msg           = HIP_MALLOC(packet_length, 0);
                 memcpy(msg, (m->payload) + hdr_size,
                        packet_length);
 

=== modified file 'hipd/cookie.c'
--- hipd/cookie.c       2010-04-13 15:52:03 +0000
+++ hipd/cookie.c       2010-04-15 17:06:57 +0000
@@ -254,8 +254,8 @@
 {
     struct hip_r1entry *err;
 
-    HIP_IFE(!(err = (struct hip_r1entry *) HIP_MALLOC(sizeof(struct 
hip_r1entry) * HIP_R1TABLESIZE,
-                                                      0)), NULL);
+    HIP_IFE(!(err = HIP_MALLOC(sizeof(struct hip_r1entry) * HIP_R1TABLESIZE, 
0)),
+            NULL);
     memset(err, 0, sizeof(struct hip_r1entry) * HIP_R1TABLESIZE);
 
 out_err:

=== modified file 'hipd/hadb.c'
--- hipd/hadb.c 2010-04-15 16:57:50 +0000
+++ hipd/hadb.c 2010-04-15 17:06:57 +0000
@@ -961,7 +961,7 @@
             /*Adding the peer address to the entry->peer_addr_list_to_be_added
              *                          * So that later aftre base exchange it 
can be transfered to
              *                                                   * SPI OUT's 
peer address list*/
-            a_item = (struct hip_peer_addr_list_item *) 
HIP_MALLOC(sizeof(struct hip_peer_addr_list_item), 0);
+            a_item = HIP_MALLOC(sizeof(struct hip_peer_addr_list_item), 0);
             if (!a_item) {
                 HIP_ERROR("item HIP_MALLOC failed\n");
                 err = -ENOMEM;
@@ -982,7 +982,7 @@
         goto out_err;
     }
 
-    a_item = (struct hip_peer_addr_list_item *) HIP_MALLOC(sizeof(struct 
hip_peer_addr_list_item), GFP_KERNEL);
+    a_item = HIP_MALLOC(sizeof(struct hip_peer_addr_list_item), GFP_KERNEL);
     if (!a_item) {
         HIP_ERROR("item HIP_MALLOC failed\n");
         err = -ENOMEM;
@@ -1098,7 +1098,7 @@
 
     entry->dh_shared_key_len = 0;
     /** @todo reuse pointer, no HIP_MALLOC */
-    entry->dh_shared_key     = (char *) HIP_MALLOC(ctx->dh_shared_key_len, 
GFP_ATOMIC);
+    entry->dh_shared_key     = HIP_MALLOC(ctx->dh_shared_key_len, GFP_ATOMIC);
     if (!entry->dh_shared_key) {
         HIP_ERROR("entry dh_shared HIP_MALLOC failed\n");
         err = -ENOMEM;

=== modified file 'hipd/hidb.c'
--- hipd/hidb.c 2010-04-13 11:33:54 +0000
+++ hipd/hidb.c 2010-04-15 17:06:57 +0000
@@ -299,9 +299,8 @@
 
     HIP_ASSERT(&lhi->hit != NULL);
     _HIP_DEBUG("host id algo:%d \n", hip_get_host_id_algo(host_id));
-    HIP_IFEL(!(id_entry = (struct hip_host_id_entry *) 
HIP_MALLOC(sizeof(struct hip_host_id_entry),
-                                                                  0)), -ENOMEM,
-             "No memory available for host id\n");
+    HIP_IFEL(!(id_entry = HIP_MALLOC(sizeof(struct hip_host_id_entry), 0)),
+             -ENOMEM, "No memory available for host id\n");
     memset(id_entry, 0, sizeof(struct hip_host_id_entry));
 
     ipv6_addr_copy(&id_entry->lhi.hit, &lhi->hit);

=== modified file 'hipd/keymat.c'
--- hipd/keymat.c       2010-04-09 16:24:44 +0000
+++ hipd/keymat.c       2010-04-15 17:06:57 +0000
@@ -43,7 +43,7 @@
         requiredmem = kij_len + 2 * sizeof(struct in6_addr) +
                       sizeof(uint8_t) + 2 * sizeof(uint64_t);
     }
-    buffer = (uint8_t *) HIP_MALLOC(requiredmem, 0);
+    buffer = HIP_MALLOC(requiredmem, 0);
     if (!buffer) {
         HIP_ERROR("Out of memory\n");
         return buffer;
@@ -327,7 +327,7 @@
     _HIP_DEBUG("need %d bytes more data\n", key_len - copied);
 
     tmp_data_len = kij_len + HIP_AH_SHA_LEN + 1;
-    tmp_data     = (uint8_t *) HIP_MALLOC(tmp_data_len, 0);
+    tmp_data     = HIP_MALLOC(tmp_data_len, 0);
     if (!tmp_data) {
         HIP_ERROR("HIP_MALLOC failed\n");
         err = -ENOMEM;

=== modified file 'lib/core/builder.c'
--- lib/core/builder.c  2010-04-14 18:51:38 +0000
+++ lib/core/builder.c  2010-04-15 17:06:57 +0000
@@ -2089,7 +2089,7 @@
     if (rem) {
         HIP_DEBUG("Adjusting param size to AES block size\n");
 
-        param_padded = (char *) HIP_MALLOC(param_len + rem, 0);
+        param_padded = HIP_MALLOC(param_len + rem, 0);
         if (!param_padded) {
             err = -ENOMEM;
             goto out_err;

=== modified file 'lib/core/hostid.c'
--- lib/core/hostid.c   2010-04-08 16:02:42 +0000
+++ lib/core/hostid.c   2010-04-15 17:06:57 +0000
@@ -175,7 +175,7 @@
 
     /* Allocate enough space for host id; there will be 20 bytes extra
      * to avoid hassle with padding. */
-    host_id_pub = (struct hip_host_id *) HIP_MALLOC(total_len, 0);
+    host_id_pub = HIP_MALLOC(total_len, 0);
     HIP_IFE(!host_id_pub, -EFAULT);
     memset(host_id_pub, 0, total_len);

Other related posts:

  • » [hipl-commit] [trunk] Rev 4290: Do not cast the result of HIP_MALLOC. - Diego Biurrun