[libvirt] [PATCH v4 3/8] nssmock: Adapt to virmock.h

Peter Krempa pkrempa at redhat.com
Fri May 13 16:17:02 UTC 2016


On Fri, May 13, 2016 at 14:32:04 +0200, Michal Privoznik wrote:
> Instead of introducing our own wrapper for dlsym()
> we can use the one provided by virmock.h.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  tests/nssmock.c | 27 +++++++++------------------
>  1 file changed, 9 insertions(+), 18 deletions(-)
> 
> diff --git a/tests/nssmock.c b/tests/nssmock.c
> index 31b1177..ee1d948 100644
> --- a/tests/nssmock.c
> +++ b/tests/nssmock.c
> @@ -21,21 +21,18 @@
>  #include <config.h>
>  
>  #ifdef NSS
> -# include <stdio.h>
> -# include <stdlib.h>
> -# include <dlfcn.h>
> +# include "virmock.h"

This one is good, but ...


>  # include <sys/types.h>
>  # include <dirent.h>
>  # include <sys/stat.h>
>  # include <fcntl.h>
>  
>  # include "configmake.h"
> -# include "internal.h"
>  # include "virstring.h"
>  # include "viralloc.h"
>  
> -static int (*realopen)(const char *path, int flags, ...);
> -static DIR * (*realopendir)(const char *name);
> +static int (*real_open)(const char *path, int flags, ...);
> +static DIR * (*real_opendir)(const char *name);
>  
>  # define LEASEDIR LOCALSTATEDIR "/lib/libvirt/dnsmasq/"
>  
> @@ -59,17 +56,11 @@ static DIR * (*realopendir)(const char *name);
>  static void
>  init_syms(void)
>  {
> -    if (realopen)
> +    if (real_open)
>          return;
>  
> -# define LOAD_SYM(name)                                                 \
> -    do {                                                                \
> -        if (!(real ## name = dlsym(RTLD_NEXT, #name)))                  \
> -            ABORT("Cannot find real '%s' symbol\n", #name);             \
> -    } while (0)

With this you can also kill ABORT_OOM, ABORT and STDERR macros.

ACK ^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160513/1aa26a83/attachment-0001.sig>


More information about the libvir-list mailing list