[Devel] [PATCH RH9] ploop: simplify ploop_status
Cyrill Gorcunov
gorcunov at gmail.com
Thu Oct 21 21:32:08 MSK 2021
From: Cyrill Gorcunov <gorcunov at gmail.com>
We can get rid of sprintf usage when encoding the status.
Just fill the string directly.
Cc: Kirill Tkhai <ktkhai at virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at 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));
More information about the Devel
mailing list