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-prev] [day] [month] [year] [list]
Message-ID: <433518d6bc8ef4e5b4fc04e3343c13eddfc32e24.camel@perches.com>
Date: Sun, 24 Aug 2025 10:50:04 -0700
From: Joe Perches <joe@...ches.com>
To: vivekyadav1207731111@...il.com, daniel.lezcano@...aro.org, 
	rafael@...nel.org
Cc: linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH] cpuidle: sysfs: fix coding style issue

On Sun, 2025-08-24 at 10:15 -0700, vivekyadav1207731111@...il.com wrote:
> From: Vivek Yadav <vivekyadav1207731111@...il.com>
> 
> Fix a checkpatch.pl error by adding space around '+='
> operator.
> 
> No functional changes intended.
> 
> [checkpatch.pl output]
> 	ERROR: spaces required around that '+='

Perhaps better to convert all sprintf style uses
to sysfs_emit and sysfs_emit_at

> diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
[]
> @@ -34,7 +34,7 @@ static ssize_t show_available_governors(struct device *dev,
>  	}
> 
>  out:
> -	i+= sprintf(&buf[i], "\n");
> +	i += sprintf(&buf[i], "\n");
>  	mutex_unlock(&cpuidle_lock);
>  	return i;
>  }

Something akin to:
---
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index d6f5da61cb7d8..3adb98c9986fd 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -22,21 +22,19 @@ static ssize_t show_available_governors(struct device *dev,
 					struct device_attribute *attr,
 					char *buf)
 {
-	ssize_t i = 0;
+	ssize_t len = 0;
 	struct cpuidle_governor *tmp;
 
 	mutex_lock(&cpuidle_lock);
-	list_for_each_entry(tmp, &cpuidle_governors, governor_list) {
-		if (i >= (ssize_t) (PAGE_SIZE - (CPUIDLE_NAME_LEN + 2)))
-			goto out;
 
-		i += scnprintf(&buf[i], CPUIDLE_NAME_LEN + 1, "%s ", tmp->name);
-	}
+	list_for_each_entry(tmp, &cpuidle_governors, governor_list)
+		len += sysfs_emit_at(buf, len, "%s%s",
+				     len > 0 ? " " : "", tmp->name);
+	len += sysfs_emit_at(buf, len, "\n");
 
-out:
-	i+= sprintf(&buf[i], "\n");
 	mutex_unlock(&cpuidle_lock);
-	return i;
+
+	return len;
 }
 
 static ssize_t show_current_driver(struct device *dev,
---
etc...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ