Skip to contentSkip to conversation

libbpf: fix some typo of hashmap init

PATCH Superseded John Sanpe 2 participants 2 messages Jul 4, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

John Sanpe

author
#0 lore raw

PATCH 1/1 libbpf: fix some typo of hashmap init

rename macro parameters to prevent replacing struct members of hashmap

---
 tools/lib/bpf/hashmap.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/lib/bpf/hashmap.h +8 -8
index 0a5bf1937a7c..bae3feaf29d0 100644
@@ -80,14 +80,14 @@ struct hashmap {
 	size_t sz;
 };
 
-#define HASHMAP_INIT(hash_fn, equal_fn, ctx) {	\
-	.hash_fn = (hash_fn),			\
-	.equal_fn = (equal_fn),			\
-	.ctx = (ctx),				\
-	.buckets = NULL,			\
-	.cap = 0,				\
-	.cap_bits = 0,				\
-	.sz = 0,				\
+#define HASHMAP_INIT(_hash_fn, _equal_fn, _ctx) {	\
+	.hash_fn = (_hash_fn),				\
+	.equal_fn = (_equal_fn),			\
+	.ctx = (_ctx),					\
+	.buckets = NULL,				\
+	.cap = 0,					\
+	.cap_bits = 0,					\
+	.sz = 0,					\
 }
 
 void hashmap__init(struct hashmap *map, hashmap_hash_fn hash_fn,
Signature · 1 line
2.40.1
maintainer
#1 lore raw
Quoted 25 lines · John Sanpe

rename macro parameters to prevent replacing struct members of hashmap

---
  tools/lib/bpf/hashmap.h | 16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)
tools/lib/bpf/hashmap.h +1 -8
index 0a5bf1937a7c..bae3feaf29d0 100644
@@ -80,14 +80,14 @@ struct hashmap {
  	size_t sz;
  };
 
-#define HASHMAP_INIT(hash_fn, equal_fn, ctx) {	\
-	.hash_fn = (hash_fn),			\
-	.equal_fn = (equal_fn),			\
-	.ctx = (ctx),				\
-	.buckets = NULL,			\
-	.cap = 0,				\
-	.cap_bits = 0,				\
-	.sz = 0,				\
+#define HASHMAP_INIT(_hash_fn, _equal_fn, _ctx) {	\

tools/lib/bpf/hashmap.h struct hashmap { · line 93

Quoted 10 lines
tools/lib/bpf/hashmap.h +7 -0
+	.hash_fn = (_hash_fn),				\
+	.equal_fn = (_equal_fn),			\
+	.ctx = (_ctx),					\
+	.buckets = NULL,				\
+	.cap = 0,					\
+	.cap_bits = 0,					\
+	.sz = 0,					\
  }
 
  void hashmap__init(struct hashmap *map, hashmap_hash_fn hash_fn,

Please send a v2 and just remove the whole HASHMAP_INIT. It's not used anywhere in libbpf.