mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Senseless code and unnecessary memset
@ 2022-04-05 17:36 Grigory Vasilyev
  2022-04-05 17:38 ` Christian König
  0 siblings, 1 reply; 5+ messages in thread
From: Grigory Vasilyev @ 2022-04-05 17:36 UTC (permalink / raw)
  To: Rodrigo Siqueira, Melissa Wen
  Cc: Grigory Vasilyev, Alex Deucher, Christian König, Pan,
	Xinhui, David Airlie, Daniel Vetter, Jani Nikula, Jiawei Gu,
	Lucas De Marchi, amd-gfx, dri-devel, linux-kernel

Using memset on local arrays before exiting the function is pointless.
Compilator will remove this code. Also for local arrays is preferable to
use {0} instead of memset. Mistakes are often made when working with
memset.

Signed-off-by: Grigory Vasilyev <h0tc0d3@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/atom.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c b/drivers/gpu/drm/amd/amdgpu/atom.c
index be9d61bcb8ae..537e48fbbe6b 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -1538,11 +1538,9 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
 int amdgpu_atom_asic_init(struct atom_context *ctx)
 {
 	int hwi = CU16(ctx->data_table + ATOM_DATA_FWI_PTR);
-	uint32_t ps[16];
+	uint32_t ps[16] = {0};
 	int ret;
 
-	memset(ps, 0, 64);
-
 	ps[0] = cpu_to_le32(CU32(hwi + ATOM_FWI_DEFSCLK_PTR));
 	ps[1] = cpu_to_le32(CU32(hwi + ATOM_FWI_DEFMCLK_PTR));
 	if (!ps[0] || !ps[1])
@@ -1551,10 +1549,6 @@ int amdgpu_atom_asic_init(struct atom_context *ctx)
 	if (!CU16(ctx->cmd_table + 4 + 2 * ATOM_CMD_INIT))
 		return 1;
 	ret = amdgpu_atom_execute_table(ctx, ATOM_CMD_INIT, ps);
-	if (ret)
-		return ret;
-
-	memset(ps, 0, 64);
 
 	return ret;
 }
-- 
2.35.1


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

end of thread, other threads:[~2022-04-10  0:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 17:36 [PATCH] drm/amdgpu: Senseless code and unnecessary memset Grigory Vasilyev
2022-04-05 17:38 ` Christian König
2022-04-06 14:26   ` Jani Nikula
2022-04-06 14:43     ` Christian König
2022-04-10  0:50       ` Grigory Vasilyev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®