summaryrefslogtreecommitdiffstats
path: root/fish
diff options
context:
space:
mode:
authorRichard W.M. Jones <[email protected]>2012-03-13 08:23:56 +0000
committerRichard W.M. Jones <[email protected]>2012-03-13 08:23:56 +0000
commitf76a88011a993d059beafe090a21a20be1cb9f4d (patch)
tree4fb7d5802ec2dc03912660a041a1b3166c1a8a2d /fish
parent14df5fa5d1731a502332e9d4a41f54ee3d4a4dac (diff)
downloadlibguestfs-f76a88011a993d059beafe090a21a20be1cb9f4d.tar.gz
libguestfs-f76a88011a993d059beafe090a21a20be1cb9f4d.tar.xz
libguestfs-f76a88011a993d059beafe090a21a20be1cb9f4d.zip
Replace 'int' with 'size_t' passim.
Analyze all uses of 'int' in the code, and replace with 'size_t' where appropriate.
Diffstat (limited to 'fish')
-rw-r--r--fish/fish.c24
-rw-r--r--fish/fish.h2
-rw-r--r--fish/glob.c8
-rw-r--r--fish/inspect.c2
-rw-r--r--fish/progress.c9
-rw-r--r--fish/rc.c3
-rw-r--r--fish/tilde.c2
7 files changed, 26 insertions, 24 deletions
diff --git a/fish/fish.c b/fish/fish.c
index 8e3e9fb2..8bfea325 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -60,9 +60,9 @@ static int launch (void);
static void interactive (void);
static void shell_script (void);
static void script (int prompt);
-static void cmdline (char *argv[], int optind, int argc);
+static void cmdline (char *argv[], size_t optind, size_t argc);
static struct parsed_command parse_command_line (char *buf, int *exit_on_error_rtn);
-static int parse_quoted_string (char *p);
+static ssize_t parse_quoted_string (char *p);
static int execute_and_inline (const char *cmd, int exit_on_error);
static void error_cb (guestfs_h *g, void *data, const char *msg);
static void initialize_readline (void);
@@ -624,7 +624,7 @@ rl_gets (int prompt)
#endif /* HAVE_LIBREADLINE */
static char buf[8192];
- int len;
+ size_t len;
if (prompt) printf (FISH);
line_read = fgets (buf, sizeof buf, stdin);
@@ -701,7 +701,7 @@ parse_command_line (char *buf, int *exit_on_error_rtn)
{
struct parsed_command pcmd;
char *p, *pend;
- int len;
+ ssize_t len;
int tilde_candidate;
int r;
const size_t argv_len = sizeof pcmd.argv / sizeof pcmd.argv[0];
@@ -880,7 +880,7 @@ hexdigit (char d)
* with the true character. Since the string is returned in place,
* the escapes must make the string shorter.
*/
-static int
+static ssize_t
parse_quoted_string (char *p)
{
char *start = p;
@@ -991,7 +991,7 @@ execute_and_inline (const char *cmd, int global_exit_on_error)
}
static void
-cmdline (char *argv[], int optind, int argc)
+cmdline (char *argv[], size_t optind, size_t argc)
{
const char *cmd;
char **params;
@@ -1040,7 +1040,7 @@ int
issue_command (const char *cmd, char *argv[], const char *pipecmd,
int rc_exit_on_error_flag)
{
- int argc;
+ size_t argc;
int stdout_saved_fd = -1;
int pid = 0;
int r;
@@ -1208,17 +1208,17 @@ error_cb (guestfs_h *g, void *data, const char *msg)
void
free_strings (char **argv)
{
- int argc;
+ size_t argc;
for (argc = 0; argv[argc] != NULL; ++argc)
free (argv[argc]);
free (argv);
}
-int
+size_t
count_strings (char *const *argv)
{
- int c;
+ size_t c;
for (c = 0; argv[c]; ++c)
;
@@ -1228,7 +1228,7 @@ count_strings (char *const *argv)
void
print_strings (char *const *argv)
{
- int argc;
+ size_t argc;
for (argc = 0; argv[argc] != NULL; ++argc)
printf ("%s\n", argv[argc]);
@@ -1237,7 +1237,7 @@ print_strings (char *const *argv)
void
print_table (char *const *argv)
{
- int i;
+ size_t i;
for (i = 0; argv[i] != NULL; i += 2)
printf ("%s: %s\n", argv[i], argv[i+1]);
diff --git a/fish/fish.h b/fish/fish.h
index 668202d7..b4b05fe5 100644
--- a/fish/fish.h
+++ b/fish/fish.h
@@ -69,7 +69,7 @@ extern int issue_command (const char *cmd, char *argv[], const char *pipe, int r
extern void list_builtin_commands (void);
extern int display_builtin_command (const char *cmd);
extern void free_strings (char **argv);
-extern int count_strings (char *const *argv);
+extern size_t count_strings (char *const *argv);
extern void print_strings (char *const *argv);
extern void print_table (char *const *argv);
extern int is_true (const char *str);
diff --git a/fish/glob.c b/fish/glob.c
index 0141040a..108eda3b 100644
--- a/fish/glob.c
+++ b/fish/glob.c
@@ -28,7 +28,7 @@
/* 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, size_t argc, char ***globs, int *posn, int *count, int *r);
+static void glob_issue (char *cmd, size_t argc, char ***globs, size_t *posn, size_t *count, int *r);
int
run_glob (const char *cmd, size_t argc, char *argv[])
@@ -44,8 +44,8 @@ run_glob (const char *cmd, size_t argc, char *argv[])
* argv[1-].
*/
char **globs[argc];
- int posn[argc];
- int count[argc];
+ size_t posn[argc];
+ size_t count[argc];
size_t i;
int r = 0;
@@ -131,7 +131,7 @@ run_glob (const char *cmd, size_t argc, char *argv[])
static void
glob_issue (char *cmd, size_t argc,
- char ***globs, int *posn, int *count,
+ char ***globs, size_t *posn, size_t *count,
int *r)
{
size_t i;
diff --git a/fish/inspect.c b/fish/inspect.c
index f93367b3..3358cd48 100644
--- a/fish/inspect.c
+++ b/fish/inspect.c
@@ -36,7 +36,7 @@ static char *root = NULL;
static void
free_strings (char **argv)
{
- int argc;
+ size_t argc;
for (argc = 0; argv[argc] != NULL; ++argc)
free (argv[argc]);
diff --git a/fish/progress.c b/fish/progress.c
index 6c30e952..c296f40c 100644
--- a/fish/progress.c
+++ b/fish/progress.c
@@ -88,7 +88,7 @@ rmsd_get_standard_deviation (const struct rmsd *r)
struct progress_bar {
double start; /* start time of command */
- int count; /* number of progress notifications per cmd */
+ size_t count; /* number of progress notifications per cmd */
struct rmsd rmsd; /* running mean and standard deviation */
int have_terminfo;
int utf8_mode;
@@ -154,7 +154,7 @@ progress_bar_reset (struct progress_bar *bar)
}
static const char *
-spinner (struct progress_bar *bar, int count)
+spinner (struct progress_bar *bar, size_t count)
{
/* Choice of unicode spinners.
*
@@ -262,7 +262,8 @@ void
progress_bar_set (struct progress_bar *bar,
uint64_t position, uint64_t total)
{
- int i, cols, pulse_mode;
+ size_t i, cols;
+ int pulse_mode;
double ratio;
const char *s_open, *s_dot, *s_dash, *s_close;
@@ -307,7 +308,7 @@ progress_bar_set (struct progress_bar *bar,
fputs (s_open, stdout);
if (!pulse_mode) {
- int dots = ratio * (double) (cols - COLS_OVERHEAD);
+ size_t dots = ratio * (double) (cols - COLS_OVERHEAD);
for (i = 0; i < dots; ++i)
fputs (s_dot, stdout);
diff --git a/fish/rc.c b/fish/rc.c
index 4c119f7b..52a2623d 100644
--- a/fish/rc.c
+++ b/fish/rc.c
@@ -36,7 +36,8 @@
#include "rc_protocol.h"
static void
-create_sockpath (pid_t pid, char *sockpath, int len, struct sockaddr_un *addr)
+create_sockpath (pid_t pid, char *sockpath, size_t len,
+ struct sockaddr_un *addr)
{
char dir[128];
uid_t euid = geteuid ();
diff --git a/fish/tilde.c b/fish/tilde.c
index 8ee14370..92679663 100644
--- a/fish/tilde.c
+++ b/fish/tilde.c
@@ -78,7 +78,7 @@ static char *
expand_home (char *orig, const char *append)
{
const char *home;
- int len;
+ size_t len;
char *str;
home = getenv ("HOME");
OSZAR »