This is a simple macro with no dependencies. Allow it to be used from any program. --- daemon/daemon.h | 12 ------------ lib/guestfs-internal-all.h | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/daemon/daemon.h b/daemon/daemon.h index 3af5c0e..8097bfc 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -340,18 +340,6 @@ is_zero (const char *buffer, size_t size) return 1; } -/* Helper for building up short lists of arguments. Your code has to - * define MAX_ARGS to a suitable value. - */ -#define ADD_ARG(argv,i,v) \ - do { \ - if ((i) >= MAX_ARGS) { \ - fprintf (stderr, "%s: %d: internal error: exceeded MAX_ARGS (%zu) when constructing the command line\n", __FILE__, __LINE__, (size_t) MAX_ARGS); \ - abort (); \ - } \ - (argv)[(i)++] = (v); \ - } while (0) - /* Helper for functions that need a root filesystem mounted. * NB. Cannot be used for FileIn functions. */ diff --git a/lib/guestfs-internal-all.h b/lib/guestfs-internal-all.h index dbf9735..0c841ff 100644 --- a/lib/guestfs-internal-all.h +++ b/lib/guestfs-internal-all.h @@ -1,5 +1,5 @@ /* libguestfs - * Copyright (C) 2013 Red Hat Inc. + * Copyright (C) 2013-2017 Red Hat Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -58,6 +58,21 @@ #define STRCASEPREFIX(a,b) (strncasecmp((a),(b),strlen((b))) == 0) #define STRSUFFIX(a,b) (strlen((a)) >= strlen((b)) && STREQ((a)+strlen((a))-strlen((b)),(b))) +/* A simple (indeed, simplistic) way to build up short lists of + * arguments. Your code must define MAX_ARGS to a suitable "larger + * than could ever be needed" value. (If the value is exceeded then + * your code will abort). For more complex needs, use something else + * more suitable. + */ +#define ADD_ARG(argv,i,v) \ + do { \ + if ((i) >= MAX_ARGS) { \ + fprintf (stderr, "%s: %d: internal error: exceeded MAX_ARGS (%zu) when constructing the command line\n", __FILE__, __LINE__, (size_t) MAX_ARGS); \ + abort (); \ + } \ + (argv)[(i)++] = (v); \ + } while (0) + #ifndef SOCK_CLOEXEC #define SOCK_CLOEXEC 0 #endif -- 2.10.2