search for: cleanup_

Displaying 20 results from an estimated 63 matches for "cleanup_".

Did you mean: cleanups
2016 Jan 22
1
Re: [PATCH v3 2/6] daemon: Split out command() functions and CLEANUP_* macros into separate files.
...te mode 100644 daemon/cleanups.c > create mode 100644 daemon/cleanups.h > create mode 100644 daemon/command.c > create mode 100644 daemon/command.h Mostly LGTM, just a couple of notes below. > +#ifndef GUESTFSD_CLEANUPS_H > +#define GUESTFSD_CLEANUPS_H > + > +/* Use by the CLEANUP_* macros. */ Can you please use the same comment as in guestfs-internal-frontend.h? > diff --git a/daemon/command.c b/daemon/command.c > new file mode 100644 > index 0000000..3e757aa > --- /dev/null > +++ b/daemon/command.c > @@ -0,0 +1,436 @@ > +/* libguestfs - the guestfsd d...
2017 Apr 25
0
[PATCH] daemon: Use CLEANUP_* functions to avoid an explicit free in stub functions.
...; pr " char *r;\n" - | RStringList _ | RHashtable _ -> pr " char **r;\n" - | RStruct (_, typ) -> pr " guestfs_int_%s *r;\n" typ - | RStructList (_, typ) -> pr " guestfs_int_%s_list *r;\n" typ + | RString _ -> pr " CLEANUP_FREE char *r = NULL;\n" + | RStringList _ | RHashtable _ -> pr " CLEANUP_FREE_STRING_LIST char **r = NULL;\n" + | RStruct (_, typ) -> pr " CLEANUP_FREE guestfs_int_%s *r = NULL;\n" typ + | RStructList (_, typ) -> pr " CLEANUP_FREE guestfs_i...
2017 Nov 03
2
[PATCH] daemon: ldm: avoid manual free()
When the LDM code was converted to the CLEANUP_* macros, a free() invocation for a CLEANUP_FREE variable was left in the ldmtool_diskgroup_volumes implementation, causing double-free on success. Updates commit 950951c67de61da27dceca8ffb2079031c13e43b. --- daemon/ldm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/daemon/ldm.c b/daemon/ldm...
2013 Jan 24
2
[PATCH 1/2] lib: Add CLEANUP_FREE macro which automatically calls 'free' when leaving scope.
From: "Richard W.M. Jones" <rjones@redhat.com> Use the macro like this to create temporary variables which are automatically cleaned up when the scope is exited: { CLEANUP_FREE (char *, foo, strdup (bar)); /* char *foo = strdup (bar) */ ... // no need to call free (foo)! } On GCC and LLVM, this is implemented using __attribute__((cleanup(...))). On other compilers, we fall back to a less efficient implementation which saves up the memory allocations and fr...
2017 Mar 10
2
[PATCH 1/2] daemon: generate cleanup handlers for structs
...e_daemon_structs_cleanups_c () = + generate_header CStyle GPLv2plus; + + pr "\ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> + +#include \"daemon.h\" +#include \"guestfs_protocol.h\" + +"; + + pr "/* Cleanup functions used by CLEANUP_* macros. Do not call\n"; + pr " * these functions directly.\n"; + pr " */\n"; + pr "\n"; + + List.iter ( + fun { s_name = typ; s_cols = cols } -> + pr "void\n"; + pr "cleanup_free_int_%s (void *ptr)\n" typ; + pr "...
2016 Jan 21
0
[PATCH v3 2/6] daemon: Split out command() functions and CLEANUP_* macros into separate files.
...to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <augeas.h> + +#include "cleanups.h" + +/* Use by the CLEANUP_* macros. Do not call these directly. */ +void +cleanup_free (void *ptr) +{ + free (* (void **) ptr); +} + +extern void free_strings (char **argv); + +void +cleanup_free_string_list (void *ptr) +{ + free_strings (* (char ***) ptr); +} + +void +cleanup_unlink_free (void *ptr) +{ + char *filename...
2019 Mar 29
1
Re: [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
On 3/29/19 3:40 AM, Richard W.M. Jones wrote: >>> + nbdkit_extents_free (extents2); >>> + >> >> Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters? > > At the moment the CLEANUP_* macros are only available to server code, > not to plugins or filters. They would certainly make plugins and > filters easier to write. I would really like attribute((cleanup)) to > turn up in ISO C one d...
2019 Mar 29
2
Re: [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
...ct nbdkit_extent e = nbdkit_get_extent (extents2, i); > + > + if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) { > + nbdkit_extents_free (extents2); > + return -1; > + } > + } > + nbdkit_extents_free (extents2); > + Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters? -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
2014 Jan 17
0
[PATCH INCOMPLETE] launch: libvirt: Use C macros to simplify XML generation.
...also make a lot + * of assumptions: + * + * - The xmlTextWriterPtr is called 'xo'. It is used implicitly. + * + * - The guestfs handle is called 'g'. It is used implicitly for errors. + * + * - It is safe to 'return -1' on failure. This is OK provided you + * always use CLEANUP_* macros. + * + * - All the "bad" casting is hidden inside the macros. + */ + +/* <element */ +#define start_element(element) \ + if (xmlTextWriterStartElement (xo, BAD_CAST (element)) == -1) { \ + xml_error ("xmlTextWriterStartElement...
2018 Aug 22
2
Re: [PATCH 4/4] java: Link with gnulib to resolve missing hash_free symbol.
On Tuesday, 14 August 2018 15:42:13 CEST Richard W.M. Jones wrote: > --- > java/Makefile.am | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/java/Makefile.am b/java/Makefile.am > index 81c20f266..1bad9a853 100644 > --- a/java/Makefile.am > +++ b/java/Makefile.am > @@ -122,7 +122,8 @@ libguestfs_jni_la_CFLAGS = \ > libguestfs_jni_la_LIBADD
2017 Jun 01
2
[Gluster-devel] Empty info file preventing glusterd from starting
...izing translator failed > > >>>>>>>> [2017-05-06 03:33:39.827784] E [graph.c:661:glusterfs_graph_ > activate] > > >>>>>>>> 0-graph: init failed > > >>>>>>>> [2017-05-06 03:33:39.828396] W [glusterfsd.c:1238:cleanup_ > and_exit] > > >>>>>>>> (-->/usr/sbin/glusterd(glusterfs_volumes_init-0x1b0b8) > > >>>>>>>> [0x1000a648] -->/usr/sbin/glusterd(glusterfs_process_volfp- > 0x1b210) > > >>>>>>>> [0x1000a4d8] -->/...
2017 Jun 01
0
[Gluster-devel] Empty info file preventing glusterd from starting
...led > > > >>>>>>>> [2017-05-06 03:33:39.827784] E [graph.c:661:glusterfs_graph_ > > activate] > > > >>>>>>>> 0-graph: init failed > > > >>>>>>>> [2017-05-06 03:33:39.828396] W [glusterfsd.c:1238:cleanup_ > > and_exit] > > > >>>>>>>> (-->/usr/sbin/glusterd(glusterfs_volumes_init-0x1b0b8) > > > >>>>>>>> [0x1000a648] -->/usr/sbin/glusterd(glusterfs_process_volfp- > > 0x1b210) > > > >>>>>>>...
2017 Jun 19
0
[PATCH v7 13/13] daemon: Link guestfsd with libutils.
...;btrfs filesystem show' command"); return NULL; } diff --git a/daemon/cleanups.c b/daemon/cleanups.c index 3102cf94b..b4767178a 100644 --- a/daemon/cleanups.c +++ b/daemon/cleanups.c @@ -24,51 +24,7 @@ #include <augeas.h> -#include "cleanups.h" - -/* Use by the CLEANUP_* macros. Do not call these directly. */ -void -cleanup_free (void *ptr) -{ - free (* (void **) ptr); -} - -extern void free_strings (char **argv); - -void -cleanup_free_string_list (void *ptr) -{ - free_strings (* (char ***) ptr); -} - -void -cleanup_unlink_free (void *ptr) -{ - char *filename...
2018 Nov 02
0
[PATCH v3 2/4] common/utils: Move libxml2 writer macros to a common header file.
...sumptions: + * + * =over 4 + * + * =item * + * + * The C<xmlTextWriterPtr> is called C<xo>. It is used implicitly + * by all the macros. + * + * =item * + * + * On failure, a function called C<xml_error> is called which you must + * define (usually as a macro). You must use C<CLEANUP_*> macros in + * your functions if you want correct cleanup of local variables along + * the error path. + * + * =item * + * + * All the "bad" casting is hidden inside the macros. + * + * =back + */ + +#ifndef GUESTFS_LIBXML2_WRITER_MACROS_H_ +#define GUESTFS_LIBXML2_WRITER_MACROS_H_ +...
2015 Jun 12
1
[PATCH] btrfs: use CLEANUP_FREE_STRING_LIST for list free
As Pino's comment, we should take advantage of macro CLEANUP_FREE_STRING_LIST. Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> --- daemon/btrfs.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 39392f7..fd93d43 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -409,7 +40...
2015 Jun 30
0
[PATCH v4 5/7] daemon: add get_random_uuid
...D(str_udevadm, udevadm); +GUESTFSD_EXT_CMD(str_uuidgen, uuidgen); #ifndef MAX # define MAX(a,b) ((a)>(b)?(a):(b)) @@ -1509,6 +1510,24 @@ udev_settle (void) fprintf (stderr, "warning: udevadm command failed\n"); } +char * +get_random_uuid (void) +{ + int r; + char *out; + CLEANUP_FREE char *err = NULL; + + r = command (&out, &err, str_uuidgen, NULL); + if (r == -1) { + reply_with_error ("%s", err); + return NULL; + } + + /* caller free */ + return out; + +} + /* Use by the CLEANUP_* macros. Do not call these directly. */ void cleanup_free (vo...
2017 Nov 03
0
Re: [PATCH] daemon: ldm: avoid manual free()
On Fri, Nov 03, 2017 at 05:31:19PM +0100, Pino Toscano wrote: > When the LDM code was converted to the CLEANUP_* macros, a free() > invocation for a CLEANUP_FREE variable was left in the > ldmtool_diskgroup_volumes implementation, causing double-free on > success. > > Updates commit 950951c67de61da27dceca8ffb2079031c13e43b. > --- > daemon/ldm.c | 1 - > 1 file changed, 1 deletion(-)...
2018 Aug 22
0
Re: [PATCH 4/4] java: Link with gnulib to resolve missing hash_free symbol.
...e.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at com.redhat.et.libguestfs.GuestFS.<clinit>(GuestFS.java:51) at Bindtests.main(Bindtests.java:33) > The java binding does not explicitly use the hash stuff from gnulib. It uses the CLEANUP_* macros, and they appear to pull in the hash_free function (via guestfs_int_cleanup_hash_free). What does confuse me is why linking with libutils.a causes the hash_free dependency to be pulled in, since if my understanding of static linking is correct it should only pull in whole object files whic...
2019 Mar 29
0
Re: [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
...i); > > + > > + if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) { > > + nbdkit_extents_free (extents2); > > + return -1; > > + } > > + } > > + nbdkit_extents_free (extents2); > > + > > Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters? At the moment the CLEANUP_* macros are only available to server code, not to plugins or filters. They would certainly make plugins and filters easier to write. I would really like attribute((cleanup)) to turn up in ISO C one day :-) Rich. -- Richar...
2023 Mar 15
1
[libnbd PATCH v4 1/3] lib/utils: introduce xwritel() as a more robust and convenient write()
...d the cleanup attribute, and libnbd > didn't. First I thought it was a mistake / oversight, but then I found a > porting note from Rich, in libnbd commit f306e231d294 ("common/utils: > Add extensible string, based on vector", 2022-03-12): > > RWMJ: This removes the CLEANUP_FREE_STRING macro since libnbd does not > use __attribute__((cleanup)). > > and then again in f3828bfd42be ("common/utils: Add new string vector > types", 2022-03-12): > > RWMJ: Removed the CLEANUP_* macros. > Most attributes are merely extensions that aid t...