From ad21703f66c0d013d3cbd2d7f307715ef77864ff Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Thu, 12 Nov 2015 17:04:41 +0300 Subject: [PATCH] LU-7421 utils: getparam_display() should reset popt otherwise it's randomly set leading to wrong output for lctl get_param. this may break testing. Change-Id: Ice1ab3ce2ba09a3c6bf6843ff4381ccb73483e42 Signed-off-by: Alex Zhuravlev Reviewed-on: http://review.whamcloud.com/17135 Tested-by: Jenkins Reviewed-by: John L. Hammond Reviewed-by: Bob Glossman Reviewed-by: James Simmons Reviewed-by: Dmitry Eremin Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/utils/lustre_cfg.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index d15780e..a588e3d 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -789,9 +789,6 @@ static int listparam_cmdline(int argc, char **argv, struct param_opts *popt) popt->po_show_path = 1; popt->po_only_path = 1; - popt->po_show_type = 0; - popt->po_recursive = 0; - popt->po_only_dir = 0; while ((ch = getopt(argc, argv, "FRD")) != -1) { switch (ch) { @@ -863,6 +860,7 @@ int jt_lcfg_listparam(int argc, char **argv) char pattern[PATH_MAX]; char *path; + memset(&popt, 0, sizeof(popt)); rc = listparam_cmdline(argc, argv, &popt); if (rc == argc && popt.po_recursive) { rc--; /* we know at least "-R" is a parameter */ @@ -892,9 +890,6 @@ static int getparam_cmdline(int argc, char **argv, struct param_opts *popt) int ch; popt->po_show_path = 1; - popt->po_only_path = 0; - popt->po_show_type = 0; - popt->po_recursive = 0; while ((ch = getopt(argc, argv, "FnNR")) != -1) { switch (ch) { @@ -1030,6 +1025,7 @@ int jt_lcfg_getparam(int argc, char **argv) char pattern[PATH_MAX]; char *path; + memset(&popt, 0, sizeof(popt)); rc = getparam_cmdline(argc, argv, &popt); if (rc == argc && popt.po_recursive) { rc--; /* we know at least "-R" is a parameter */ @@ -1074,15 +1070,12 @@ int jt_nodemap_info(int argc, char **argv) { const char usage_str[] = "usage: nodemap_info " "[list|nodemap_name|all]\n"; - struct param_opts popt = { - .po_only_path = 0, - .po_show_path = 1, - .po_show_type = 0, - .po_recursive = 0, - .po_only_dir = 0 - }; + struct param_opts popt; int rc = 0; + memset(&popt, 0, sizeof(popt)); + popt.po_show_path = 1; + if (argc > 2) { fprintf(stderr, usage_str); return -1; @@ -1197,6 +1190,7 @@ int jt_lcfg_setparam(int argc, char **argv) char pattern[PATH_MAX]; char *path = NULL, *value = NULL; + memset(&popt, 0, sizeof(popt)); rc = setparam_cmdline(argc, argv, &popt); if (rc < 0 || rc >= argc) return CMD_HELP; -- 1.8.3.1