Skip to content

Commit d2f99e0

Browse files
cjhoward92Carson Howard
authored andcommitted
examples: ls-files: fix compile error
1 parent cd39273 commit d2f99e0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/ls-files.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void usage(const char *message, const char *arg)
4949
exit(1);
5050
}
5151

52-
static void parse_options(ls_options *opts, int argc, char *argv[])
52+
static int parse_options(ls_options *opts, int argc, char *argv[])
5353
{
5454
int parsing_files = 0;
5555
struct args_info args = ARGS_INFO_INIT;
@@ -58,7 +58,7 @@ static void parse_options(ls_options *opts, int argc, char *argv[])
5858
memset(opts, 0, sizeof(ls_options));
5959

6060
if (argc < 2)
61-
return;
61+
return 0;
6262

6363
for (args.pos = 1; args.pos < argc; ++args.pos) {
6464
char *a = argv[args.pos];
@@ -77,8 +77,11 @@ static void parse_options(ls_options *opts, int argc, char *argv[])
7777
opts->error_unmatch = 1;
7878
} else {
7979
usage("Unsupported argument", a);
80+
return -1;
8081
}
8182
}
83+
84+
return 0;
8285
}
8386

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

116-
parse_options(&opts, argc, argv);
119+
if ((error = parse_options(&opts, argc, argv)) < 0)
120+
return error;
117121

118122
git_libgit2_init();
119123

0 commit comments

Comments
 (0)