diff options
author | Ben Pfaff <blp@nicira.com> | 2012-07-13 16:00:29 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-08-03 13:33:13 -0700 |
commit | ebc56baa41db060b8783051e67b6fcbc148ebd60 (patch) | |
tree | 6eccb5e9fe078abf361ed9bcc2d23f5a3ca79395 /lib/bitmap.h | |
parent | e9c048007b113fdf05ca3ccbfa25d01c24f1da43 (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/bitmap.h')
-rw-r--r-- | lib/bitmap.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/bitmap.h b/lib/bitmap.h index 47b77e73..89804962 100644 --- a/lib/bitmap.h +++ b/lib/bitmap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ static inline unsigned long * bitmap_unit__(const unsigned long *bitmap, size_t offset) { - return (unsigned long *) &bitmap[offset / BITMAP_ULONG_BITS]; + return CONST_CAST(unsigned long *, &bitmap[offset / BITMAP_ULONG_BITS]); } static inline unsigned long |