0x90
0x90

Reputation: 41012

Why do I get this compilation warning in a kernel module with ioctl?

When defining t_ioctl like this, I get no warning:

long t_ioctl(struct file *filep, unsigned int cmd, unsigned long input){

When defining t_ioctl like this:

static long t_ioctl(struct file *filep, unsigned int cmd, unsigned long input){

I get the warning:

warning: 't_ioctl' defined but not used

but when it is up to t_read or t_write the static and non static function declaration doesn't cause the warning. e.g:

static ssize_t t_read(struct file *filp, char __user * buf, size_t count, loff_t * f_pos);

Why do I get the warning in one case and not the other?

Upvotes: 0

Views: 863

Answers (1)

Lance Richardson
Lance Richardson

Reputation: 4610

Most likely you have a definition like this in the same file:

static struct file_operations fileops = {
    .read     = t_read,
    .write    = t_write,
    /* etc. ... */
};

And you're missing

.compat_ioctl = t_ioctl, /* or .ioctl/.unlocked_ioctl, depending on version etc. */

Upvotes: 5

Related Questions