summaryrefslogtreecommitdiffstats
path: root/utils.h
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-29 17:43:12 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2018-10-29 17:45:19 +1100
commitf55fa7657dd217a71af9198e0bc5754c0cd335ce (patch)
treea89858857e3e0ec7672866d086e12b3c58cf84e3 /utils.h
parent96aa81e1426e64875850616e12c3415231ed14f8 (diff)
parent188712f58b309d94d26d7468a792326c464a7eda (diff)
Merge remote-tracking branch 'agl/master' into flounder
Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
Diffstat (limited to 'utils.h')
-rw-r--r--utils.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/utils.h b/utils.h
new file mode 100644
index 0000000..0931e82
--- /dev/null
+++ b/utils.h
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AVIRT - ALSA Virtual Soundcard
+ *
+ * Copyright (c) 2010-2018 Fiberdyne Systems Pty Ltd
+ *
+ * utils.h - Some useful macros/utils for AVIRT
+ */
+
+#ifndef __SOUND_AVIRT_UTILS_H
+#define __SOUND_AVIRT_UTILS_H
+
+#define CHK_ERR(errno) \
+ do { \
+ if ((errno) < 0) \
+ return (errno); \
+ } while (0)
+
+#define CHK_ERR_V(errno, fmt, args...) \
+ do { \
+ if ((errno) < 0) { \
+ DERROR(D_LOGNAME, (fmt), ##args) \
+ return (errno); \
+ } \
+ } while (0)
+
+#define CHK_NULL(x) \
+ do { \
+ if (!(x)) \
+ return -EFAULT; \
+ } while (0)
+
+#define CHK_NULL_V(x, fmt, args...) \
+ do { \
+ if (!(x)) { \
+ DERROR(D_LOGNAME, "[ERRNO: %d] " fmt, -EFAULT, \
+ ##args); \
+ return -EFAULT; \
+ } \
+ } while (0)
+
+#endif /* __SOUND_AVIRT_UTILS_H */