aboutsummaryrefslogtreecommitdiff
path: root/lib/netdev.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-07-13 16:00:29 -0700
committerBen Pfaff <blp@nicira.com>2012-08-03 13:33:13 -0700
commitebc56baa41db060b8783051e67b6fcbc148ebd60 (patch)
tree6eccb5e9fe078abf361ed9bcc2d23f5a3ca79395 /lib/netdev.c
parente9c048007b113fdf05ca3ccbfa25d01c24f1da43 (diff)
util: New macro CONST_CAST.
Casts are sometimes necessary. One common reason that they are necessary is for discarding a "const" qualifier. However, this can impede maintenance: if the type of the expression being cast changes, then the presence of the cast can hide a necessary change in the code that does the cast. Using CONST_CAST, instead of a bare cast, makes these changes visible. Inspired by my own work elsewhere: http://git.savannah.gnu.org/cgit/pspp.git/tree/src/libpspp/cast.h#n80 Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/netdev.c')
-rw-r--r--lib/netdev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/netdev.c b/lib/netdev.c
index ac98cb52..394d8957 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -847,7 +847,7 @@ do_update_flags(struct netdev *netdev, enum netdev_flags off,
int
netdev_get_flags(const struct netdev *netdev_, enum netdev_flags *flagsp)
{
- struct netdev *netdev = (struct netdev *) netdev_;
+ struct netdev *netdev = CONST_CAST(struct netdev *, netdev_);
return do_update_flags(netdev, 0, 0, flagsp, false);
}