Skip to content

Commit

Permalink
chore: rename function usage to help
Browse files Browse the repository at this point in the history
this prevent warning from GCC15:

In file included from main.c:38:
mh.h:93:6: error: conflicting types for ‘usage’; have ‘void(void)’
   93 | void usage();
      |      ^~~~~
In file included from main.c:37:
cmd.h:71:6: note: previous definition of ‘usage’ with type ‘void(struct command *)’
   71 | void usage(struct command *cmd) {
      |      ^~~~~
  • Loading branch information
oz123 committed Nov 29, 2024
1 parent 245bcdf commit 238fb93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ find_cmd(const char *arg)
}


void usage(const struct command *cmd) {
void help(const struct command *cmd) {
fprintf(stderr, PROGNAME " [ --help | --version | --file <Makefile> ] [target]\n");
fprintf(stderr, "\nOptions:\n");
for (int i = 0; cmd[i].name != NULL; i++) {
fprintf(stderr, " %s, %s\t\t\t%s\n", cmd[i].shortcut, cmd[i].name, cmd[i].descr);
}
for (int i = 0; cmd[i].name != NULL; i++) {
fprintf(stderr, " %s, %s\t\t\t%s\n", cmd[i].shortcut, cmd[i].name, cmd[i].descr);
}
}

void version(void) {
Expand All @@ -95,14 +95,14 @@ parse_args(int argc, char *argv[], char **filename, char **lookup) {
int ch = find_cmd(argv[1]);
switch (ch) {
case CMD_HELP:
usage(cmd);
help(cmd);
exit(1);
case CMD_VERSION:
version();
exit(0);
case CMD_FILE:
if (argc < 3) {
usage(cmd);
help(cmd);
exit(1);
}
*filename = argv[2];
Expand All @@ -120,3 +120,5 @@ parse_args(int argc, char *argv[], char **filename, char **lookup) {
}
}
}

/* vim: set ts=4 sw=4 et: */
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "mh.h"


static int find_cmd(const char *);
static int find_cmd(const char *);

int
main(int argc, char *argv[])
Expand Down

0 comments on commit 238fb93

Please sign in to comment.