mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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:
@@ -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);
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user