linux指针初始化,从Linux内核4.8.0-53-通用Linux Mint中的IOCTL函数的不兼容指针初始化错误64位...

static struct file_operations my_fops =

{

.unlocked_ioctl = my_ioctl, error is here. I can not fix this.

};

注意:请忽略我的所有print_k。

请帮我解决这个问题。我感谢你们所有人。

这里是我的代码:

static long my_ioctl(struct file *f,unsigned int cm,unsigned long arg[b])

{

int re;

unsigned long arg[3];

switch (cm)

{

case H_ADD:

arg[2] = arg[0] + arg[1];

print_k("Driver:Calculating is complete,Result = %d \n",arg[2]);

break;

case H_SUB:

print_k ("Driver: Start ...\n");

arg[2] = arg[0] - arg[1];

print_k("Driver:Calculating is complete,Result = %d \n",arg[2]);

break;

case H_MULL:

print_k ("Driver: Start ...\n");

arg[2] = arg[0] * arg[1];

print_k("Driver:Calculating is complete,Result = %d \n",arg[2]);

break;

case H_DIV:

print_k ("Driver: Start ...\n");

arg[2] = arg[0]/arg[1];

print_k("Driver:Calculating is complete,Result = %d \n",arg[2]);

break;

default:

print_k ("Driver: I don't have this operation!\n");

re = -Er;

break;

}

return re;

}

static struct file_operations my_fops =

{

.unlocked_ioctl = my_ioctl,

};

+1

'static long my_ioctl(struct file * f,unsigned int cm,unsigned long arg [b])'是错误的。最后一个参数必须是'unsigned long arg'而不是'arg [b]'。如果你的最后一个参数被设计成一个指向某种数组的指针,你需要在*你的函数中相应地转换它*。 –

+3

我已修复格式(使代码可读) –

+1

嗨@BronislavElizavetin谢谢你的回答。我对最后一个论点感到抱歉。这是一个错误。它是unsigned long arg [],我做了一些测试,它的工作原理比内核版本4.8低。不幸的是,它不适用于我自己的Linux内核版本4.8 -64位。 –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值