lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1462988936-13486-1-git-send-email-falakreyaz@gmail.com>
Date:	Wed, 11 May 2016 23:18:43 +0530
From:	Muhammad Falak R Wani <falakreyaz@...il.com>
To:	Christian Knig <christian.koenig@....com>
Cc:	Alex Deucher <alexander.deucher@....com>,
	David Airlie <airlied@...ux.ie>, Rex Zhu <Rex.Zhu@....com>,
	Nils Wallménius <nils.wallmenius@...il.com>,
	Dan Carpenter <dan.carpenter@...cle.com>,
	Jammy Zhou <Jammy.Zhou@....com>,
	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drm/amd/powerplay: use ARRAY_SIZE() for size of array

Use ARRAY_SIZE() for the size calculation of the array. Also move the
condition evaulation function out of the for loop.
Although, any respectable c-compiler would optimize this and evaluate
the function only once outside the loop, but the optimzation engine
of gcc is bit brain-dead, and at times needs some hand holding.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@...il.com>
---
 drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
index da18f44..718a551 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
@@ -636,10 +636,11 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr)
 	int ret;
 	enum cgs_ucode_id ucode_id;
 	struct cgs_firmware_info info = {0};
+	int n = ARRAY_SIZE(firmware_list);
 
 	cz_smu->driver_buffer_length = 0;
 
-	for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) {
+	for (i = 0; i < n; i++) {
 
 		firmware_type = cz_translate_firmware_enum_to_arg(smumgr,
 					firmware_list[i]);
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ