From: Cyrill Gorcunov <gorcu...@gmail.com>

We can get rid of sprintf usage when encoding the status.
Just fill the string directly.

Cc: Kirill Tkhai <ktk...@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcu...@gmail.com>
---
 drivers/md/dm-ploop-target.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

--- vzkernel.orig/drivers/md/dm-ploop-target.c
+++ vzkernel/drivers/md/dm-ploop-target.c
@@ -435,20 +435,21 @@ static void ploop_status(struct dm_targe
                         unsigned int maxlen)
 {
        struct ploop *ploop = ti->private;
-       char stat[16] = { 0 }, *p = stat;
+       char stat[16], *p = stat;
        ssize_t sz = 0;
 
        down_read(&ploop->ctl_rwsem);
        if (ploop->falloc_new_clu)
-               p += sprintf(p, "f");
+               *p++ = 'f';
        if (ploop->tracking_bitmap)
-               p += sprintf(p, "t");
+               *p++ = 't';
        if (READ_ONCE(ploop->noresume))
-               p += sprintf(p, "n");
+               *p++ = 'n';
        if (READ_ONCE(ploop->event_enospc))
-               p += sprintf(p, "s");
+               *p++ = 's';
        if (p == stat)
-               p += sprintf(p, "o");
+               *p++ = 'o';
+       *p++ = '\0';
        up_read(&ploop->ctl_rwsem);
 
        BUG_ON(p - stat >= sizeof(stat));
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to