summaryrefslogtreecommitdiff
path: root/drivers/block/zram/zcomp.c
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>2014-04-07 22:38:22 (GMT)
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 23:36:02 (GMT)
commit56b4e8cb85827a2ccc4752a2a7148e56b62b7e96 (patch)
tree48a9d05f13fd1c1dedf768879ebb4c05c7cf2fed /drivers/block/zram/zcomp.c
parent60a726e33375a1096e85399cfa1327081b4c38be (diff)
downloadlinux-56b4e8cb85827a2ccc4752a2a7148e56b62b7e96.tar.xz
zram: use scnprintf() in attrs show() methods
sysfs.txt documentation lists the following requirements: - The buffer will always be PAGE_SIZE bytes in length. On i386, this is 4096. - show() methods should return the number of bytes printed into the buffer. This is the return value of scnprintf(). - show() should always use scnprintf(). Use scnprintf() in show() functions. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Jerome Marchand <jmarchan@redhat.com> Cc: Nitin Gupta <ngupta@vflare.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/zram/zcomp.c')
-rw-r--r--drivers/block/zram/zcomp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
index b0e7592c..f1ff39a 100644
--- a/drivers/block/zram/zcomp.c
+++ b/drivers/block/zram/zcomp.c
@@ -275,12 +275,14 @@ ssize_t zcomp_available_show(const char *comp, char *buf)
while (backends[i]) {
if (sysfs_streq(comp, backends[i]->name))
- sz += sprintf(buf + sz, "[%s] ", backends[i]->name);
+ sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
+ "[%s] ", backends[i]->name);
else
- sz += sprintf(buf + sz, "%s ", backends[i]->name);
+ sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
+ "%s ", backends[i]->name);
i++;
}
- sz += sprintf(buf + sz, "\n");
+ sz += scnprintf(buf + sz, PAGE_SIZE - sz, "\n");
return sz;
}