[hipl-commit] [trunk] Rev 3565: removed constness from parameter that was modified afterwards

  • From: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 9 Feb 2010 12:23:33 +0200

Committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
Date: Tue Feb 09 11:20:41 2010 +0100
Revision: 3565
Revision-id: rene.hummen@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  removed constness from parameter that was modified afterwards
  
  It's really not a good idea to cast a const to a type with variable
  value just to be able to change that later on. Constness also supports
  documentation and has to allow a developer to rely on its semantics. If
  a const needs to be changed somewhere in the code, its constness should
  be removed throughout the whole codebase.

Modified:
  M  lib/tool/nlink.c
  M  lib/tool/nlink.h

=== modified file 'lib/tool/nlink.c'
--- lib/tool/nlink.c    2010-01-19 11:26:32 +0000
+++ lib/tool/nlink.c    2010-02-09 10:20:41 +0000
@@ -907,7 +907,7 @@
         }
 }
 
-int hip_iproute_get(struct rtnl_handle *rth, const struct in6_addr *src_addr,
+int hip_iproute_get(struct rtnl_handle *rth, struct in6_addr *src_addr,
                    const struct in6_addr *dst_addr, char *idev, char *odev,
                    int family, struct idxmap **idxmap)
 {
@@ -969,7 +969,7 @@
                addattr32(&req.n, sizeof(req), RTA_OIF, idx);
        }
        HIP_IFE((rtnl_talk(rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0), -1);
-       HIP_IFE(hip_parse_src_addr(&req.n, (struct in6_addr *) src_addr), -1);
+       HIP_IFE(hip_parse_src_addr(&req.n, src_addr), -1);
 
  out_err:
 

=== modified file 'lib/tool/nlink.h'
--- lib/tool/nlink.h    2010-01-19 11:26:32 +0000
+++ lib/tool/nlink.h    2010-02-09 10:20:41 +0000
@@ -88,7 +88,7 @@
 int hip_iproute_modify(struct rtnl_handle *rth,
                        int cmd, int flags, int family, char *ip,
                        char *dev);
-int hip_iproute_get(struct rtnl_handle *rth, const struct in6_addr *src_addr,
+int hip_iproute_get(struct rtnl_handle *rth, struct in6_addr *src_addr,
                        const struct in6_addr *dst_addr, char *idev, char *odev,
                        int family, struct idxmap **idxmap);

Other related posts:

  • » [hipl-commit] [trunk] Rev 3565: removed constness from parameter that was modified afterwards - Rene Hummen