getline: Rename &n parameter as &allocsize.

The second parameter passed into getline(3) is the size of the
allocated buffer, *NOT* the length of the returned line.  This can be
confusing, so rename this parameter as 'allocsize' consistently
throughout the code.

This is just code motion.
This commit is contained in:
Richard W.M. Jones
2013-02-11 12:43:48 +00:00
parent e0a3a7c1e5
commit e527aed895
6 changed files with 12 additions and 12 deletions

View File

@@ -155,8 +155,8 @@ set_filter (const char *filter)
}
CLEANUP_FREE char *line = NULL;
size_t len = 0;
while (getline (&line, &len, ifp) != -1) {
size_t allocsize = 0;
while (getline (&line, &allocsize, ifp) != -1) {
int r;
if (is_filter_line (line)) {
r = fprintf (ofp, " filter = [ %s ]\n", filter);

View File

@@ -442,7 +442,7 @@ do_md_stat (const char *md)
size_t mdlen;
FILE *fp;
CLEANUP_FREE char *line = NULL;
size_t len = 0;
size_t allocsize = 0;
ssize_t n;
guestfs_int_mdstat_list *ret = NULL;
@@ -457,7 +457,7 @@ do_md_stat (const char *md)
}
/* Search for a line which begins with "<md> : ". */
while ((n = getline (&line, &len, fp)) != -1) {
while ((n = getline (&line, &allocsize, fp)) != -1) {
if (STRPREFIX (line, md) &&
line[mdlen] == ' ' && line[mdlen+1] == ':' && line[mdlen+2] == ' ') {
/* Found it. */

View File

@@ -104,7 +104,7 @@ auth_callback (guestfs_h *g,
size_t i;
char *prompt;
char *reply = NULL;
size_t replylen;
size_t allocsize;
char *pass;
ssize_t len;
int r;
@@ -129,7 +129,7 @@ auth_callback (guestfs_h *g,
printf ("%s: ", prompt);
free (prompt);
len = getline (&reply, &replylen, stdin);
len = getline (&reply, &allocsize, stdin);
if (len == -1) {
perror ("getline");
exit (EXIT_FAILURE);

View File

@@ -972,7 +972,7 @@ execute_and_inline (const char *cmd, int global_exit_on_error)
{
FILE *pp;
CLEANUP_FREE char *line = NULL;
size_t len = 0;
size_t allocsize = 0;
ssize_t n;
int exit_on_error;
struct parsed_command pcmd;
@@ -983,7 +983,7 @@ execute_and_inline (const char *cmd, int global_exit_on_error)
return -1;
}
while ((n = getline (&line, &len, pp)) != -1) {
while ((n = getline (&line, &allocsize, pp)) != -1) {
exit_on_error = global_exit_on_error;
/* Chomp final line ending which parse_command_line would not expect. */

View File

@@ -41,7 +41,7 @@ read_key (const char *param)
char *ret = NULL;
int tty;
int tcset = 0;
size_t n = 0;
size_t allocsize = 0;
ssize_t len;
/* Read and write to /dev/tty if available. */
@@ -69,7 +69,7 @@ read_key (const char *param)
}
}
len = getline (&ret, &n, infp);
len = getline (&ret, &allocsize, infp);
if (len == -1) {
perror ("getline");
ret = NULL;

View File

@@ -466,13 +466,13 @@ read_line_from (const char *cmd)
{
FILE *pp;
char *ret = NULL;
size_t n;
size_t allocsize;
pp = popen (cmd, "r");
if (pp == NULL)
error (EXIT_FAILURE, errno, "%s: external command failed", cmd);
if (getline (&ret, &n, pp) == -1)
if (getline (&ret, &allocsize, pp) == -1)
error (EXIT_FAILURE, errno, "could not read line from external command");
if (pclose (pp) == -1)