[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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 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 ^^

Attachment: signature.asc
Description: Digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]