summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Lewandowski <k.lewandowsk@samsung.com>2022-08-02 13:11:01 +0200
committerKarol Lewandowski <k.lewandowsk@samsung.com>2022-08-05 00:12:06 +0200
commite8e544b33da5f984221babb762525212a3685708 (patch)
tree3d3866c8314d15f25dbbdfe210991c20f905f7c5
parentec3ba6e783cade2b2c3fa87d14005c0a5352c348 (diff)
downloadsessiond-e8e544b33da5f984221babb762525212a3685708.tar.gz
sessiond-e8e544b33da5f984221babb762525212a3685708.tar.bz2
sessiond-e8e544b33da5f984221babb762525212a3685708.zip
library: Add macro to validate and get gvariant without explicit 'return'
This allows more flexible handling of type errors, without creating new macro for each new case. Change-Id: I6ea3311ed24da9021e6a2b65eab31cea894ae0c0
-rw-r--r--libsessiond/src/lib.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/libsessiond/src/lib.h b/libsessiond/src/lib.h
index 2915b55..a57d81d 100644
--- a/libsessiond/src/lib.h
+++ b/libsessiond/src/lib.h
@@ -41,6 +41,9 @@ typedef struct {
#define COMPARATOR_RESULT_SAME_ 0
#define COMPARATOR_RESULT_DIFFERENT_ -1
+// Implementation note: g_variant_get() returns void, hence ", true"
+#define typechecked_g_variant_get(var, type, args...) (g_variant_is_of_type(var, G_VARIANT_TYPE(type)) ? (g_variant_get(var, type, args), true) : false)
+
//use when function return err value
#define maybe_g_variant_get_or_ret_diff_(var, c_str_, args...) \
if (!g_variant_is_of_type(var, G_VARIANT_TYPE(c_str_) )) { return COMPARATOR_RESULT_DIFFERENT_ ; } \