Skip to contentSkip to conversation

Multipath: Remove duplicated memset() for multipathd show command.

PATCH New Gris Ge 1 participant 1 message Jun 15, 2016 Device mapper

lore
Share & tools
lore

Gris Ge

author
#0 lore raw

PATCH 1/1 Multipath: Remove duplicated memset() for multipathd show command.

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'.

---
 libmultipath/print.c | 10 ----------
 1 file changed, 10 deletions(-)
libmultipath/print.c +0 -10
index 2d159ed..e3c14b6 100644
@@ -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;
Signature · 1 line
2.8.3