From d911b50bcb804c22d2a28e10d699515681e5e249 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 21 Oct 2010 10:50:25 +0100 Subject: [PATCH] fish: Change 'int argc' to 'size_t argc' throughout. Cherry picked from commit 6391d1a7cfa10337a75465c72d49df3c9ebc65ca. --- fish/alloc.c | 4 ++-- fish/echo.c | 4 ++-- fish/edit.c | 2 +- fish/fish.h | 26 +++++++++++++------------- fish/glob.c | 11 ++++++----- fish/lcd.c | 2 +- fish/man.c | 2 +- fish/more.c | 2 +- fish/rc.c | 7 ++++--- fish/reopen.c | 2 +- fish/supported.c | 2 +- fish/time.c | 2 +- src/generator.ml | 4 ++-- 13 files changed, 36 insertions(+), 34 deletions(-) diff --git a/fish/alloc.c b/fish/alloc.c index 7533741..11fc364 100644 --- a/fish/alloc.c +++ b/fish/alloc.c @@ -31,7 +31,7 @@ #include "fish.h" int -do_alloc (const char *cmd, int argc, char *argv[]) +do_alloc (const char *cmd, size_t argc, char *argv[]) { if (argc != 2) { fprintf (stderr, _("use 'alloc file size' to create an image\n")); @@ -45,7 +45,7 @@ do_alloc (const char *cmd, int argc, char *argv[]) } int -do_sparse (const char *cmd, int argc, char *argv[]) +do_sparse (const char *cmd, size_t argc, char *argv[]) { if (argc != 2) { fprintf (stderr, _("use 'sparse file size' to create a sparse image\n")); diff --git a/fish/echo.c b/fish/echo.c index 33992d4..2d84100 100644 --- a/fish/echo.c +++ b/fish/echo.c @@ -25,9 +25,9 @@ #include "fish.h" int -do_echo (const char *cmd, int argc, char *argv[]) +do_echo (const char *cmd, size_t argc, char *argv[]) { - int i; + size_t i; for (i = 0; i < argc; ++i) { if (i > 0) printf (" "); diff --git a/fish/edit.c b/fish/edit.c index 10950f9..67ea01f 100644 --- a/fish/edit.c +++ b/fish/edit.c @@ -32,7 +32,7 @@ /* guestfish edit command, suggested by Ján Ondrej, implemented by RWMJ */ int -do_edit (const char *cmd, int argc, char *argv[]) +do_edit (const char *cmd, size_t argc, char *argv[]) { char filename[] = "/tmp/guestfishXXXXXX"; char buf[256]; diff --git a/fish/fish.h b/fish/fish.h index 6cd811a..c9013d4 100644 --- a/fish/fish.h +++ b/fish/fish.h @@ -72,7 +72,7 @@ extern void extended_help_message (void); /* in cmds.c (auto-generated) */ extern void list_commands (void); extern int display_command (const char *cmd); -extern int run_action (const char *cmd, int argc, char *argv[]); +extern int run_action (const char *cmd, size_t argc, char *argv[]); /* in completion.c (auto-generated) */ extern char **do_completion (const char *text, int start, int end); @@ -82,28 +82,28 @@ extern int complete_dest_paths; extern char *complete_dest_paths_generator (const char *text, int state); /* in alloc.c */ -extern int do_alloc (const char *cmd, int argc, char *argv[]); -extern int do_sparse (const char *cmd, int argc, char *argv[]); +extern int do_alloc (const char *cmd, size_t argc, char *argv[]); +extern int do_sparse (const char *cmd, size_t argc, char *argv[]); extern int alloc_disk (const char *filename, const char *size, int add, int sparse); /* in echo.c */ -extern int do_echo (const char *cmd, int argc, char *argv[]); +extern int do_echo (const char *cmd, size_t argc, char *argv[]); /* in edit.c */ -extern int do_edit (const char *cmd, int argc, char *argv[]); +extern int do_edit (const char *cmd, size_t argc, char *argv[]); /* in lcd.c */ -extern int do_lcd (const char *cmd, int argc, char *argv[]); +extern int do_lcd (const char *cmd, size_t argc, char *argv[]); /* in glob.c */ -extern int do_glob (const char *cmd, int argc, char *argv[]); +extern int do_glob (const char *cmd, size_t argc, char *argv[]); /* in man.c */ -extern int do_man (const char *cmd, int argc, char *argv[]); +extern int do_man (const char *cmd, size_t argc, char *argv[]); /* in more.c */ -extern int do_more (const char *cmd, int argc, char *argv[]); +extern int do_more (const char *cmd, size_t argc, char *argv[]); /* in prep.c */ struct prep_data { @@ -121,17 +121,17 @@ extern void prep_error (prep_data *data, const char *filename, const char *fs, . /* in rc.c (remote control) */ extern void rc_listen (void) __attribute__((noreturn)); -extern int rc_remote (int pid, const char *cmd, int argc, char *argv[], +extern int rc_remote (int pid, const char *cmd, size_t argc, char *argv[], int exit_on_error); /* in reopen.c */ -extern int do_reopen (const char *cmd, int argc, char *argv[]); +extern int do_reopen (const char *cmd, size_t argc, char *argv[]); /* in supported.c */ -extern int do_supported (const char *cmd, int argc, char *argv[]); +extern int do_supported (const char *cmd, size_t argc, char *argv[]); /* in time.c */ -extern int do_time (const char *cmd, int argc, char *argv[]); +extern int do_time (const char *cmd, size_t argc, char *argv[]); /* in tilde.c */ extern char *try_tilde_expansion (char *path); diff --git a/fish/glob.c b/fish/glob.c index 2731b2f..8ca0920 100644 --- a/fish/glob.c +++ b/fish/glob.c @@ -28,10 +28,10 @@ /* A bit tricky because in the case where there are multiple * paths we have to perform a Cartesian product. */ -static void glob_issue (char *cmd, int argc, char ***globs, int *posn, int *count, int *r); +static void glob_issue (char *cmd, size_t argc, char ***globs, int *posn, int *count, int *r); int -do_glob (const char *cmd, int argc, char *argv[]) +do_glob (const char *cmd, size_t argc, char *argv[]) { /* For 'glob cmd foo /s* /usr/s*' this could be: * @@ -46,7 +46,8 @@ do_glob (const char *cmd, int argc, char *argv[]) char **globs[argc]; int posn[argc]; int count[argc]; - int i, r = 0; + size_t i; + int r = 0; if (argc < 1) { fprintf (stderr, _("use 'glob command [args...]'\n")); @@ -129,11 +130,11 @@ do_glob (const char *cmd, int argc, char *argv[]) } static void -glob_issue (char *cmd, int argc, +glob_issue (char *cmd, size_t argc, char ***globs, int *posn, int *count, int *r) { - int i; + size_t i; char *argv[argc+1]; argv[0] = cmd; diff --git a/fish/lcd.c b/fish/lcd.c index e631f21..6631a2b 100644 --- a/fish/lcd.c +++ b/fish/lcd.c @@ -28,7 +28,7 @@ /* guestfish lcd command (similar to the lcd command in BSD ftp) */ int -do_lcd (const char *cmd, int argc, char *argv[]) +do_lcd (const char *cmd, size_t argc, char *argv[]) { if (argc != 1) { fprintf (stderr, _("use 'lcd directory' to change local directory\n")); diff --git a/fish/man.c b/fish/man.c index e28e892..5554515 100644 --- a/fish/man.c +++ b/fish/man.c @@ -28,7 +28,7 @@ /* guestfish man command */ int -do_man (const char *cmd, int argc, char *argv[]) +do_man (const char *cmd, size_t argc, char *argv[]) { if (argc != 0) { fprintf (stderr, _("use 'man' without parameters to open the manual\n")); diff --git a/fish/more.c b/fish/more.c index 55faefa..2186a34 100644 --- a/fish/more.c +++ b/fish/more.c @@ -28,7 +28,7 @@ #include "fish.h" int -do_more (const char *cmd, int argc, char *argv[]) +do_more (const char *cmd, size_t argc, char *argv[]) { char filename[] = "/tmp/guestfishXXXXXX"; char buf[256]; diff --git a/fish/rc.c b/fish/rc.c index dbaf953..e637fc6 100644 --- a/fish/rc.c +++ b/fish/rc.c @@ -177,14 +177,15 @@ rc_listen (void) char sockpath[128]; pid_t pid; struct sockaddr_un addr; - int sock, s, i; + int sock, s; + size_t i; FILE *fp; XDR xdr, xdr2; guestfish_hello hello; guestfish_call call; guestfish_reply reply; char **argv; - int argc; + size_t argc; memset (&hello, 0, sizeof hello); memset (&call, 0, sizeof call); @@ -307,7 +308,7 @@ rc_listen (void) /* Remote control client. */ int -rc_remote (int pid, const char *cmd, int argc, char *argv[], +rc_remote (int pid, const char *cmd, size_t argc, char *argv[], int exit_on_error) { guestfish_hello hello; diff --git a/fish/reopen.c b/fish/reopen.c index 2dfc8db..1f299eb 100644 --- a/fish/reopen.c +++ b/fish/reopen.c @@ -26,7 +26,7 @@ #include "fish.h" int -do_reopen (const char *cmd, int argc, char *argv[]) +do_reopen (const char *cmd, size_t argc, char *argv[]) { guestfs_h *g2; int r; diff --git a/fish/supported.c b/fish/supported.c index c97af14..d2eb91a 100644 --- a/fish/supported.c +++ b/fish/supported.c @@ -26,7 +26,7 @@ #include "fish.h" int -do_supported (const char *cmd, int argc, char *argv[]) +do_supported (const char *cmd, size_t argc, char *argv[]) { char **groups; diff --git a/fish/time.c b/fish/time.c index ed00c18..ed9fb67 100644 --- a/fish/time.c +++ b/fish/time.c @@ -26,7 +26,7 @@ #include "fish.h" int -do_time (const char *cmd, int argc, char *argv[]) +do_time (const char *cmd, size_t argc, char *argv[]) { struct timeval start_t, end_t; int64_t start_us, end_us, elapsed_us; diff --git a/src/generator.ml b/src/generator.ml index a1c1380..0c090e4 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -7844,7 +7844,7 @@ and generate_fish_cmds () = (* run_ actions *) List.iter ( fun (name, style, _, flags, _, _, _) -> - pr "static int run_%s (const char *cmd, int argc, char *argv[])\n" name; + pr "static int run_%s (const char *cmd, size_t argc, char *argv[])\n" name; pr "{\n"; (match fst style with | RErr @@ -8057,7 +8057,7 @@ and generate_fish_cmds () = ) all_functions; (* run_action function *) - pr "int run_action (const char *cmd, int argc, char *argv[])\n"; + pr "int run_action (const char *cmd, size_t argc, char *argv[])\n"; pr "{\n"; List.iter ( fun (name, _, _, flags, _, _, _) -> -- 1.8.3.1