]> git.itanic.dy.fi Git - glucose/commitdiff
Fixed option handling.
authorSteve Sloan <steve@finagle.org>
Sat, 24 Mar 2012 19:39:53 +0000 (12:39 -0700)
committerSteve Sloan <steve@finagle.org>
Sat, 24 Mar 2012 19:39:53 +0000 (12:39 -0700)
main.c
options.c

diff --git a/main.c b/main.c
index 0f2b641bf8af0419091a727efaba11a874e7b6ba..954d733bb3e174724562b6c5938e61e531b00d4e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -37,12 +37,13 @@ char *token(char **str, char sep);
 int main(int argc, char *argv[])
 {
        FILE *outf;
 int main(int argc, char *argv[])
 {
        FILE *outf;
-       struct user_options opts = { .output_format = CLEAN };
+       struct user_options opts = { .usbdev = NULL, .output_path = NULL, .output_format = CLEAN, .trace_level = 0 };
        struct msg msg;
        int fd, usage_code, ret, error;
        int entries = 0;
 
        struct msg msg;
        int fd, usage_code, ret, error;
        int entries = 0;
 
-       read_args(argc, argv, &opts);
+       if ( read_args(argc, argv, &opts) )
+               return -1;
 
        trace_level = opts.trace_level;
 
 
        trace_level = opts.trace_level;
 
index 7bd5b9bbfd9700a081a8753d46dc379c01903bf2..8392f99c346f073ffabcf91500f5f8e065e6ba3c 100644 (file)
--- a/options.c
+++ b/options.c
@@ -30,13 +30,11 @@ int read_args(int argc, char *argv[], struct user_options *opts)
         static struct option long_options[] = {
                 { .val = 'd', .name = "device", .has_arg = 1, },
                 { .val = 'v', .name = "verbose", .has_arg = 2 },
         static struct option long_options[] = {
                 { .val = 'd', .name = "device", .has_arg = 1, },
                 { .val = 'v', .name = "verbose", .has_arg = 2 },
-               { .val = 'o', .name = "output", .has_arg = 1 },
+                { .val = 'o', .name = "output", .has_arg = 1 },
                 { .val = 'f', .name = "format", .has_arg = 1, },
         };
         char short_options[] = "d:v:o:f:";
 
                 { .val = 'f', .name = "format", .has_arg = 1, },
         };
         char short_options[] = "d:v:o:f:";
 
-       memset(opts, 0, sizeof(*opts));
-
         while (1) {
                 c = getopt_long(argc, argv, short_options, long_options,
                                 &option_index);
         while (1) {
                 c = getopt_long(argc, argv, short_options, long_options,
                                 &option_index);