aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/zram/zcomp.c
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>2014-04-07 18:38:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 19:36:02 -0400
commit56b4e8cb85827a2ccc4752a2a7148e56b62b7e96 (patch)
tree48a9d05f13fd1c1dedf768879ebb4c05c7cf2fed /drivers/block/zram/zcomp.c
parent60a726e33375a1096e85399cfa1327081b4c38be (diff)
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 b0e7592c44d8..f1ff39a3d1c1 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)
275 275
276 while (backends[i]) { 276 while (backends[i]) {
277 if (sysfs_streq(comp, backends[i]->name)) 277 if (sysfs_streq(comp, backends[i]->name))
278 sz += sprintf(buf + sz, "[%s] ", backends[i]->name); 278 sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
279 "[%s] ", backends[i]->name);
279 else 280 else
280 sz += sprintf(buf + sz, "%s ", backends[i]->name); 281 sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
282 "%s ", backends[i]->name);
281 i++; 283 i++;
282 } 284 }
283 sz += sprintf(buf + sz, "\n"); 285 sz += scnprintf(buf + sz, PAGE_SIZE - sz, "\n");
284 return sz; 286 return sz;
285} 287}
286 288