util: New macro CONST_CAST.
authorBen Pfaff <blp@nicira.com>
Fri, 13 Jul 2012 23:00:29 +0000 (16:00 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 3 Aug 2012 20:33:13 +0000 (13:33 -0700)
commitebc56baa41db060b8783051e67b6fcbc148ebd60
tree6eccb5e9fe078abf361ed9bcc2d23f5a3ca79395
parente9c048007b113fdf05ca3ccbfa25d01c24f1da43
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>
25 files changed:
lib/bitmap.h
lib/dpif-linux.c
lib/dynamic-string.c
lib/hmap.h
lib/json.c
lib/list.c
lib/netdev-linux.c
lib/netdev.c
lib/netlink-socket.c
lib/ofpbuf.c
lib/ovsdb-data.c
lib/ovsdb-idl.c
lib/shash.c
lib/sset.h
lib/stp.c
lib/stream-ssl.c
lib/util.h
lib/vlog.c
ofproto/connmgr.c
ofproto/ofproto-dpif.c
ofproto/ofproto.c
ovsdb/ovsdb-server.c
ovsdb/row.c
ovsdb/transaction.c
tests/test-stp.c