[libvirt] [PATCH v2 3/8] util: Generate a common internal only error print
Peter Krempa
pkrempa at redhat.com
Mon Jun 5 07:39:45 UTC 2017
On Fri, Jun 02, 2017 at 06:17:17 -0400, John Ferlan wrote:
> If virObjectIsClass fails "internally" to virobject.c, create a macro to
> generate the VIR_WARN describing what the problem is. Also improve the
> checks and message a bit to indicate which was the failure - whether the
> obj was NULL or just not the right class
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
> src/util/virobject.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/src/util/virobject.c b/src/util/virobject.c
> index 34805d3..9f5f187 100644
> --- a/src/util/virobject.c
> +++ b/src/util/virobject.c
> @@ -47,6 +47,16 @@ struct _virClass {
> virObjectDisposeCallback dispose;
> };
>
> +#define VIR_OBJECT_USAGE_PRINT_WARNING(anyobj, objclass) \
> + do { \
> + virObjectPtr obj = anyobj; \
> + if (!obj) \
> + VIR_WARN("Object %p is not a virObject class instance", anyobj);\
Is this really helpful?
Object (nil) is not a virObject class instance.
%p does not make sense since it's always NULL, and also obviously a
null pointer is not a class instance ...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170605/2545306a/attachment-0001.sig>
More information about the libvir-list
mailing list