drivers/cpuidle/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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 '+='
Signed-off-by: Vivek Yadav <vivekyadav1207731111@gmail.com>
---
drivers/cpuidle/sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index d6f5da61cb7d..cbf2e021c6ba 100644
--- 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;
}
---
2.25.1
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...
© 2016 - 2025 Red Hat, Inc.