Re: [PATCH] staging: android: ashmem: used const keyword
On Tue, Jul 28, 2020 at 11:29:35PM +0530, Dhiraj Sharma wrote: > I ran checkpatch.pl script which reported a warning to use const keyword > on line 370.Therefore I made this change. > > Signed-off-by: Dhiraj Sharma > --- > 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 c05a214191da..f9cfa15b785f 100644 > --- a/drivers/staging/android/ashmem.c > +++ b/drivers/staging/android/ashmem.c > @@ -367,7 +367,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; You have now submitted two patches that you obviously never even built, which is the first step in kernel development :( Please be more careful next time. greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: android: ashmem: used const keyword
Alright, I have understood now that I should not trust on checkpatch.pl script fully but partially it is indeed helpful. Please don't criticize this script, it was my fault instead. Before submitting code changes I would test them all, sorry for wasting your time please ignore this patch changes now. I will not commit such foolish mistakes now. Thank you Dhiraj Sharma On Tue, Jul 28, 2020 at 11:55 PM Greg KH wrote: > > On Tue, Jul 28, 2020 at 11:29:35PM +0530, Dhiraj Sharma wrote: > > I ran checkpatch.pl script which reported a warning to use const keyword > > on line 370.Therefore I made this change. > > > > Signed-off-by: Dhiraj Sharma > > --- > > 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 c05a214191da..f9cfa15b785f 100644 > > --- a/drivers/staging/android/ashmem.c > > +++ b/drivers/staging/android/ashmem.c > > @@ -367,7 +367,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; > > You have now submitted two patches that you obviously never even built, > which is the first step in kernel development :( > > Please be more careful next time. > > greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: android: ashmem: used const keyword
On Tue, 2020-07-28 at 23:29 +0530, Dhiraj Sharma wrote: > I ran checkpatch.pl script which reported a warning to use const keyword > on line 370.Therefore I made this change. checkpatch is a brainless script. Not everything it suggests is appropriate. > diff --git a/drivers/staging/android/ashmem.c > b/drivers/staging/android/ashmem.c [] > @@ -367,7 +367,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; This can't work. Please make sure to compile your proposed changes _before_ you post them. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: android: ashmem: used const keyword
Hi Dhiraj, Thank you for the patch! Yet something to improve: [auto build test ERROR on staging/staging-testing] url: https://github.com/0day-ci/linux/commits/Dhiraj-Sharma/staging-android-ashmem-used-const-keyword/20200729-020222 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 11536442a3b4e1de6890ea5e805908debb74f94a config: i386-randconfig-r012-20200729 (attached as .config) compiler: gcc-9 (Debian 9.3.0-14) 9.3.0 reproduce (this is a W=1 build): # save the attached .config to linux build tree make W=1 ARCH=i386 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): drivers/staging/android/ashmem.c: In function 'ashmem_mmap': >> drivers/staging/android/ashmem.c:418:16: error: assignment of read-only >> variable 'vmfile_fops' 418 |vmfile_fops = *vmfile->f_op; |^ >> drivers/staging/android/ashmem.c:419:21: error: assignment of member 'mmap' >> in read-only object 419 |vmfile_fops.mmap = ashmem_vmfile_mmap; | ^ >> drivers/staging/android/ashmem.c:420:34: error: assignment of member >> 'get_unmapped_area' in read-only object 420 |vmfile_fops.get_unmapped_area = | ^ vim +/vmfile_fops +418 drivers/staging/android/ashmem.c 6d67b0290b4b84c Suren Baghdasaryan 2020-01-27 367 11980c2ac4ccfad Robert Love2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 11980c2ac4ccfad Robert Love2011-12-20 369 { e200c35fc32789d Dhiraj Sharma 2020-07-28 370 static const struct file_operations vmfile_fops; 11980c2ac4ccfad Robert Love2011-12-20 371 struct ashmem_area *asma = file->private_data; 11980c2ac4ccfad Robert Love2011-12-20 372 int ret = 0; 11980c2ac4ccfad Robert Love2011-12-20 373 11980c2ac4ccfad Robert Love2011-12-20 374 mutex_lock(&ashmem_mutex); 11980c2ac4ccfad Robert Love2011-12-20 375 11980c2ac4ccfad Robert Love2011-12-20 376 /* user needs to SET_SIZE before mapping */ 59848d6aded59a6 Alistair Strachan 2018-06-19 377 if (!asma->size) { 11980c2ac4ccfad Robert Love2011-12-20 378 ret = -EINVAL; 11980c2ac4ccfad Robert Love2011-12-20 379 goto out; 11980c2ac4ccfad Robert Love2011-12-20 380 } 11980c2ac4ccfad Robert Love2011-12-20 381 8632c614565d0c5 Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */ 8632c614565d0c5 Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { 11980c2ac4ccfad Robert Love2011-12-20 384 ret = -EINVAL; 11980c2ac4ccfad Robert Love2011-12-20 385 goto out; 11980c2ac4ccfad Robert Love2011-12-20 386 } 11980c2ac4ccfad Robert Love2011-12-20 387 11980c2ac4ccfad Robert Love2011-12-20 388 /* requested protection bits must match our allowed protection mask */ 59848d6aded59a6 Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & 59848d6aded59a6 Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) { 11980c2ac4ccfad Robert Love2011-12-20 391 ret = -EPERM; 11980c2ac4ccfad Robert Love2011-12-20 392 goto out; 11980c2ac4ccfad Robert Love2011-12-20 393 } 56f76fc68492af7 Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask); 11980c2ac4ccfad Robert Love2011-12-20 395 11980c2ac4ccfad Robert Love2011-12-20 396 if (!asma->file) { 11980c2ac4ccfad Robert Love2011-12-20 397 char *name = ASHMEM_NAME_DEF; 11980c2ac4ccfad Robert Love2011-12-20 398 struct file *vmfile; 11980c2ac4ccfad Robert Love2011-12-20 399 11980c2ac4ccfad Robert Love2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') 11980c2ac4ccfad Robert Love2011-12-20 401 name = asma->name; 11980c2ac4ccfad Robert Love2011-12-20 402 11980c2ac4ccfad Robert Love2011-12-20 403 /* ... and allocate the backing shmem file */ 11980c2ac4ccfad Robert Love2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); 7f44cb0ba88b40c Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) { 11980c2ac4ccfad Robert Love2011-12-20 406 ret = PTR_ERR(vmfile); 11980c2ac4ccfad Robert Love2011-12-20 407 goto out; 11980c2ac4ccfad Robert Love2011-12-20 408 } 97fbfef6bd59788 Shuxiao Zhang 2017-04-06 409 vmfile->f_mode |= FMODE_LSEEK; 11980c2ac4ccfad Robe
Re: [PATCH] staging: android: ashmem: used const keyword
Hi Dhiraj, Thank you for the patch! Yet something to improve: [auto build test ERROR on staging/staging-testing] url: https://github.com/0day-ci/linux/commits/Dhiraj-Sharma/staging-android-ashmem-used-const-keyword/20200729-020222 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 11536442a3b4e1de6890ea5e805908debb74f94a config: nds32-allyesconfig (attached as .config) compiler: nds32le-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): drivers/staging/android/ashmem.c: In function 'ashmem_mmap': >> drivers/staging/android/ashmem.c:418:16: error: assignment of read-only >> variable 'vmfile_fops' 418 |vmfile_fops = *vmfile->f_op; |^ >> drivers/staging/android/ashmem.c:419:21: error: assignment of member 'mmap' >> in read-only object 419 |vmfile_fops.mmap = ashmem_vmfile_mmap; | ^ >> drivers/staging/android/ashmem.c:420:34: error: assignment of member >> 'get_unmapped_area' in read-only object 420 |vmfile_fops.get_unmapped_area = | ^ vim +/vmfile_fops +418 drivers/staging/android/ashmem.c 6d67b0290b4b84c Suren Baghdasaryan 2020-01-27 367 11980c2ac4ccfad Robert Love2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 11980c2ac4ccfad Robert Love2011-12-20 369 { e200c35fc32789d Dhiraj Sharma 2020-07-28 370 static const struct file_operations vmfile_fops; 11980c2ac4ccfad Robert Love2011-12-20 371 struct ashmem_area *asma = file->private_data; 11980c2ac4ccfad Robert Love2011-12-20 372 int ret = 0; 11980c2ac4ccfad Robert Love2011-12-20 373 11980c2ac4ccfad Robert Love2011-12-20 374 mutex_lock(&ashmem_mutex); 11980c2ac4ccfad Robert Love2011-12-20 375 11980c2ac4ccfad Robert Love2011-12-20 376 /* user needs to SET_SIZE before mapping */ 59848d6aded59a6 Alistair Strachan 2018-06-19 377 if (!asma->size) { 11980c2ac4ccfad Robert Love2011-12-20 378 ret = -EINVAL; 11980c2ac4ccfad Robert Love2011-12-20 379 goto out; 11980c2ac4ccfad Robert Love2011-12-20 380 } 11980c2ac4ccfad Robert Love2011-12-20 381 8632c614565d0c5 Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */ 8632c614565d0c5 Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { 11980c2ac4ccfad Robert Love2011-12-20 384 ret = -EINVAL; 11980c2ac4ccfad Robert Love2011-12-20 385 goto out; 11980c2ac4ccfad Robert Love2011-12-20 386 } 11980c2ac4ccfad Robert Love2011-12-20 387 11980c2ac4ccfad Robert Love2011-12-20 388 /* requested protection bits must match our allowed protection mask */ 59848d6aded59a6 Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & 59848d6aded59a6 Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) { 11980c2ac4ccfad Robert Love2011-12-20 391 ret = -EPERM; 11980c2ac4ccfad Robert Love2011-12-20 392 goto out; 11980c2ac4ccfad Robert Love2011-12-20 393 } 56f76fc68492af7 Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask); 11980c2ac4ccfad Robert Love2011-12-20 395 11980c2ac4ccfad Robert Love2011-12-20 396 if (!asma->file) { 11980c2ac4ccfad Robert Love2011-12-20 397 char *name = ASHMEM_NAME_DEF; 11980c2ac4ccfad Robert Love2011-12-20 398 struct file *vmfile; 11980c2ac4ccfad Robert Love2011-12-20 399 11980c2ac4ccfad Robert Love2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') 11980c2ac4ccfad Robert Love2011-12-20 401 name = asma->name; 11980c2ac4ccfad Robert Love2011-12-20 402 11980c2ac4ccfad Robert Love2011-12-20 403 /* ... and allocate the backing shmem file */ 11980c2ac4ccfad Robert Love2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); 7f44cb0ba88b40c Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) { 11980c2ac4ccfad Robert Love2011-12-20 406 ret = PTR_ERR(vmfile); 11980c2ac4ccfad Robert Love2011-12-20 407 goto
Re: [PATCH] staging: android: ashmem: used const keyword
Hi Dhiraj, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on staging/staging-testing] url: https://github.com/0day-ci/linux/commits/Dhiraj-Sharma/staging-android-ashmem-used-const-keyword/20200729-020222 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 11536442a3b4e1de6890ea5e805908debb74f94a :: branch date: 6 days ago :: commit date: 6 days ago config: i386-randconfig-s002-20200803 (attached as .config) compiler: gcc-9 (Debian 9.3.0-14) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.2-117-g8c7aee71-dirty # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) >> drivers/staging/android/ashmem.c:418:25: sparse: sparse: assignment to const >> expression drivers/staging/android/ashmem.c:419:36: sparse: sparse: assignment to const expression drivers/staging/android/ashmem.c:420:36: sparse: sparse: assignment to const expression # https://github.com/0day-ci/linux/commit/e200c35fc32789d0eec4878160474e62f9eebeb7 git remote add linux-review https://github.com/0day-ci/linux git remote update linux-review git checkout e200c35fc32789d0eec4878160474e62f9eebeb7 vim +418 drivers/staging/android/ashmem.c 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 367 11980c2ac4ccfa Robert Love2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 11980c2ac4ccfa Robert Love2011-12-20 369 { e200c35fc32789 Dhiraj Sharma 2020-07-28 370 static const struct file_operations vmfile_fops; 11980c2ac4ccfa Robert Love2011-12-20 371 struct ashmem_area *asma = file->private_data; 11980c2ac4ccfa Robert Love2011-12-20 372 int ret = 0; 11980c2ac4ccfa Robert Love2011-12-20 373 11980c2ac4ccfa Robert Love2011-12-20 374 mutex_lock(&ashmem_mutex); 11980c2ac4ccfa Robert Love2011-12-20 375 11980c2ac4ccfa Robert Love2011-12-20 376 /* user needs to SET_SIZE before mapping */ 59848d6aded59a Alistair Strachan 2018-06-19 377 if (!asma->size) { 11980c2ac4ccfa Robert Love2011-12-20 378 ret = -EINVAL; 11980c2ac4ccfa Robert Love2011-12-20 379 goto out; 11980c2ac4ccfa Robert Love2011-12-20 380 } 11980c2ac4ccfa Robert Love2011-12-20 381 8632c614565d0c Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */ 8632c614565d0c Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { 11980c2ac4ccfa Robert Love2011-12-20 384 ret = -EINVAL; 11980c2ac4ccfa Robert Love2011-12-20 385 goto out; 11980c2ac4ccfa Robert Love2011-12-20 386 } 11980c2ac4ccfa Robert Love2011-12-20 387 11980c2ac4ccfa Robert Love2011-12-20 388 /* requested protection bits must match our allowed protection mask */ 59848d6aded59a Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & 59848d6aded59a Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) { 11980c2ac4ccfa Robert Love2011-12-20 391 ret = -EPERM; 11980c2ac4ccfa Robert Love2011-12-20 392 goto out; 11980c2ac4ccfa Robert Love2011-12-20 393 } 56f76fc68492af Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask); 11980c2ac4ccfa Robert Love2011-12-20 395 11980c2ac4ccfa Robert Love2011-12-20 396 if (!asma->file) { 11980c2ac4ccfa Robert Love2011-12-20 397 char *name = ASHMEM_NAME_DEF; 11980c2ac4ccfa Robert Love2011-12-20 398 struct file *vmfile; 11980c2ac4ccfa Robert Love2011-12-20 399 11980c2ac4ccfa Robert Love2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') 11980c2ac4ccfa Robert Love2011-12-20 401 name = asma->name; 11980c2ac4ccfa Robert Love2011-12-20 402 11980c2ac4ccfa Robert Love2011-12-20 403 /* ... and allocate the backing shmem file */ 11980c2ac4ccfa Robert Love2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); 7f44cb0ba88b40 Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) { 11980c2ac4ccfa Robert Love2011-12-20 406 ret = PTR_ERR(vmfile); 11980c2ac4ccfa Robert Love2011-12-20 407 goto out; 11980c2ac4ccfa Robert Love2011-12-20 408 } 97fbfef6bd5978 Shuxiao Zhang 2017-04-06 409 vmfile->f_mode