# HG changeset patch # User Matti Hamalainen # Date 1456241939 -7200 # Node ID 46a0fab6ca1f9e4f3568eb01571e99d25faa827f # Parent b6f2efd0f6f219d7f9f27e61ef95e25d05f0d8cb Fix snprintf() test running. diff -r b6f2efd0f6f2 -r 46a0fab6ca1f tests.c --- a/tests.c Tue Feb 23 17:30:07 2016 +0200 +++ b/tests.c Tue Feb 23 17:38:59 2016 +0200 @@ -192,10 +192,8 @@ memset(buf1, SET_SENTINEL_BYTE, SET_BUF_SIZE+2); buf1[SET_BUF_SIZE+1] = 0; memset(buf2, SET_SENTINEL_BYTE, SET_BUF_SIZE+2); buf2[SET_BUF_SIZE+1] = 0; - va_copy(tmp, ap); - - ret1 = th_vsnprintf(buf1, len, fmt, ap); - ret2 = vsnprintf(buf2, len, fmt, tmp); + va_copy(tmp, ap); ret1 = th_vsnprintf(buf1, len, fmt, tmp); + va_copy(tmp, ap); ret2 = vsnprintf(buf2, len, fmt, tmp); test_result_msg(&ctx, ret1 == ret2, "retval mismatch %d [th] != %d [libc]", ret1, ret2); test_result_msg(&ctx, strcmp(buf1, buf2) == 0, "result mismatch '%s' [th] != '%s' [libc]", buf1, buf2); @@ -205,7 +203,8 @@ // Test th_strdup_vprintf() test_start(&ctx, "th_strdup_vprintf('%s')", fmt); - char *str = th_strdup_vprintf(fmt, ap); + va_copy(tmp, ap); + char *str = th_strdup_vprintf(fmt, tmp); test_result_msg(&ctx, str != NULL, "result NULL"); th_free(str); }