gpt4 book ai didi

linux - 调用 netif_napi_add 时为 "makes pointer from integer without a cast"

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:24:59 24 4
gpt4 key购买 nike

netif_napi_add 的语法是:

netif_napi_add(struct net_device *dev, struct napi_struct *napi,int (*poll)(struct napi_struct *, int), int weight)

用于初始化napi结构。问题是,当我将函数用作:

netif_napi_add(wdev,rnapi,rrpoll(rnapi,20),16);

它给我一个编译警告:

warning: passing argument 3 of ‘netif_napi_add’ makes pointer from integer without a cast
/usr/src/linux-2.6.34.10-0.6/include/linux/netdevice.h:1089:6: note: expected ‘int (*)(struct napi_struct *, int)’ but argument is of type ‘int’

我该如何解决?

最佳答案

netif_napi_add 的第三个参数,int (*poll)(struct napi_struct *, int),是一个 function pointer名为 poll 的函数,该函数采用 struct napi_struct *int 并返回 int。您直接调用 rrpoll 并将其返回值(int)传递给 netif_napi_add,而不是函数指针。您可能只想将 rrpoll 直接传递给函数:

netif_napi_add(wdev, rnapi, &rrpoll, 16);

关于linux - 调用 netif_napi_add 时为 "makes pointer from integer without a cast",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9307114/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com