linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] proc: fix alloc_cast.cocci warnings
  2022-01-25  2:35 fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless kernel test robot
@ 2022-01-25  1:13 ` kernel test robot
  2022-01-25  3:01 ` fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless Hao Lee
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-01-25  1:13 UTC (permalink / raw)
  To: Hao Lee; +Cc: kbuild-all, linux-kernel, 0day robot, Alexey Dobriyan

From: kernel test robot <lkp@intel.com>

fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless.

 Remove casting the values returned by memory allocation functions
 like kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc.

Semantic patch information:
 This makes an effort to find cases of casting of values returned by
 kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc,
 kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes
 the casting as it is not required. The result in the patch case may
 need some reformatting.

Generated by: scripts/coccinelle/api/alloc/alloc_cast.cocci

CC: Hao Lee <haolee.swjtu@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---

tree:   https://github.com/0day-ci/linux/commits/UPDATE-20220123-215907/Hao-Lee/proc-use-kmalloc-instead-of-__get_free_page-to-alloc-path-buffer/20220123-181005
head:   98106e76de95ae9aefa914ec056448a5571155dc
commit: 98106e76de95ae9aefa914ec056448a5571155dc proc: alloc PATH_MAX bytes for /proc/${pid}/fd/ symlinks
:::::: branch date: 35 hours ago
:::::: commit date: 35 hours ago

 base.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1764,7 +1764,7 @@ out:
 
 static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
 {
-	char *tmp = (char *)kmalloc(PATH_MAX, GFP_KERNEL);
+	char *tmp = kmalloc(PATH_MAX, GFP_KERNEL);
 	char *pathname;
 	int len;
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless.
@ 2022-01-25  2:35 kernel test robot
  2022-01-25  1:13 ` [PATCH] proc: fix alloc_cast.cocci warnings kernel test robot
  2022-01-25  3:01 ` fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless Hao Lee
  0 siblings, 2 replies; 4+ messages in thread
From: kernel test robot @ 2022-01-25  2:35 UTC (permalink / raw)
  To: Hao Lee; +Cc: kbuild-all, linux-kernel, 0day robot, Alexey Dobriyan

tree:   https://github.com/0day-ci/linux/commits/UPDATE-20220123-215907/Hao-Lee/proc-use-kmalloc-instead-of-__get_free_page-to-alloc-path-buffer/20220123-181005
head:   98106e76de95ae9aefa914ec056448a5571155dc
commit: 98106e76de95ae9aefa914ec056448a5571155dc proc: alloc PATH_MAX bytes for /proc/${pid}/fd/ symlinks
date:   35 hours ago
config: i386-randconfig-c001-20220124 (https://download.01.org/0day-ci/archive/20220125/202201250941.1xbLnDRA-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


cocci warnings: (new ones prefixed by >>)
>> fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless.

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless.
  2022-01-25  2:35 fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless kernel test robot
  2022-01-25  1:13 ` [PATCH] proc: fix alloc_cast.cocci warnings kernel test robot
@ 2022-01-25  3:01 ` Hao Lee
  2022-01-25  6:05   ` Hao Lee
  1 sibling, 1 reply; 4+ messages in thread
From: Hao Lee @ 2022-01-25  3:01 UTC (permalink / raw)
  To: kernel test robot; +Cc: kbuild-all, LKML, Alexey Dobriyan, Andrew Morton

On Tue, Jan 25, 2022 at 10:36 AM kernel test robot <lkp@intel.com> wrote:
>
> tree:   https://github.com/0day-ci/linux/commits/UPDATE-20220123-215907/Hao-Lee/proc-use-kmalloc-instead-of-__get_free_page-to-alloc-path-buffer/20220123-181005
> head:   98106e76de95ae9aefa914ec056448a5571155dc
> commit: 98106e76de95ae9aefa914ec056448a5571155dc proc: alloc PATH_MAX bytes for /proc/${pid}/fd/ symlinks
> date:   35 hours ago
> config: i386-randconfig-c001-20220124 (https://download.01.org/0day-ci/archive/20220125/202201250941.1xbLnDRA-lkp@intel.com/config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> cocci warnings: (new ones prefixed by >>)
> >> fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless.

Hello, Alexey,

This patch has been added to the -mm tree, how do we deal with this problem...
Thanks.

>
> Please review and possibly fold the followup patch.
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless.
  2022-01-25  3:01 ` fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless Hao Lee
@ 2022-01-25  6:05   ` Hao Lee
  0 siblings, 0 replies; 4+ messages in thread
From: Hao Lee @ 2022-01-25  6:05 UTC (permalink / raw)
  To: kernel test robot; +Cc: kbuild-all, LKML, Alexey Dobriyan, Andrew Morton

On Tue, Jan 25, 2022 at 11:01 AM Hao Lee <haolee.swjtu@gmail.com> wrote:
>
> On Tue, Jan 25, 2022 at 10:36 AM kernel test robot <lkp@intel.com> wrote:
> >
> > tree:   https://github.com/0day-ci/linux/commits/UPDATE-20220123-215907/Hao-Lee/proc-use-kmalloc-instead-of-__get_free_page-to-alloc-path-buffer/20220123-181005
> > head:   98106e76de95ae9aefa914ec056448a5571155dc
> > commit: 98106e76de95ae9aefa914ec056448a5571155dc proc: alloc PATH_MAX bytes for /proc/${pid}/fd/ symlinks
> > date:   35 hours ago
> > config: i386-randconfig-c001-20220124 (https://download.01.org/0day-ci/archive/20220125/202201250941.1xbLnDRA-lkp@intel.com/config)
> > compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> >
> > cocci warnings: (new ones prefixed by >>)
> > >> fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless.
>
> Hello, Alexey,
>
> This patch has been added to the -mm tree, how do we deal with this problem...
> Thanks.

Andrew has handled it. Thanks.

>
> >
> > Please review and possibly fold the followup patch.
> >
> > ---
> > 0-DAY CI Kernel Test Service, Intel Corporation
> > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-25  7:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-25  2:35 fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless kernel test robot
2022-01-25  1:13 ` [PATCH] proc: fix alloc_cast.cocci warnings kernel test robot
2022-01-25  3:01 ` fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless Hao Lee
2022-01-25  6:05   ` Hao Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).