mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-17 20:54:10 +00:00
hwmon: (ibmpex) Allow format string checking
The only difference between the three power_sensor_name_templates is whether there is a suffix of "", "_lowest" or "_highest". We might as well pull those into an array and use a literal format string, allowing gcc to do type checking of the arguments to sprintf. Incidentially, the same three suffixes are used in the temp_sensor_name_templates case, so we end up eliminating one static array. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> [Guenter Roeck: Fixed line length over 80 characters] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
1055b5f904
commit
a0fc74d42d
1 changed files with 8 additions and 11 deletions
|
@ -56,15 +56,10 @@ static u8 const temp_sensor_sig[] = {0x74, 0x65, 0x6D};
|
||||||
static u8 const watt_sensor_sig[] = {0x41, 0x43};
|
static u8 const watt_sensor_sig[] = {0x41, 0x43};
|
||||||
|
|
||||||
#define PEX_NUM_SENSOR_FUNCS 3
|
#define PEX_NUM_SENSOR_FUNCS 3
|
||||||
static char const * const power_sensor_name_templates[] = {
|
static const char * const sensor_name_suffixes[] = {
|
||||||
"%s%d_average",
|
"",
|
||||||
"%s%d_average_lowest",
|
"_lowest",
|
||||||
"%s%d_average_highest"
|
"_highest"
|
||||||
};
|
|
||||||
static char const * const temp_sensor_name_templates[] = {
|
|
||||||
"%s%d_input",
|
|
||||||
"%s%d_input_lowest",
|
|
||||||
"%s%d_input_highest"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data);
|
static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data);
|
||||||
|
@ -355,9 +350,11 @@ static int create_sensor(struct ibmpex_bmc_data *data, int type,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (type == TEMP_SENSOR)
|
if (type == TEMP_SENSOR)
|
||||||
sprintf(n, temp_sensor_name_templates[func], "temp", counter);
|
sprintf(n, "temp%d_input%s",
|
||||||
|
counter, sensor_name_suffixes[func]);
|
||||||
else if (type == POWER_SENSOR)
|
else if (type == POWER_SENSOR)
|
||||||
sprintf(n, power_sensor_name_templates[func], "power", counter);
|
sprintf(n, "power%d_average%s",
|
||||||
|
counter, sensor_name_suffixes[func]);
|
||||||
|
|
||||||
sysfs_attr_init(&data->sensors[sensor].attr[func].dev_attr.attr);
|
sysfs_attr_init(&data->sensors[sensor].attr[func].dev_attr.attr);
|
||||||
data->sensors[sensor].attr[func].dev_attr.attr.name = n;
|
data->sensors[sensor].attr[func].dev_attr.attr.name = n;
|
||||||
|
|
Loading…
Add table
Reference in a new issue