aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-11-05 16:56:28 -0400
committerMike Frysinger <vapier@gentoo.org>2021-11-05 16:56:28 -0400
commit2f99599214eeb36b329ddc90559c17210312f7d1 (patch)
treecbc7b288ef904cd8f1c9e4a5d954d230e5476dc1 /src
parentlibsandbox/libsbutil: use faccessat for file-existence tests (diff)
downloadsandbox-2f99599214eeb36b329ddc90559c17210312f7d1.tar.gz
sandbox-2f99599214eeb36b329ddc90559c17210312f7d1.tar.bz2
sandbox-2f99599214eeb36b329ddc90559c17210312f7d1.zip
sandbox: move xasprintf helper here
Since this is only used by sandbox, and is not usable by libsandbox, move it out of libsbutil. Leave a note behind for possible future macros too. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/sandbox.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/sandbox.h b/src/sandbox.h
index 28961f5..477973a 100644
--- a/src/sandbox.h
+++ b/src/sandbox.h
@@ -40,6 +40,14 @@ extern pid_t setup_namespaces(void);
#define sb_err(fmt, args...) _sb_err(warn, fmt, ## args)
#define sb_perr(fmt, args...) _sb_err(pwarn, fmt, ## args)
+#define xasprintf(fmt, ...) \
+({ \
+ int _ret = asprintf(fmt, __VA_ARGS__); \
+ if (_ret == 0) \
+ sb_perr("asprintf(%s) failed", #fmt); \
+ _ret; \
+})
+
/* Option parsing related code */
extern void parseargs(int argc, char *argv[]);
extern int opt_use_namespaces;