From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Fenghua Yu <fenghua.yu@intel.com>,
Jean Delvare <jdelvare@suse.de>,
Guenter Roeck <linux@roeck-us.net>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] hwmon: (coretemp) Allow format checking
Date: Thu, 12 Feb 2015 15:15:16 +0100 [thread overview]
Message-ID: <1423750517-26439-2-git-send-email-linux@rasmusvillemoes.dk> (raw)
In-Reply-To: <1423750517-26439-1-git-send-email-linux@rasmusvillemoes.dk>
By extracting the only part that differs we can allow static checking
of the format string, and possibly save a little .rodata.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/hwmon/coretemp.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 5b7fec824f10..0e873bca98a4 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -397,14 +397,13 @@ static int create_core_attrs(struct temp_data *tdata, struct device *dev,
struct device_attribute *devattr, char *buf) = {
show_label, show_crit_alarm, show_temp, show_tjmax,
show_ttarget };
- static const char *const names[TOTAL_ATTRS] = {
- "temp%d_label", "temp%d_crit_alarm",
- "temp%d_input", "temp%d_crit",
- "temp%d_max" };
+ static const char *const suffixes[TOTAL_ATTRS] = {
+ "label", "crit_alarm", "input", "crit", "max"
+ };
for (i = 0; i < tdata->attr_size; i++) {
- snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH, names[i],
- attr_no);
+ snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH,
+ "temp%d_%s", attr_no, suffixes[i]);
sysfs_attr_init(&tdata->sd_attrs[i].dev_attr.attr);
tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i];
tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO;
--
2.1.3
next prev parent reply other threads:[~2015-02-12 14:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-12 14:15 [PATCH 1/3] hwmon: (applesmc) " Rasmus Villemoes
2015-02-12 14:15 ` Rasmus Villemoes [this message]
2015-02-13 5:08 ` [PATCH 2/3] hwmon: (coretemp) " Guenter Roeck
2015-02-12 14:15 ` [PATCH 3/3] hwmon: (ibmpex) Allow format string checking Rasmus Villemoes
2015-02-13 5:09 ` Guenter Roeck
2015-02-13 5:13 ` [PATCH 1/3] hwmon: (applesmc) Allow format checking Guenter Roeck
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=1423750517-26439-2-git-send-email-linux@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=fenghua.yu@intel.com \
--cc=jdelvare@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lm-sensors@lm-sensors.org \
/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®