Skip to content

Commit

Permalink
Merge pull request #4 from akinomyoga/fix-use-of-indeterminate-value
Browse files Browse the repository at this point in the history
Fix usage of the uninitialized variable long_opt
  • Loading branch information
saitoha committed Jul 27, 2016
2 parents d06c7bf + b2f6430 commit 166125a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,11 @@ static void show_help()

static int parse_args(int argc, char *argv[], struct settings_t *psettings)
{
int long_opt;
int n;
char const *optstring = "w:h:HVl:f:b:c:t:jr:i:o:";
#ifdef HAVE_GETOPT_LONG
int long_opt;
int option_index;
#endif /* HAVE_GETOPT_LONG */

#ifdef HAVE_GETOPT_LONG
struct option long_options[] = {
{"width", required_argument, &long_opt, 'w'},
{"height", required_argument, &long_opt, 'h'},
Expand Down Expand Up @@ -280,9 +277,11 @@ static int parse_args(int argc, char *argv[], struct settings_t *psettings)
if (n == -1) {
break;
}
#ifdef HAVE_GETOPT_LONG
if (n == 0) {
n = long_opt;
}
#endif /* HAVE_GETOPT_LONG */
switch(n) {
case 'w':
psettings->width = atoi(optarg);
Expand Down

0 comments on commit 166125a

Please sign in to comment.