[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Error compiling a module



Dear Friends!:

I've been compiling this code: https://github.com/bsalunke/SysCallInterceptModule
and when executing make or ./compile.sh, it's report this error:

/MyPath/SysCallInterceptModule-master/Module/SysCallInterceptModule.c:244:12: error: initialization of ‘ssize_t (*)(struct file *, char *, size_t,  loff_t *)’ {aka ‘long int (*)(struct file *, char *, long unsigned int,  long long int *)’} from incompatible pointer type ‘int (*)(struct file *, char *, size_t,  loff_t)’ {aka ‘int (*)(struct file *, char *, long unsigned int,  long long int)’} [-Werror=incompatible-pointer-types]

The error stops being reported if I replace line 244 with:
   .read = (ssize_t (*)(struct file *, char *, size_t,  loff_t *)) &device_read,

But was that really necessary?  I went through all the source code and couldn't find any other struct file_operations with a read function defined this way:

int (*)(struct file *, char *, long unsigned int,  long long int)’}

The error also didn't disappear if I declared the read function on line 147 as:

static ssize_t  device_read(struct file* filep, char* buffer, size_t len, loff_t offset){

I appreciate any explanation on why this occurs and / or any different solutions to avoid the error. Personally, it doesn't seem very logical to me.




Reply to: