[PATCH] staging: android: ashmem: Declared file operation with const keyword Warning found by checkpatch.pl script.

shaikh kamal posted 1 patch 4 years, 3 months ago
drivers/staging/android/ashmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] staging: android: ashmem: Declared file operation with const keyword Warning found by checkpatch.pl script.
Posted by shaikh kamal 4 years, 3 months ago
Signed-off-by: shaikh kamal <shaikhkamal2012@gmail.com>
---
 drivers/staging/android/ashmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index ddbde3f8430e..4c6b420fbf4d 100644
--- 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;
 
-- 
2.17.1
Re: [PATCH] staging: android: ashmem: Declared file operation with const keyword Warning found by checkpatch.pl script.
Posted by Joe Perches 4 years, 3 months ago
On Sun, 2022-03-13 at 03:11 +0530, shaikh kamal wrote:
[]
> 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;

Make sure to compile any files modified by your suggested patches
_before_ sending the patches.
Re: [PATCH] staging: android: ashmem: Declared file operation with const keyword Warning found by checkpatch.pl script.
Posted by shaikh kamaluddin 4 years, 3 months ago
On 3/13/2022 2:57 AM, Joe Perches wrote:
> On Sun, 2022-03-13 at 03:11 +0530, shaikh kamal wrote:
> []
>> 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;
> 
> Make sure to compile any files modified by your suggested patches
> _before_ sending the patches.
> 
> 

Thanks for your suggestion, Kernel build is failing.
Re: [PATCH] staging: android: ashmem: Declared file operation with const keyword Warning found by checkpatch.pl script.
Posted by Pavel Skripkin 4 years, 3 months ago
Hi Shaikh,

On 3/12/22 23:41, shaikh kamal wrote:
> Signed-off-by: shaikh kamal <shaikhkamal2012@gmail.com>
> ---
>   drivers/staging/android/ashmem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
> index ddbde3f8430e..4c6b420fbf4d 100644
> --- 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;
>   

Are you sure this patch compiles? vmfile_fops is overrided few lines below

odd checkpatch.pl warning...




With regards,
Pavel Skripkin
Re: [PATCH] staging: android: ashmem: Declared file operation with const keyword Warning found by checkpatch.pl script.
Posted by shaikh kamaluddin 4 years, 3 months ago
On 3/13/2022 3:13 AM, Pavel Skripkin wrote:
> Hi Shaikh,
> 
> On 3/12/22 23:41, shaikh kamal wrote:
>> Signed-off-by: shaikh kamal <shaikhkamal2012@gmail.com>
>> ---
>>   drivers/staging/android/ashmem.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/android/ashmem.c 
>> b/drivers/staging/android/ashmem.c
>> index ddbde3f8430e..4c6b420fbf4d 100644
>> --- 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;
> 
> Are you sure this patch compiles? vmfile_fops is overrided few lines below
> 
> odd checkpatch.pl warning...
> 
> 
> 
> 
> With regards,
> Pavel Skripkin

Thank you,yes vmfile_fops is overrided in below code.
Building the kernel - make -j4,
drivers/staging/android/ashmem.c: In function ‘ashmem_mmap’:
drivers/staging/android/ashmem.c:431:16: error: assignment of read-only 
variable ‘vmfile_fops’
     vmfile_fops = *vmfile->f_op;
                 ^
drivers/staging/android/ashmem.c:432:21: error: assignment of member 
‘mmap’ in read-only object
     vmfile_fops.mmap = ashmem_vmfile_mmap;
                      ^
drivers/staging/android/ashmem.c:433:34: error: assignment of member 
‘get_unmapped_area’ in read-only object
     vmfile_fops.get_unmapped_area =
                                   ^
scripts/Makefile.build:288: recipe for target 
'drivers/staging/android/ashmem.o' failed
make[3]: *** [drivers/staging/android/ashmem.o] Error 1
scripts/Makefile.build:550: recipe for target 'drivers/staging/android' 
failed
make[2]: *** [drivers/staging/android] Error 2
scripts/Makefile.build:550: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:1831: recipe for target 'drivers' failed


Thanks & Regards,
Shaikh Kamaluddin
Re: [PATCH] staging: android: ashmem: Declared file operation with const keyword Warning found by checkpatch.pl script.
Posted by Greg Kroah-Hartman 4 years, 3 months ago
On Sun, Mar 13, 2022 at 02:11:27AM +0530, shaikh kamal wrote:
> Signed-off-by: shaikh kamal <shaikhkamal2012@gmail.com>
> ---
>  drivers/staging/android/ashmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
> index ddbde3f8430e..4c6b420fbf4d 100644
> --- 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;
>  
> -- 
> 2.17.1
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch breaks the build.

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what is needed in order to
  properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what a proper Subject: line should
  look like.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot