[hipl-dev] [Branch ~hipl-core/hipl/trunk] Rev 5155: Remove pointless void* casts of memcpy/memcmp arguments.

  • From: noreply@xxxxxxxxxxxxx
  • To: HIPL core team <hipl-dev@xxxxxxxxxxxxx>
  • Date: Mon, 15 Nov 2010 13:04:33 -0000

------------------------------------------------------------
revno: 5155
committer: Diego Biurrun <diego@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-11-15 14:01:56 +0100
message:
  Remove pointless void* casts of memcpy/memcmp arguments.
  
  memcpy/memcmp take (const) void* arguments, but void* is compatible with
  any pointer type in C, so there is no need to cast the arguments.
modified:
  hipd/hiprelay.c
  lib/core/prefix.c


--
lp:hipl
https://code.launchpad.net/~hipl-core/hipl/trunk

Your team HIPL core team is subscribed to branch lp:hipl.
To unsubscribe from this branch go to 
https://code.launchpad.net/~hipl-core/hipl/trunk/+edit-subscription
=== modified file 'hipd/hiprelay.c'
--- hipd/hiprelay.c     2010-10-20 03:38:26 +0000
+++ hipd/hiprelay.c     2010-11-15 13:01:56 +0000
@@ -69,7 +69,7 @@
  *
  * <pre>
  * hip_relrec_t dummy, *fetch_record = NULL;
- * memcpy((char *)&(dummy.hit_r), hit, sizeof(hit));
+ * memcpy(&dummy.hit_r, hit, sizeof(hit));
  * fetch_record = hip_relht_get(&dummy);
  * if (fetch_record != NULL) {
  *     // Do something with the record.
@@ -79,7 +79,7 @@
  * <li>Deleting a relay record. A dummy record can be used:
  * <pre>
  * hip_relrec_t dummy;
- * memcpy((char *) &(dummy.hit_r), hit, sizeof(hit));
+ * memcpy(&dummy.hit_r, hit, sizeof(hit));
  * hip_relht_rec_free(&dummy);
  * </pre>
  * </li>

=== modified file 'lib/core/prefix.c'
--- lib/core/prefix.c   2010-10-18 17:44:31 +0000
+++ lib/core/prefix.c   2010-11-15 13:01:56 +0000
@@ -383,24 +383,22 @@
 
 int ipv4_addr_cmp(const struct in_addr *a1,
                                 const struct in_addr *a2) {
-    return memcmp((const char *) a1, (const char *) a2,
-                  sizeof(struct in_addr));
+    return memcmp(a1, a2, sizeof(struct in_addr));
 }
 
 void ipv4_addr_copy(struct in_addr *a1,
                                   const struct in_addr *a2) {
-    memcpy((char *) a1, (const char *) a2, sizeof(struct in_addr));
+    memcpy(a1, a2, sizeof(struct in_addr));
 }
 
 int ipv6_addr_cmp(const struct in6_addr *a1,
                   const struct in6_addr *a2) {
-    return memcmp((const char *) a1, (const char *) a2,
-                  sizeof(struct in6_addr));
+    return memcmp(a1, a2, sizeof(struct in6_addr));
 }
 
 void ipv6_addr_copy(struct in6_addr *a1,
                const struct in6_addr *a2) {
-    memcpy((char *) a1, (const char *) a2, sizeof(struct in6_addr));
+    memcpy(a1, a2, sizeof(struct in6_addr));
 }
 
 int ipv6_addr_any(const struct in6_addr *a) {

Other related posts: