Re: [PATCH] Staging : android: Struct file_operations should be const
From: Joe Perches
Date: Mon Feb 07 2022 - 01:41:03 EST
On Mon, 2022-02-07 at 00:17 -0300, Leonardo Araujo wrote:
> From: "Leonardo Araujo" <leonardo.aa88@xxxxxxxxx>
>
> WARNING: struct file_operations should normally be const
Always compile the files modified by a patch before you send it out.
[]
> diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
[]
> @@ -377,7 +377,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, unsigned long addr,
>
> static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
> {
> - static struct file_operations vmfile_fops;
> + static const struct file_operations vmfile_fops;
> struct ashmem_area *asma = file->private_data;
> int ret = 0;
>
<apply patch>
$ make allyesconfig
$ make drivers/staging/android/ashmem.o
[...]
CC drivers/staging/android/ashmem.o
drivers/staging/android/ashmem.c: In function ‘ashmem_mmap’:
drivers/staging/android/ashmem.c:431:37: error: assignment of read-only variable ‘vmfile_fops’
431 | vmfile_fops = *vmfile->f_op;
| ^
drivers/staging/android/ashmem.c:432:42: error: assignment of member ‘mmap’ in read-only object
432 | vmfile_fops.mmap = ashmem_vmfile_mmap;
| ^
drivers/staging/android/ashmem.c:433:55: error: assignment of member ‘get_unmapped_area’ in read-only object
433 | vmfile_fops.get_unmapped_area =
| ^
make[3]: *** [scripts/Makefile.build:289: drivers/staging/android/ashmem.o] Error 1
make[2]: *** [scripts/Makefile.build:572: drivers/staging/android] Error 2
make[1]: *** [scripts/Makefile.build:572: drivers/staging] Error 2
make: *** [Makefile:1965: drivers] Error 2