diff options
author | Hanjun Guo <guohanjun@huawei.com> | 2020-05-19 08:25:20 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2020-05-19 17:41:17 +0200 |
commit | 3f9f8daad3422809d1db47ef1ca5b1400c889f9d (patch) | |
tree | b332574e47e2b5b2c3a3637bc987e4e809a3ff2d /drivers/cpuidle | |
parent | cpuidle: psci: Fixup execution order when entering a domain idle state (diff) | |
download | linux-3f9f8daad3422809d1db47ef1ca5b1400c889f9d.tar.xz linux-3f9f8daad3422809d1db47ef1ca5b1400c889f9d.zip |
cpuidle: sysfs: Fix the overlap for showing available governors
When showing the available governors, it's "%s " in scnprintf(),
not "%s", so if the governor name has 15 characters, it will
overlap with the later one, fix it by adding one more for the
size.
While we are at it, fix the minor coding style issue and remove
the "/sizeof(char)" since sizeof(char) always equals 1.
Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
Reviewed-by: Doug Smythies <dsmythies@telus.net>
Tested-by: Doug Smythies <dsmythies@telus.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r-- | drivers/cpuidle/sysfs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index d3ef1d7ad6ee..477b05afaf81 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -35,10 +35,10 @@ static ssize_t show_available_governors(struct device *dev, mutex_lock(&cpuidle_lock); list_for_each_entry(tmp, &cpuidle_governors, governor_list) { - if (i >= (ssize_t) ((PAGE_SIZE/sizeof(char)) - - CPUIDLE_NAME_LEN - 2)) + if (i >= (ssize_t) (PAGE_SIZE - (CPUIDLE_NAME_LEN + 2))) goto out; - i += scnprintf(&buf[i], CPUIDLE_NAME_LEN, "%s ", tmp->name); + + i += scnprintf(&buf[i], CPUIDLE_NAME_LEN + 1, "%s ", tmp->name); } out: |