diff options
author | Jean Delvare <jdelvare@suse.de> | 2017-09-19 08:59:34 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2017-10-29 21:36:03 -0400 |
commit | fc483a9bf795ebf49bf0c872d125391d8fee2f3f (patch) | |
tree | dddab88c2fd11da4e1f5641189cbbe31cbd67d94 /drivers/hwmon/stts751.c | |
parent | 6dcf2fb5e8db3704f50af1f198256cb4e2453f8b (diff) |
hwmon: (stts751) Fix buffer size passed to snprintf
Function snprintf already cares for the terminating NUL at the end of
the string, the caller doesn't need to do it.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Andrea Merello <andrea.merello@gmail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/stts751.c')
-rw-r--r-- | drivers/hwmon/stts751.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/hwmon/stts751.c b/drivers/hwmon/stts751.c index 3f940fb67dc6..7fe152d92350 100644 --- a/drivers/hwmon/stts751.c +++ b/drivers/hwmon/stts751.c | |||
@@ -396,7 +396,7 @@ static ssize_t show_max_alarm(struct device *dev, struct device_attribute *attr, | |||
396 | if (ret < 0) | 396 | if (ret < 0) |
397 | return ret; | 397 | return ret; |
398 | 398 | ||
399 | return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->max_alert); | 399 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->max_alert); |
400 | } | 400 | } |
401 | 401 | ||
402 | static ssize_t show_min_alarm(struct device *dev, struct device_attribute *attr, | 402 | static ssize_t show_min_alarm(struct device *dev, struct device_attribute *attr, |
@@ -413,7 +413,7 @@ static ssize_t show_min_alarm(struct device *dev, struct device_attribute *attr, | |||
413 | if (ret < 0) | 413 | if (ret < 0) |
414 | return ret; | 414 | return ret; |
415 | 415 | ||
416 | return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->min_alert); | 416 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->min_alert); |
417 | } | 417 | } |
418 | 418 | ||
419 | static ssize_t show_input(struct device *dev, struct device_attribute *attr, | 419 | static ssize_t show_input(struct device *dev, struct device_attribute *attr, |
@@ -428,7 +428,7 @@ static ssize_t show_input(struct device *dev, struct device_attribute *attr, | |||
428 | if (ret < 0) | 428 | if (ret < 0) |
429 | return ret; | 429 | return ret; |
430 | 430 | ||
431 | return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->temp); | 431 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->temp); |
432 | } | 432 | } |
433 | 433 | ||
434 | static ssize_t show_therm(struct device *dev, struct device_attribute *attr, | 434 | static ssize_t show_therm(struct device *dev, struct device_attribute *attr, |
@@ -436,7 +436,7 @@ static ssize_t show_therm(struct device *dev, struct device_attribute *attr, | |||
436 | { | 436 | { |
437 | struct stts751_priv *priv = dev_get_drvdata(dev); | 437 | struct stts751_priv *priv = dev_get_drvdata(dev); |
438 | 438 | ||
439 | return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->therm); | 439 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->therm); |
440 | } | 440 | } |
441 | 441 | ||
442 | static ssize_t set_therm(struct device *dev, struct device_attribute *attr, | 442 | static ssize_t set_therm(struct device *dev, struct device_attribute *attr, |
@@ -478,7 +478,7 @@ static ssize_t show_hyst(struct device *dev, struct device_attribute *attr, | |||
478 | { | 478 | { |
479 | struct stts751_priv *priv = dev_get_drvdata(dev); | 479 | struct stts751_priv *priv = dev_get_drvdata(dev); |
480 | 480 | ||
481 | return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->hyst); | 481 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->hyst); |
482 | } | 482 | } |
483 | 483 | ||
484 | static ssize_t set_hyst(struct device *dev, struct device_attribute *attr, | 484 | static ssize_t set_hyst(struct device *dev, struct device_attribute *attr, |
@@ -518,7 +518,7 @@ static ssize_t show_therm_trip(struct device *dev, | |||
518 | if (ret < 0) | 518 | if (ret < 0) |
519 | return ret; | 519 | return ret; |
520 | 520 | ||
521 | return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->therm_trip); | 521 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->therm_trip); |
522 | } | 522 | } |
523 | 523 | ||
524 | static ssize_t show_max(struct device *dev, struct device_attribute *attr, | 524 | static ssize_t show_max(struct device *dev, struct device_attribute *attr, |
@@ -526,7 +526,7 @@ static ssize_t show_max(struct device *dev, struct device_attribute *attr, | |||
526 | { | 526 | { |
527 | struct stts751_priv *priv = dev_get_drvdata(dev); | 527 | struct stts751_priv *priv = dev_get_drvdata(dev); |
528 | 528 | ||
529 | return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->event_max); | 529 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->event_max); |
530 | } | 530 | } |
531 | 531 | ||
532 | static ssize_t set_max(struct device *dev, struct device_attribute *attr, | 532 | static ssize_t set_max(struct device *dev, struct device_attribute *attr, |
@@ -560,7 +560,7 @@ static ssize_t show_min(struct device *dev, struct device_attribute *attr, | |||
560 | { | 560 | { |
561 | struct stts751_priv *priv = dev_get_drvdata(dev); | 561 | struct stts751_priv *priv = dev_get_drvdata(dev); |
562 | 562 | ||
563 | return snprintf(buf, PAGE_SIZE - 1, "%d\n", priv->event_min); | 563 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->event_min); |
564 | } | 564 | } |
565 | 565 | ||
566 | static ssize_t set_min(struct device *dev, struct device_attribute *attr, | 566 | static ssize_t set_min(struct device *dev, struct device_attribute *attr, |
@@ -594,7 +594,7 @@ static ssize_t show_interval(struct device *dev, struct device_attribute *attr, | |||
594 | { | 594 | { |
595 | struct stts751_priv *priv = dev_get_drvdata(dev); | 595 | struct stts751_priv *priv = dev_get_drvdata(dev); |
596 | 596 | ||
597 | return snprintf(buf, PAGE_SIZE - 1, "%d\n", | 597 | return snprintf(buf, PAGE_SIZE, "%d\n", |
598 | stts751_intervals[priv->interval]); | 598 | stts751_intervals[priv->interval]); |
599 | } | 599 | } |
600 | 600 | ||