[sheepdog] [PATCH 1/2] trivial: pass pointers of node_id for node_id_cmp() in node_eq()
mitake.hitoshi at lab.ntt.co.jp
Fri Nov 30 09:51:36 CET 2012
It seems that current node_eq() passes pointers of struct sd_node to
node_id_cmp() as parameters even though node_id_cmp() assumes the
parameters are pointers of node_id.
Currently, it works correctly because of the below 2 reasons:
1. types of parameters of node_id_cmp() are defined as void *.
It is for qsort()
2. nid of struct node_id is defined as the first member of the struct.
So this might not be a problem until the layout of struct sd_node is
changed. But I think that it is dangerous and should be fixed.
It seems that this problem is caused by a change in the commit
Cc: Liu Yuan <namei.unix at gmail.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
include/sheep.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/sheep.h b/include/sheep.h
index 5bedfa8..e0d63a4 100644
@@ -250,7 +250,7 @@ static inline int node_id_cmp(const void *a, const void *b)
static inline bool node_eq(const struct sd_node *a, const struct sd_node *b)
- return node_id_cmp(a, b) == 0;
+ return node_id_cmp(&a->nid, &b->nid) == 0;
static inline int vnode_cmp(const void *a, const void *b)
More information about the sheepdog