diff mbox series

[v2] ksmbd-tools: add missing long option in adduser/addshare/control

Message ID 20220602051852.75949-1-linkinjeon@kernel.org (mailing list archive)
State New, archived
Headers show
Series [v2] ksmbd-tools: add missing long option in adduser/addshare/control | expand

Commit Message

Namjae Jeon June 2, 2022, 5:18 a.m. UTC
Add missing long option in adduser/addshare/control.

Reported-by: David Howells <dhowells@redhat.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 v2:
   - add NULL element in opts[].

 addshare/addshare.c | 12 +++++++++++-
 adduser/adduser.c   | 13 ++++++++++++-
 control/control.c   | 10 +++++++++-
 3 files changed, 32 insertions(+), 3 deletions(-)

Comments

Hyunchul Lee June 2, 2022, 5:59 a.m. UTC | #1
2022년 6월 2일 (목) 오후 2:19, Namjae Jeon <linkinjeon@kernel.org>님이 작성:
>
> Add missing long option in adduser/addshare/control.
>
> Reported-by: David Howells <dhowells@redhat.com>
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
> ---

Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>

>  v2:
>    - add NULL element in opts[].
>
>  addshare/addshare.c | 12 +++++++++++-
>  adduser/adduser.c   | 13 ++++++++++++-
>  control/control.c   | 10 +++++++++-
>  3 files changed, 32 insertions(+), 3 deletions(-)
>
> diff --git a/addshare/addshare.c b/addshare/addshare.c
> index 4d25047..af36e4b 100644
> --- a/addshare/addshare.c
> +++ b/addshare/addshare.c
> @@ -54,6 +54,16 @@ static void usage(void)
>         exit(EXIT_FAILURE);
>  }
>
> +static const struct option opts[] = {
> +       {"add-share",           required_argument,      NULL,   'a' },
> +       {"del-share",           required_argument,      NULL,   'd' },
> +       {"update-share",        required_argument,      NULL,   'u' },
> +       {"options",             required_argument,      NULL,   'o' },
> +       {"version",             no_argument,            NULL,   'V' },
> +       {"verbose",             no_argument,            NULL,   'v' },
> +       {NULL,                  0,                      NULL,    0  }
> +};
> +
>  static void show_version(void)
>  {
>         printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
> @@ -102,7 +112,7 @@ int main(int argc, char *argv[])
>         set_logger_app_name("ksmbd.addshare");
>
>         opterr = 0;
> -       while ((c = getopt(argc, argv, "c:a:d:u:p:o:Vvh")) != EOF)
> +       while ((c = getopt_long(argc, argv, "c:a:d:u:p:o:Vvh", opts, NULL)) != EOF)
>                 switch (c) {
>                 case 'a':
>                         arg_name = g_ascii_strdown(optarg, strlen(optarg));
> diff --git a/adduser/adduser.c b/adduser/adduser.c
> index 88b12db..9e736ee 100644
> --- a/adduser/adduser.c
> +++ b/adduser/adduser.c
> @@ -50,6 +50,17 @@ static void usage(void)
>         exit(EXIT_FAILURE);
>  }
>
> +static const struct option opts[] = {
> +       {"add-user",            required_argument,      NULL,   'a' },
> +       {"del-user",            required_argument,      NULL,   'd' },
> +       {"update-user",         required_argument,      NULL,   'u' },
> +       {"password",            required_argument,      NULL,   'p' },
> +       {"import-users",        required_argument,      NULL,   'i' },
> +       {"version",             no_argument,            NULL,   'V' },
> +       {"verbose",             no_argument,            NULL,   'v' },
> +       {NULL,                  0,                      NULL,    0  }
> +};
> +
>  static void show_version(void)
>  {
>         printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
> @@ -102,7 +113,7 @@ int main(int argc, char *argv[])
>         set_logger_app_name("ksmbd.adduser");
>
>         opterr = 0;
> -       while ((c = getopt(argc, argv, "c:i:a:d:u:p:Vvh")) != EOF)
> +       while ((c = getopt_long(argc, argv, "c:i:a:d:u:p:Vvh", opts, NULL)) != EOF)
>                 switch (c) {
>                 case 'a':
>                         arg_account = g_strdup(optarg);
> diff --git a/control/control.c b/control/control.c
> index 780a48a..94fec33 100644
> --- a/control/control.c
> +++ b/control/control.c
> @@ -23,6 +23,14 @@ static void usage(void)
>         exit(EXIT_FAILURE);
>  }
>
> +static const struct option opts[] = {
> +       {"shutdown",            no_argument,            NULL,   's' },
> +       {"debug",               required_argument,      NULL,   'd' },
> +       {"ksmbd-version",       no_argument,            NULL,   'c' },
> +       {"version",             no_argument,            NULL,   'V' },
> +       {NULL,                  0,                      NULL,    0  }
> +};
> +
>  static void show_version(void)
>  {
>         printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
> @@ -101,7 +109,7 @@ int main(int argc, char *argv[])
>         }
>
>         opterr = 0;
> -       while ((c = getopt(argc, argv, "sd:cVh")) != EOF)
> +       while ((c = getopt_long(argc, argv, "sd:cVh", opts, NULL)) != EOF)
>                 switch (c) {
>                 case 's':
>                         ret = ksmbd_control_shutdown();
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/addshare/addshare.c b/addshare/addshare.c
index 4d25047..af36e4b 100644
--- a/addshare/addshare.c
+++ b/addshare/addshare.c
@@ -54,6 +54,16 @@  static void usage(void)
 	exit(EXIT_FAILURE);
 }
 
+static const struct option opts[] = {
+	{"add-share",		required_argument,	NULL,	'a' },
+	{"del-share",		required_argument,	NULL,	'd' },
+	{"update-share",	required_argument,	NULL,	'u' },
+	{"options",		required_argument,	NULL,	'o' },
+	{"version",		no_argument,		NULL,	'V' },
+	{"verbose",		no_argument,		NULL,	'v' },
+	{NULL,			0,			NULL,	 0  }
+};
+
 static void show_version(void)
 {
 	printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
@@ -102,7 +112,7 @@  int main(int argc, char *argv[])
 	set_logger_app_name("ksmbd.addshare");
 
 	opterr = 0;
-	while ((c = getopt(argc, argv, "c:a:d:u:p:o:Vvh")) != EOF)
+	while ((c = getopt_long(argc, argv, "c:a:d:u:p:o:Vvh", opts, NULL)) != EOF)
 		switch (c) {
 		case 'a':
 			arg_name = g_ascii_strdown(optarg, strlen(optarg));
diff --git a/adduser/adduser.c b/adduser/adduser.c
index 88b12db..9e736ee 100644
--- a/adduser/adduser.c
+++ b/adduser/adduser.c
@@ -50,6 +50,17 @@  static void usage(void)
 	exit(EXIT_FAILURE);
 }
 
+static const struct option opts[] = {
+	{"add-user",		required_argument,	NULL,	'a' },
+	{"del-user",		required_argument,	NULL,	'd' },
+	{"update-user",		required_argument,	NULL,	'u' },
+	{"password",		required_argument,	NULL,	'p' },
+	{"import-users",	required_argument,	NULL,	'i' },
+	{"version",		no_argument,		NULL,	'V' },
+	{"verbose",		no_argument,		NULL,	'v' },
+	{NULL,			0,			NULL,	 0  }
+};
+
 static void show_version(void)
 {
 	printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
@@ -102,7 +113,7 @@  int main(int argc, char *argv[])
 	set_logger_app_name("ksmbd.adduser");
 
 	opterr = 0;
-	while ((c = getopt(argc, argv, "c:i:a:d:u:p:Vvh")) != EOF)
+	while ((c = getopt_long(argc, argv, "c:i:a:d:u:p:Vvh", opts, NULL)) != EOF)
 		switch (c) {
 		case 'a':
 			arg_account = g_strdup(optarg);
diff --git a/control/control.c b/control/control.c
index 780a48a..94fec33 100644
--- a/control/control.c
+++ b/control/control.c
@@ -23,6 +23,14 @@  static void usage(void)
 	exit(EXIT_FAILURE);
 }
 
+static const struct option opts[] = {
+	{"shutdown",		no_argument,		NULL,	's' },
+	{"debug",		required_argument,	NULL,	'd' },
+	{"ksmbd-version",	no_argument,		NULL,	'c' },
+	{"version",		no_argument,		NULL,	'V' },
+	{NULL,			0,			NULL,	 0  }
+};
+
 static void show_version(void)
 {
 	printf("ksmbd-tools version : %s\n", KSMBD_TOOLS_VERSION);
@@ -101,7 +109,7 @@  int main(int argc, char *argv[])
 	}
 
 	opterr = 0;
-	while ((c = getopt(argc, argv, "sd:cVh")) != EOF)
+	while ((c = getopt_long(argc, argv, "sd:cVh", opts, NULL)) != EOF)
 		switch (c) {
 		case 's':
 			ret = ksmbd_control_shutdown();