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]
Date:   Wed, 12 Oct 2022 18:10:39 +0800
From:   Li kunyu <kunyu@...china.com>
To:     trenn@...e.com, shuah@...nel.org, ray.huang@....com
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Li kunyu <kunyu@...china.com>
Subject: [PATCH] power: cpupower: utils: Optimize print_online_cpus and print_offline_cpus function

1. Remove the initialization assignment of variables, and they will be
assigned first.
2. Remove the mandatory conversion of returned value of malloc function,
which returns void* type.

Signed-off-by: Li kunyu <kunyu@...china.com>
---
 tools/power/cpupower/utils/helpers/misc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c
index 9547b29254a7..36dbd0562240 100644
--- a/tools/power/cpupower/utils/helpers/misc.c
+++ b/tools/power/cpupower/utils/helpers/misc.c
@@ -134,11 +134,11 @@ void get_cpustate(void)
  */
 void print_online_cpus(void)
 {
-	int str_len = 0;
-	char *online_cpus_str = NULL;
+	int str_len;
+	char *online_cpus_str;
 
 	str_len = online_cpus->size * 5;
-	online_cpus_str = (void *)malloc(sizeof(char) * str_len);
+	online_cpus_str = malloc(sizeof(char) * str_len);
 
 	if (!bitmask_isallclear(online_cpus)) {
 		bitmask_displaylist(online_cpus_str, str_len, online_cpus);
@@ -152,11 +152,11 @@ void print_online_cpus(void)
  */
 void print_offline_cpus(void)
 {
-	int str_len = 0;
-	char *offline_cpus_str = NULL;
+	int str_len;
+	char *offline_cpus_str;
 
 	str_len = offline_cpus->size * 5;
-	offline_cpus_str = (void *)malloc(sizeof(char) * str_len);
+	offline_cpus_str = malloc(sizeof(char) * str_len);
 
 	if (!bitmask_isallclear(offline_cpus)) {
 		bitmask_displaylist(offline_cpus_str, str_len, offline_cpus);
-- 
2.18.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ