mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: vivekyadav1207731111@gmail.com, daniel.lezcano@linaro.org,
	 rafael@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH] cpuidle: sysfs: fix coding style issue
Date: Sun, 24 Aug 2025 10:50:04 -0700	[thread overview]
Message-ID: <433518d6bc8ef4e5b4fc04e3343c13eddfc32e24.camel@perches.com> (raw)
In-Reply-To: <20250824171543.17662-1-vivekyadav1207731111@gmail.com>

On Sun, 2025-08-24 at 10:15 -0700, vivekyadav1207731111@gmail.com wrote:
> From: Vivek Yadav <vivekyadav1207731111@gmail.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...

      reply	other threads:[~2025-08-24 17:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-24 17:15 vivekyadav1207731111
2025-08-24 17:50 ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=433518d6bc8ef4e5b4fc04e3343c13eddfc32e24.camel@perches.com \
    --to=joe@perches.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=vivekyadav1207731111@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®