The helper get_next_string is useful and generic. So move from exclusive weightedpath module to util module. It will be used in the next second patch. Signed-off-by: Junxiong Guan <guanjunxiong@xxxxxxxxxx> --- libmultipath/prioritizers/weightedpath.c | 10 +--------- libmultipath/util.c | 9 +++++++++ libmultipath/util.h | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libmultipath/prioritizers/weightedpath.c b/libmultipath/prioritizers/weightedpath.c index 34a43a81..e0f3efbb 100644 --- a/libmultipath/prioritizers/weightedpath.c +++ b/libmultipath/prioritizers/weightedpath.c @@ -34,15 +34,7 @@ #include <regex.h> #include "structs_vec.h" #include "print.h" - -char *get_next_string(char **temp, char *split_char) -{ - char *token = NULL; - token = strsep(temp, split_char); - while (token != NULL && !strcmp(token, "")) - token = strsep(temp, split_char); - return token; -} +#include "util.h" #define CHECK_LEN \ do { \ diff --git a/libmultipath/util.c b/libmultipath/util.c index dff2ed3c..528ba73b 100644 --- a/libmultipath/util.c +++ b/libmultipath/util.c @@ -64,6 +64,15 @@ filepresent (char * run) { return 0; } +char *get_next_string(char **temp, char *split_char) +{ + char *token = NULL; + token = strsep(temp, split_char); + while (token != NULL && !strcmp(token, "")) + token = strsep(temp, split_char); + return token; +} + int get_word (char * sentence, char ** word) { diff --git a/libmultipath/util.h b/libmultipath/util.h index 45291be8..584ad948 100644 --- a/libmultipath/util.h +++ b/libmultipath/util.h @@ -6,6 +6,7 @@ size_t strchop(char *); int basenamecpy (const char * src, char * dst, int); int filepresent (char * run); +char *get_next_string(char **temp, char *split_char); int get_word (char * sentence, char ** word); size_t strlcpy(char *dst, const char *src, size_t size); size_t strlcat(char *dst, const char *src, size_t size); -- 2.11.1 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel