Re: [kvm-unit-tests PATCH 21/32] lib: printf-style report prefixes

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

 



On 21.04.2017 02:49, David Matlack wrote:
> From: Peter Feiner <pfeiner@xxxxxxxxxx>
> 
> Signed-off-by: Peter Feiner <pfeiner@xxxxxxxxxx>
> Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>
> ---
>  lib/libcflat.h |  1 +
>  lib/report.c   | 38 +++++++++++++++++++++++++++++++++-----
>  2 files changed, 34 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index 5d356df75f1f..05c18543dd72 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -96,6 +96,7 @@ extern int vsnprintf(char *buf, int size, const char *fmt, va_list va)
>  extern int vprintf(const char *fmt, va_list va)
>  					__attribute__((format(printf, 1, 0)));
>  
> +void report_prefix_pushf(const char *prefix_fmt, ...);
>  extern void report_prefix_push(const char *prefix);
>  extern void report_prefix_pop(void);
>  extern void report(const char *msg_fmt, bool pass, ...);
> diff --git a/lib/report.c b/lib/report.c
> index e24e81382f9e..1033f1e44e99 100644
> --- a/lib/report.c
> +++ b/lib/report.c
> @@ -17,14 +17,42 @@ static unsigned int tests, failures, xfailures, skipped;
>  static char prefixes[256];
>  static struct spinlock lock;
>  
> -void report_prefix_push(const char *prefix)
> +#define PREFIX_DELIMITER ": "
> +
> +void report_prefix_pushf(const char *prefix_fmt, ...)
>  {
> +	va_list va;
> +	int len;
> +	int start;
> +
>  	spin_lock(&lock);
> -	strcat(prefixes, prefix);
> -	strcat(prefixes, ": ");
> +
> +	len = strlen(prefixes);
> +	assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
> +	start = len;
> +
> +	va_start(va, prefix_fmt);
> +	len += vsnprintf(&prefixes[len], sizeof(prefixes) - len, prefix_fmt,
> +			 va);
> +	va_end(va);
> +	assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
> +
> +	assert_msg(!strstr(&prefixes[start], PREFIX_DELIMITER),
> +		   "Prefix \"%s\" contains delimiter \"" PREFIX_DELIMITER "\"",
> +		   &prefixes[start]);
> +
> +	len += snprintf(&prefixes[len], sizeof(prefixes) - len,
> +			PREFIX_DELIMITER);
> +	assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
> +
>  	spin_unlock(&lock);
>  }

I can not compile the current master of kvm-unit-tests anymore... I
think it is due to the above patch. I get now these error messages:

powerpc64-linux-gnu-gcc  -std=gnu99 -ffreestanding -Wextra -O2 -I lib -I lib/libfdt -Wa,-mregnames -g -MMD -MF lib/.report.d -Wall -Werror  -fomit-frame-pointer    -Wno-frame-address   -fno-pic   -mbig-endian   -c -o lib/report.o lib/report.c
In file included from lib/report.c:13:0:
lib/report.c: In function ‘report_prefix_pushf’:
lib/report.c:38:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
  assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
                 ^
lib/libcflat.h:133:8: note: in definition of macro ‘assert_msg’
  if (!(cond)) {       \
        ^
lib/report.c:45:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
  assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
                 ^
lib/libcflat.h:133:8: note: in definition of macro ‘assert_msg’
  if (!(cond)) {       \
        ^
lib/report.c:53:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
  assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
                 ^
lib/libcflat.h:133:8: note: in definition of macro ‘assert_msg’
  if (!(cond)) {       \
        ^
 Thomas




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux