evtranalyze: don't try to open stdin by default
authorAggelos Economopoulos <aoiko@cc.ece.ntua.gr>
Mon, 24 May 2010 22:15:50 +0000 (01:15 +0300)
committerAggelos Economopoulos <aoiko@cc.ece.ntua.gr>
Wed, 26 May 2010 13:21:50 +0000 (16:21 +0300)
We don't handle that correctly yet, so error out instead. A
lot of people were getting a crash on their first run b/c
they didn't specify an input file.

usr.bin/evtranalyze/evtranalyze.c

index 59d7b2c..5666ebc 100644 (file)
@@ -88,7 +88,7 @@ struct command {
 };
 
 evtr_t evtr;
-char *opt_infile;
+static char *opt_infile;
 unsigned evtranalyze_debug;
 
 static
@@ -953,7 +953,9 @@ main(int argc, char **argv)
        if (argc == 0) {
                err(2, "need to specify a command\n");
        }
-       if (!opt_infile || !strcmp(opt_infile, "-")) {
+       if (!opt_infile) {
+               err(2, "you need to specify an input file\n");
+       } else if (!strcmp(opt_infile, "-")) {
                inf = stdin;
        } else {
                inf = fopen(opt_infile, "r");