hmap: Make HMAP_INITIALIZER a valid initializer for a const hmap.
authorBen Pfaff <blp@nicira.com>
Fri, 26 Apr 2013 18:10:53 +0000 (11:10 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 3 May 2013 20:29:46 +0000 (13:29 -0700)
Without this change, an initialization such as
    const struct hmap map = HMAP_INITIALIZER(&map);
yields a compiler warning "initialization discards qualifiers from pointer
target type".

Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/hmap.h

index 2867bfa..9b6d8c7 100644 (file)
@@ -65,7 +65,8 @@ struct hmap {
 };
 
 /* Initializer for an empty hash map. */
-#define HMAP_INITIALIZER(HMAP) { &(HMAP)->one, NULL, 0, 0 }
+#define HMAP_INITIALIZER(HMAP) \
+    { (struct hmap_node **const) &(HMAP)->one, NULL, 0, 0 }
 
 /* Initialization. */
 void hmap_init(struct hmap *);