[dm-devel] [PATCH] Multipath: Remove duplicated memset() for multipathd show command.
Gris Ge
fge at redhat.com
Wed Jun 15 14:50:38 UTC 2016
Problem:
* The duplicated memset() wasted too much time. For example:
with 5k paths, "sudo multipathd -k'show paths'" command will have
at least 5k times of memset().
Reasons:
* The memory passing to snprint_xxx(e.g. snprint_multipath) is already
zeroed by MALLOC().
* No need to zero memory before snprintf which will always terminate
the string with '\0'.
Signed-off-by: Gris Ge <fge at redhat.com>
---
libmultipath/print.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 2d159ed..e3c14b6 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -782,8 +782,6 @@ snprint_multipath_header (char * line, int len, char * format)
int fwd;
struct multipath_data * data;
- memset(line, 0, len);
-
do {
if (!TAIL)
break;
@@ -817,8 +815,6 @@ snprint_multipath (char * line, int len, char * format,
struct multipath_data * data;
char buff[MAX_FIELD_LEN] = {};
- memset(line, 0, len);
-
do {
if (!TAIL)
break;
@@ -853,8 +849,6 @@ snprint_path_header (char * line, int len, char * format)
int fwd;
struct path_data * data;
- memset(line, 0, len);
-
do {
if (!TAIL)
break;
@@ -888,8 +882,6 @@ snprint_path (char * line, int len, char * format,
struct path_data * data;
char buff[MAX_FIELD_LEN];
- memset(line, 0, len);
-
do {
if (!TAIL)
break;
@@ -925,8 +917,6 @@ snprint_pathgroup (char * line, int len, char * format,
struct pathgroup_data * data;
char buff[MAX_FIELD_LEN];
- memset(line, 0, len);
-
do {
if (!TAIL)
break;
--
2.8.3
More information about the dm-devel
mailing list