* [char-misc-next] mei: bus: use scnprintf in *_show
@ 2016-03-24 8:38 Tomas Winkler
2016-03-31 23:43 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Tomas Winkler @ 2016-03-24 8:38 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Alexander Usyskin, linux-kernel, Rasmus Villemoes, Tomas Winkler
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
There's no reason to duplicate the logic provided by scnprintf().
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/bus.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 5d5996e39a67..04dc05150898 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -634,11 +634,8 @@ static ssize_t name_show(struct device *dev, struct device_attribute *a,
char *buf)
{
struct mei_cl_device *cldev = to_mei_cl_device(dev);
- size_t len;
- len = snprintf(buf, PAGE_SIZE, "%s", cldev->name);
-
- return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+ return scnprintf(buf, PAGE_SIZE, "%s", cldev->name);
}
static DEVICE_ATTR_RO(name);
@@ -647,11 +644,8 @@ static ssize_t uuid_show(struct device *dev, struct device_attribute *a,
{
struct mei_cl_device *cldev = to_mei_cl_device(dev);
const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl);
- size_t len;
-
- len = snprintf(buf, PAGE_SIZE, "%pUl", uuid);
- return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+ return scnprintf(buf, PAGE_SIZE, "%pUl", uuid);
}
static DEVICE_ATTR_RO(uuid);
@@ -660,11 +654,8 @@ static ssize_t version_show(struct device *dev, struct device_attribute *a,
{
struct mei_cl_device *cldev = to_mei_cl_device(dev);
u8 version = mei_me_cl_ver(cldev->me_cl);
- size_t len;
-
- len = snprintf(buf, PAGE_SIZE, "%02X", version);
- return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+ return scnprintf(buf, PAGE_SIZE, "%02X", version);
}
static DEVICE_ATTR_RO(version);
@@ -673,10 +664,8 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
{
struct mei_cl_device *cldev = to_mei_cl_device(dev);
const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl);
- size_t len;
- len = snprintf(buf, PAGE_SIZE, "mei:%s:%pUl:", cldev->name, uuid);
- return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+ return scnprintf(buf, PAGE_SIZE, "mei:%s:%pUl:", cldev->name, uuid);
}
static DEVICE_ATTR_RO(modalias);
--
2.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [char-misc-next] mei: bus: use scnprintf in *_show
2016-03-24 8:38 [char-misc-next] mei: bus: use scnprintf in *_show Tomas Winkler
@ 2016-03-31 23:43 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2016-03-31 23:43 UTC (permalink / raw)
To: Tomas Winkler; +Cc: Alexander Usyskin, linux-kernel, Rasmus Villemoes
On Thu, Mar 24, 2016 at 10:38:04AM +0200, Tomas Winkler wrote:
> From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
>
> There's no reason to duplicate the logic provided by scnprintf().
And really, there's no need for any of this, just use sprintf() for
sysfs attributes that are the size of an integer.
But I'll take this for now, just to keep people happy because "everyone
knows sprintf() should never be used"...
bah.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-31 23:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-24 8:38 [char-misc-next] mei: bus: use scnprintf in *_show Tomas Winkler
2016-03-31 23:43 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox