util: Fix virGetLastErrorMessage to return proper error when 'err' is NULL
util: Fix virGetLastErrorMessage to return proper error when 'err' is NULL

Both virGetLastError and virGetLastErrorMessage call virLastErrorObject method
that returns a thread-local error object. However, if a direct call to malloc
or pthread_setspecific (probably also due to malloc, since it sets ENOMEM)
fail, virLastErrorObject returns NULL which, although incorrectly interpreted
by virGetLastError as no error, still requires the caller to check for NULL
pointer. This isn't the case with virGetLastErrorMessage that also treated it
incorrectly as no error, but returned the literal "no error".
This patch tweaks the checks in the virGetLastErrorMessage function, so that
if virLastErrorObject failed, it returned "unknown error" which is equivalent
to the current approach with virGetLastError and if it returned NULL,
"unknown error" was set.

Signed-off-by: Erik Skultety <2c14d38fa47c8799f1b9c16280abe27f8edfec6e@redhat.com>

datto/libvirt,olafhering/libvirt,olafhering/libvirt,eskultety/libvirt,datto/libvirt,jardasgit/libvirt,taget/libvirt,zippy2/libvirt,VenkatDatta/libvirt,eskultety/libvirt,nertpinx/libvirt,taget/libvirt,libvirt/libvirt,libvirt/libvirt,zippy2/libvirt,fabianfreyer/libvirt,crobinso/libvirt,datto/libvirt,eskultety/libvirt,fabianfreyer/libvirt,taget/libvirt,jardasgit/libvirt,jfehlig/libvirt,libvirt/libvirt,crobinso/libvirt,andreabolognani/libvirt,olafhering/libvirt,taget/libvirt,andreabolognani/libvirt,VenkatDatta/libvirt,jfehlig/libvirt,jfehlig/libvirt,zippy2/libvirt,nertpinx/libvirt,andreabolognani/libvirt,olafhering/libvirt,jardasgit/libvirt,jardasgit/libvirt,crobinso/libvirt,crobinso/libvirt,eskultety/libvirt,VenkatDatta/libvirt,datto/libvirt,fabianfreyer/libvirt,fabianfreyer/libvirt,libvirt/libvirt,eskultety/libvirt,VenkatDatta/libvirt,zippy2/libvirt,andreabolognani/libvirt,nertpinx/libvirt,jfehlig/libvirt,VenkatDatta/libvirt,nertpinx/libvirt,nertpinx/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,jardasgit/libvirt,taget/libvirt,datto/libvirt