Skip to content
Merged
Prev Previous commit
Next Next commit
examples: ls-files: fix compile error
  • Loading branch information
cjhoward92 authored and Carson Howard committed Mar 27, 2018
commit d2f99e0a7f259511d94a960c54c297db2ec455af
10 changes: 7 additions & 3 deletions examples/ls-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static void usage(const char *message, const char *arg)
exit(1);
}

static void parse_options(ls_options *opts, int argc, char *argv[])
static int parse_options(ls_options *opts, int argc, char *argv[])
{
int parsing_files = 0;
struct args_info args = ARGS_INFO_INIT;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really being used, is it? You could instead just loop over argc/argv[]:

int i;
for (i = 1; i < argc; i++) {
    char *arg = argv[i];
    ...
}

Expand All @@ -58,7 +58,7 @@ static void parse_options(ls_options *opts, int argc, char *argv[])
memset(opts, 0, sizeof(ls_options));

if (argc < 2)
return;
return 0;

for (args.pos = 1; args.pos < argc; ++args.pos) {
char *a = argv[args.pos];
Expand All @@ -77,8 +77,11 @@ static void parse_options(ls_options *opts, int argc, char *argv[])
opts->error_unmatch = 1;
} else {
usage("Unsupported argument", a);
return -1;
}
}

return 0;
}

static int print_paths(ls_options *opts, git_index *index)
Expand Down Expand Up @@ -113,7 +116,8 @@ int main(int argc, char *argv[])
size_t i = 0;
int error;

parse_options(&opts, argc, argv);
if ((error = parse_options(&opts, argc, argv)) < 0)
return error;

git_libgit2_init();

Expand Down