编译libconhash的时候出现了一些类型问题的警告:
conhash_util.c: In function ‘conhash_get_vnodes’:
conhash_util.c:31:2: warning: passing argument 1 of ‘util_rbtree_mid_travel’ discards ‘const’ qualifier from pointer target type [enabled by default]
util_rbtree.h:112:6: note: expected ‘struct util_rbtree_t *’ but argument is of type ‘const struct util_rbtree_t *’
gcc -I. -I. -c conhash.c -o bin/conhash.o
conhash.c: In function ‘conhash_lookup’:
conhash.c:80:2: warning: passing argument 1 of ‘util_rbtree_lookup’ discards ‘const’ qualifier from pointer target type [enabled by default]
util_rbtree.h:74:21: note: expected ‘struct util_rbtree_t *’ but argument is of type ‘const struct util_rbtree_t *’
util_rbtree_mid_travel函数声明如下:
void util_rbtree_mid_travel(util_rbtree_t *rbtree, void(*opera)(util_rbtree_node_t *, void *), void *data);
调用时是如下形式的:
util_rbtree_mid_travel(&(conhash->vnode_tree), __get_vnodes, &vnodes);
因为&取址运算符的返回值是const的常指针,因此才出现了上面的警告。
修改函数util_rbtree_mid_travel的原先如下,即第一个参数为常指针:
void util_rbtree_mid_travel(const util_rbtree_t *rbtree, void(*opera)(util_rbtree_node_t *, void *), void *data);
阅读(4270) | 评论(0) | 转发(0) |