[PATCH] drm/amd/display: fix alloc_cast.cocci warnings

kbuild test robot fengguang.wu at intel.com
Fri Oct 6 20:56:13 UTC 2017


drivers/gpu/drm/amd/amdgpu/../display/dc/basics/logger.c:73:23-27: 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

Fixes: 2004f45ef83f ("drm/amd/display: Use kernel alloc/free")
CC: Harry Wentland <harry.wentland at amd.com>
Signed-off-by: Fengguang Wu <fengguang.wu at intel.com>
---

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

--- a/drivers/gpu/drm/amd/amdgpu/../display/dc/basics/logger.c
+++ b/drivers/gpu/drm/amd/amdgpu/../display/dc/basics/logger.c
@@ -70,7 +70,7 @@ static bool construct(struct dc_context
 {
 	/* malloc buffer and init offsets */
 	logger->log_buffer_size = DAL_LOGGER_BUFFER_MAX_SIZE;
-	logger->log_buffer = (char *)kzalloc(logger->log_buffer_size * sizeof(char),
+	logger->log_buffer = kzalloc(logger->log_buffer_size * sizeof(char),
 					     GFP_KERNEL);
 
 	if (!logger->log_buffer)


More information about the dri-devel mailing list