编译时的一个警告,INIT_WORK的,在线等

tananade 2011-05-02 10:09:01
447 INIT_WORK(&stuff->work, sculld_do_deferred_op);

5 main.c|447| warning: assignment from incompatible pointer type

参数的声明和定义如下:

struct async_work {
struct kiocb *iocb;
int result;
struct work_struct work;
};

struct async_work *stuff;

static void sculld_do_deferred_op(void *p)

不知道怎么回事?明明类型都对阿,怎么说指针类型不对呢?
求点拨
...全文
195 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
念茜 2011-07-17
  • 打赏
  • 举报
回复
work_struct里的那个data已经不是参数了,如果需要传参数,在你自己的结构体里加上个param,然后container_of过去最好。
hero1985 2011-07-06
  • 打赏
  • 举报
回复
readv() 和 writev() 方法,在file_operations 结构中,已经被移除,以有利于aio_readv() 和 aio_writev() (原型被改变了)。请看这篇文章:http://lwn.net/Articles/202449/。


google from:
http://www.chinaunix.net/jh/4/1040681.html
hero1985 2011-07-06
  • 打赏
  • 举报
回复
static void sculld_do_deferred_op(void *p)
====>>
static void sculld_do_deferred_op((struct work_struct *)p)
windman521 2011-06-11
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 tananade 的回复:]

唉,居然还是没有人.....
第一个问题我已经找到了
static void sculld_do_deferred_op(void *p)
参数要为
static void sculld_do_deferred_op(struct work_struct *p)
主要是INIT_WORK由3个参数变为了2个参数,void *data参数没有了,合并到work_struct里面了
所以……
[/Quote]

我帮你顶
tananade 2011-05-03
  • 打赏
  • 举报
回复
唉,居然还是没有人.....
第一个问题我已经找到了
static void sculld_do_deferred_op(void *p)
参数要为
static void sculld_do_deferred_op(struct work_struct *p)
主要是INIT_WORK由3个参数变为了2个参数,void *data参数没有了,合并到work_struct里面了
所以只能通过这种方法传递给处理函数
具体大家看看这个网站吧
http://ubuntuforums.org/showthread.php?t=441180
tananade 2011-05-02
  • 打赏
  • 举报
回复
居然没有人..........

还一个问题,我的内核源码是2.6.32的
突然发现struct file_operations好像有了改变?本人菜鸟,有很多不理解之处


linux/fs.h

/*
* NOTE:
* read, write, poll, fsync, readv, writev, unlocked_ioctl and compat_ioctl
* can be called without the big kernel lock held in all filesystems.
*/
struct file_operations {
struct module *owner;
loff_t (*llseek) (struct file *, loff_t, int);
ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
int (*open) (struct inode *, struct file *);
int (*flush) (struct file *, fl_owner_t id);
int (*release) (struct inode *, struct file *);
int (*fsync) (struct file *, struct dentry *, int datasync);
int (*aio_fsync) (struct kiocb *, int datasync);
int (*fasync) (int, struct file *, int);
int (*lock) (struct file *, int, struct file_lock *);
ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
int (*check_flags)(int);
int (*flock) (struct file *, int, struct file_lock *);
ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
int (*setlease)(struct file *, long, struct file_lock **);
};


这file_operation结构里面都没有了readv,writev,为什么上面NOTE里面写readv,writev可以在没有大内核锁的情况下在任何文件系统中使用?

还有
ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
里面的参数是不是发生了变化阿,ldd3里面写的是
ssize_t (*aio_read) (struct kiocb *, char __user *, size_t, loff_t);
ssize_t (*aio_write) (struct kiocb *, const char __user *, size_t, loff_t*);

而现在的aio_read和aio_write的参数和以前的readv,writev一样

求解啊?

实在是困惑了,以前的代码都不知道怎么改了

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧