Skip to content
Advertisement

Error initialization from incompatible pointer of IOCTL function in Linux kernel 4.8.0-53-generic Linux Mint 64 bit

I’ve got an error while writing a char device module, using Ioctl command.

JavaScript

Note: please ignore all my print_k.

Please, help me fix this. My thanks to all of you.

Here is my code :

JavaScript

Advertisement

Answer

The third argument unsigned long arg[b] in the function prototype is dubious. It should be simply unsigned long arg even if it’s supposed to be a pointer. It’s easy to cast it to the type of interest within the function body.

..the optional arg argument is passed in the form of an unsigned long, regardless of whether it was given by the user as an integer or a pointer.

( Linux Device Drivers 3, Chapter 6, Section 1 )

Also, it’s wrong to declare a variable within the function body which has the same name as one of the arguments. Please choose another name for unsigned long arg[3];.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement