* [PATCH 0/2] ubihealthd: Fix options @ 2019-10-03 6:34 Alexander Dahl 2019-10-03 6:35 ` [PATCH 1/2] ubihealthd: Add missing sentinel in options array Alexander Dahl ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Alexander Dahl @ 2019-10-03 6:34 UTC (permalink / raw) To: linux-mtd; +Cc: Alexander Dahl Hello, I started experimenting with ubihealthd, first thing I did was: ./ubihealthd -h And boom segfault. The first patch is about that. The second about having the usual -h and --help options. Greets Alex Alexander Dahl (2): ubihealthd: Add missing sentinel in options array ubihealthd: Add option -h/--help ubi-utils/ubihealthd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] ubihealthd: Add missing sentinel in options array 2019-10-03 6:34 [PATCH 0/2] ubihealthd: Fix options Alexander Dahl @ 2019-10-03 6:35 ` Alexander Dahl 2019-10-03 6:35 ` [PATCH 2/2] ubihealthd: Add option -h/--help Alexander Dahl 2019-10-03 7:54 ` [PATCH 0/2] ubihealthd: Fix options Richard Weinberger 2 siblings, 0 replies; 5+ messages in thread From: Alexander Dahl @ 2019-10-03 6:35 UTC (permalink / raw) To: linux-mtd; +Cc: Alexander Dahl `getopt_long()` requires a null terminated array, otherwise we get segfaults when passing invalid options. Fixes: 7f0e2dc21fb2 ("ubi-utils: Implement a ubihealthd") Signed-off-by: Alexander Dahl <post@lespocky.de> --- ubi-utils/ubihealthd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ubi-utils/ubihealthd.c b/ubi-utils/ubihealthd.c index 3e665be..f38235b 100644 --- a/ubi-utils/ubihealthd.c +++ b/ubi-utils/ubihealthd.c @@ -56,6 +56,7 @@ static const struct option options[] = { .flag = NULL, .val = 'i' }, + { /* sentinel */ } }; static void dolog(const char *fmt, ...) -- 2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ubihealthd: Add option -h/--help 2019-10-03 6:34 [PATCH 0/2] ubihealthd: Fix options Alexander Dahl 2019-10-03 6:35 ` [PATCH 1/2] ubihealthd: Add missing sentinel in options array Alexander Dahl @ 2019-10-03 6:35 ` Alexander Dahl 2019-10-03 7:54 ` [PATCH 0/2] ubihealthd: Fix options Richard Weinberger 2 siblings, 0 replies; 5+ messages in thread From: Alexander Dahl @ 2019-10-03 6:35 UTC (permalink / raw) To: linux-mtd; +Cc: Alexander Dahl Using '?' as option did not work, and would be strange to pass anyway, because it's a glob char for the shell and you would have to escape it like ./ubihealthd -\? … use the more common -h/--help instead. Note: this does not touch the output, just changes the options itself. Signed-off-by: Alexander Dahl <post@lespocky.de> --- ubi-utils/ubihealthd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ubi-utils/ubihealthd.c b/ubi-utils/ubihealthd.c index f38235b..27799f7 100644 --- a/ubi-utils/ubihealthd.c +++ b/ubi-utils/ubihealthd.c @@ -42,7 +42,7 @@ static int ubi_fd; static int interval_secs = 120; static int nodaemon; -static const char opt_string[] = "d:i:f"; +static const char opt_string[] = "d:i:fh"; static const struct option options[] = { { .name = "device", @@ -56,6 +56,12 @@ static const struct option options[] = { .flag = NULL, .val = 'i' }, + { + .name = "help", + .has_arg = no_argument, + .flag = NULL, + .val = 'h' + }, { /* sentinel */ } }; @@ -238,7 +244,7 @@ int main (int argc, char *argv[]) nodaemon = 1; break; } - case '?': + case 'h': default: fprintf(stderr, "Usage: %s [ -d UBI_DEVICE ] [-i INTERVAL_SEC ] [ -f ]\n", argv[0]); exit(1); -- 2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] ubihealthd: Fix options 2019-10-03 6:34 [PATCH 0/2] ubihealthd: Fix options Alexander Dahl 2019-10-03 6:35 ` [PATCH 1/2] ubihealthd: Add missing sentinel in options array Alexander Dahl 2019-10-03 6:35 ` [PATCH 2/2] ubihealthd: Add option -h/--help Alexander Dahl @ 2019-10-03 7:54 ` Richard Weinberger 2019-10-07 8:15 ` David Oberhollenzer 2 siblings, 1 reply; 5+ messages in thread From: Richard Weinberger @ 2019-10-03 7:54 UTC (permalink / raw) To: Alexander Dahl; +Cc: linux-mtd On Thu, Oct 3, 2019 at 8:35 AM Alexander Dahl <post@lespocky.de> wrote: > > Hello, > > I started experimenting with ubihealthd, first thing I did was: > > ./ubihealthd -h > > And boom segfault. The first patch is about that. The second about > having the usual -h and --help options. Thanks for fixing this. Acked-by: Richard Weinberger <richard@nod.at> -- Thanks, //richard ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] ubihealthd: Fix options 2019-10-03 7:54 ` [PATCH 0/2] ubihealthd: Fix options Richard Weinberger @ 2019-10-07 8:15 ` David Oberhollenzer 0 siblings, 0 replies; 5+ messages in thread From: David Oberhollenzer @ 2019-10-07 8:15 UTC (permalink / raw) To: Richard Weinberger, Alexander Dahl; +Cc: linux-mtd Applied to mtd-utils.git master. Thanks, David ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-10-07 8:15 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-10-03 6:34 [PATCH 0/2] ubihealthd: Fix options Alexander Dahl 2019-10-03 6:35 ` [PATCH 1/2] ubihealthd: Add missing sentinel in options array Alexander Dahl 2019-10-03 6:35 ` [PATCH 2/2] ubihealthd: Add option -h/--help Alexander Dahl 2019-10-03 7:54 ` [PATCH 0/2] ubihealthd: Fix options Richard Weinberger 2019-10-07 8:15 ` David Oberhollenzer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).