diff options
author | Eric Blake <eblake@redhat.com> | 2013-12-27 18:12:05 -0700 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2014-01-09 13:55:20 -0700 |
commit | 916273eb94071ea723642758133ab420250a9294 (patch) | |
tree | ccb0404f7ebb98ba670dbc9c57a3e1dddf9c7a4e /src/datatypes.h | |
parent | 9ec935d56593f2b066e34bb58056368f13f89b13 (diff) | |
download | libvirt-916273eb94071ea723642758133ab420250a9294.tar.gz |
maint: improve VIR_ERR_INVALID_SECRET usage
While all errors related to invalid secrets appeared to be
consistent, we might as well continue the trend of using a
common macro. Just as in commit 6e130ddc, the difference
between VIR_IS_SECRET and VIR_IS_CONNECTED_SECRET is moot
(due to reference counting, any valid secret must be tied to
a valid domain). For now, we don't need virCheckSecretGoto().
* src/datatypes.h (virCheckSecretReturn): New macro.
(VIR_IS_SECRET, VIR_IS_CONNECTED_SECRET): Drop unused macros.
* src/libvirt.c: Use macro throughout.
(virLibSecretError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'src/datatypes.h')
-rw-r--r-- | src/datatypes.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/datatypes.h b/src/datatypes.h index f478360124..29a1096ccd 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -178,10 +178,19 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_SECRET(obj) \ - (virObjectIsClass((obj), virSecretClass)) -# define VIR_IS_CONNECTED_SECRET(obj) \ - (VIR_IS_SECRET(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckSecretReturn(obj, retval) \ + do { \ + virSecretPtr _secret = (obj); \ + if (!virObjectIsClass(_secret, virSecretClass) || \ + !virObjectIsClass(_secret->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_SECRET, \ + VIR_ERR_INVALID_SECRET, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) # define VIR_IS_STREAM(obj) \ (virObjectIsClass((obj), virStreamClass)) |