search for: add_str

Displaying 20 results from an estimated 142 matches for "add_str".

2012 Mar 13
2
[PATCH 0/2] 'int' to 'size_t' changes
These two patches are probably not completely independent, but separating them is a lot of work. With *both* patches applied, all the tests and extra-tests pass. That's no guarantee however that there isn't a mistake, so I don't think this patch is a candidate for the 1.16 branch, until it's had a lot more testing in development. Rich.
2011 Dec 05
1
[PATCH] blkid: split the RHEL5 which can't support some options
...kid", "-c", "/dev/null", + "-p", "-i", "-o", "export", device, NULL); if (r == -1) { reply_with_error("%s", err); goto error; @@ -142,12 +166,12 @@ do_blkid(const char *device) } } + if (add_string(&ret, &size, &alloc, NULL) == -1) goto error; + free(out); free(err); free(lines); - if (add_string(&ret, &size, &alloc, NULL) == -1) return NULL; - return ret; error: @@ -158,3 +182,45 @@ error: return NULL; } + +static char ** +blkid_without_p_op...
2014 Nov 21
3
Re: [PATCH 6/6] New API: btrfs_subvolume_show
...;is btrfs root") != NULL) { Take care of adding a space before parenthesis (also in other parts of this patch). > + reply_with_error ("%s is btrfs root", subvolume); > + return NULL; > + } > + > + /* The first line is the path of the subvolume. */ > + if (add_string (&ret, strdup("path")) == -1) { add_string duplicates the string, so you don't need to do that manually. > + return NULL; > + } > + if (add_string (&ret, out) == -1) { > + return NULL; > + } > + > + /* Read the lines and split into "key...
2014 Nov 21
0
[PATCH 6/6] New API: btrfs_subvolume_show
...e btrfs root, `btrfs subvolume show' reports: + * <path> is btrfs root + */ + if (strstr(out, "is btrfs root") != NULL) { + reply_with_error ("%s is btrfs root", subvolume); + return NULL; + } + + /* The first line is the path of the subvolume. */ + if (add_string (&ret, strdup("path")) == -1) { + return NULL; + } + if (add_string (&ret, out) == -1) { + return NULL; + } + + /* Read the lines and split into "key: value". */ + while (*p) { + /* leading spaces and tabs */ + while (*p && c_isspace (*p)) p++...
2014 Dec 02
0
[PATCH 2/8] New API: btrfs_subvolume_show
...' reports: + * <path> is btrfs root + */ + if (strstr (key, "is btrfs root") != NULL) { + reply_with_error ("%s is btrfs root", subvolume); + return NULL; + } + + /* The first line is the path of the subvolume. */ + if (key && !value) { + if (add_string (&ret, "path") == -1) + return NULL; + if (add_string (&ret, key) == -1) + return NULL; + } else { + if (add_string (&ret, key) == -1) + return NULL; + if (add_string (&ret, value) == -1) + return NULL; + } + + /* Read the lines and split...
2014 Nov 24
0
Re: [PATCH 6/6] New API: btrfs_subvolume_show
...dding a space before parenthesis (also in other parts of > this patch). Okay. > > > + reply_with_error ("%s is btrfs root", subvolume); > > + return NULL; > > + } > > + > > + /* The first line is the path of the subvolume. */ > > + if (add_string (&ret, strdup("path")) == -1) { > > add_string duplicates the string, so you don't need to do that > manually. Okay. > > > + return NULL; > > + } > > + if (add_string (&ret, out) == -1) { > > + return NULL; > > + } >...
2011 Dec 05
1
[PATCH] mdadm: fix a possible memory leak when error
When add_string() error, it returned without free the *ret*. Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com> --- daemon/md.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/md.c b/daemon/md.c index 5a4d815..8d28878 100644 --- a/daemon/md.c +++ b/daemon/md.c @...
2014 Dec 05
1
Re: [PATCH 2/8] New API: btrfs_subvolume_show
...root > + */ > + if (strstr (key, "is btrfs root") != NULL) { > + reply_with_error ("%s is btrfs root", subvolume); > + return NULL; > + } > + > + /* The first line is the path of the subvolume. */ > + if (key && !value) { > + if (add_string (&ret, "path") == -1) > + return NULL; > + if (add_string (&ret, key) == -1) > + return NULL; > + } else { > + if (add_string (&ret, key) == -1) > + return NULL; > + if (add_string (&ret, value) == -1) > + return NUL...
2016 Jul 07
2
[PATCH 1/2] daemon: free the string on stringsbuf add failure
If add_string_nodup fails free the passed string instead of leaking it, as that string would have been owned by the stringbuf. Adapt few places to this behaviour. --- daemon/btrfs.c | 4 +--- daemon/devsparts.c | 8 ++++---- daemon/guestfsd.c | 1 + 3 files changed, 6 insertions(+), 7 deletions(-) dif...
2017 Nov 03
1
[PATCH] daemon: btrfs: remove dead check
...2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index f11902b21..d363ada6d 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -990,7 +990,7 @@ do_btrfs_subvolume_show (const char *subvolume) return NULL; } } else { - if (add_string (&ret, key ? key : "") == -1) + if (add_string (&ret, key) == -1) return NULL; if (value && !STREQ (value, "-")) { if (add_string (&ret, value) == -1) -- 2.13.6
2016 Jul 07
0
[PATCH 2/2] daemon: fix cleanup of stringsbuf usages
...ex 9716796..1d0f5a0 100644 --- a/daemon/available.c +++ b/daemon/available.c @@ -53,7 +53,7 @@ char ** do_available_all_groups (void) { size_t i; - DECLARE_STRINGSBUF (groups); + CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (groups); for (i = 0; optgroups[i].group != NULL; ++i) { if (add_string (&groups, optgroups[i].group) == -1) @@ -63,7 +63,7 @@ do_available_all_groups (void) if (end_stringsbuf (&groups) == -1) return NULL; - return groups.argv; /* caller frees */ + return take_stringsbuf (&groups); /* caller frees */ } /* Search for f...
2009 Aug 03
1
[PATCH] Recognise cd-rom devices in devsparts.c
.../* RHBZ#514505: Some versions of qemu <= 0.10 add a - * CD-ROM device even though we didn't request it. Try to - * detect this by seeing if the device contains media. - */ - int fd = open (buf, O_RDONLY); - if (fd == -1) { - perror (buf); - continue; + if (add_string (&r, &size, &alloc, dev_path) == -1) { + return 0; } - close (fd); - if (add_string (&r, &size, &alloc, buf) == -1) { - closedir (dir); - return NULL; - } - } + return 1; } - if (add_string (&r, &size, &alloc, NULL)...
2014 Nov 21
13
[PATCH 0/6] btrfs support part1: subvolume commands
Hi, This is the part1 of improving btrfs support. This series adds missing parameters to btrfs_subvolume_snapshot and btrfs_subvolume_create, and adds two new API btrfs_subvolume_get_default and btrfs_subvolume_show. Other parts will follow. Regards, Hu Hu Tao (6): btrfs: correct words about subvolume and snapshot btrfs: add optional parameter `ro' to btrfs_subvolume_snapshot btrfs:
2012 Jan 24
14
[PATCH 00/14] Run the daemon under valgrind and fix resultant errors.
This patch series lets you run the daemon under valgrind. Many errors were found and fixed. With the complete series applied, valgrind doesn't show any errors.
2017 Apr 19
1
[PATCH] daemon: Remove use of fixed-size stack buffers.
.../devsparts.c @@ -125,13 +125,16 @@ foreach_block_device (block_dev_func_t func, bool return_md) static int add_device (const char *device, struct stringsbuf *r) { - char dev_path[256]; - snprintf (dev_path, sizeof dev_path, "/dev/%s", device); + CLEANUP_FREE char *dev_path; - if (add_string (r, dev_path) == -1) { + if (asprintf (&dev_path, "/dev/%s", device) == -1) { + reply_with_perror ("asprintf"); return -1; } + if (add_string (r, dev_path) == -1) + return -1; + return 0; } @@ -153,10 +156,13 @@ do_list_devices (void) static int...
2015 Jul 13
1
[PATCH] daemon: add a space after func name to fit code-style
...p = analyze_line (p, &key, &value, ':'); while (key) { /* snapshot is special, see the output above */ if (STREQLEN (key, "Snapshot(s)", sizeof ("Snapshot(s)") - 1)) { @@ -1093,7 +1093,7 @@ do_btrfs_subvolume_show (const char *subvolume) if (add_string (&ret, key) == -1) return NULL; - p = analyze_line(p, &key, &value, ':'); + p = analyze_line (p, &key, &value, ':'); while (key && !value) { ss = realloc (ss, ss_len + strlen (key) + 1); @@ -1107,7 +1107,7 @@ do...
2015 Jun 16
2
[PATCH] New API: btrfs_device_stats
...; + p = analyze_line(p, &key, &value, ':'); while (key) { /* snapshot is special, see the output above */ if (STREQLEN (key, "Snapshot(s)", sizeof ("Snapshot(s)") - 1)) { @@ -994,7 +994,7 @@ do_btrfs_subvolume_show (const char *subvolume) if (add_string (&ret, key) == -1) return NULL; - p = analyze_line(p, &key, &value); + p = analyze_line(p, &key, &value, ':'); while (key && !value) { ss = realloc (ss, ss_len + strlen (key) + 1); @@ -1008,7 +1008,7 @@ do_btrfs_subvolu...
2010 Mar 11
2
[PATCH FOR DISCUSSION ONLY] Rewrite libguestfs-supermin-helper in C.
..., "including host file %s (directly referenced)\n", + hostfile); + + cpio_append_stat (hostfile, &statbuf); + } /* Ignore files that don't exist. */ + } +} + +/*----------*/ +/* Helper functions. *NOTE* we never bother to free anything. */ + +static void +add_string (char ***argv, size_t *size, size_t *alloc, const char *str) +{ + char **new_argv; + char *new_str; + + if (*size >= *alloc) { + *alloc += 64; + new_argv = realloc (*argv, *alloc * sizeof (char *)); + if (new_argv == NULL) { + perror ("realloc"); + exit (EXIT_F...
2015 Jun 17
2
Re: [PATCH] New API: btrfs_device_stats
...39;:'); >> while (key) { >> /* snapshot is special, see the output above */ >> if (STREQLEN (key, "Snapshot(s)", sizeof ("Snapshot(s)") - 1)) { >> @@ -994,7 +994,7 @@ do_btrfs_subvolume_show (const char *subvolume) >> if (add_string (&ret, key) == -1) >> return NULL; >> >> - p = analyze_line(p, &key, &value); >> + p = analyze_line(p, &key, &value, ':'); >> >> while (key && !value) { >> ss = realloc (ss, ss_l...
2014 Nov 26
7
[PATCH v2 0/5] btrfs support part1: subvolume commands
Hi, This is the part1 of improving btrfs support. This series adds missing parameters to btrfs_subvolume_snapshot and btrfs_subvolume_create, and adds two new API btrfs_subvolume_get_default and btrfs_subvolume_show. Other parts will follow. Regards, Hu changes: v2: - add 'once_had_no_optargs = true' for btrfs_subvolume_snapshot and btrfs_subvolume_create - improved documents