From patchwork Thu Jun 29 11:34:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 21329 Received: (qmail 26702 invoked by alias); 29 Jun 2017 11:34:32 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 26689 invoked by uid 89); 29 Jun 2017 11:34:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3167 X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A3E7ACE633 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=fweimer@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A3E7ACE633 Subject: Re: [PATCH] vfprintf: Add test case for user-defined types and format specifiers To: "H.J. Lu" Cc: GNU C Library References: <20170619134830.6E09B402AEC20@oldenburg.str.redhat.com> <7b5f9ce5-abf8-5263-1d80-250fe7571982@redhat.com> From: Florian Weimer Message-ID: Date: Thu, 29 Jun 2017 13:34:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: On 06/29/2017 12:51 PM, H.J. Lu wrote: > On Thu, Jun 29, 2017 at 12:31 AM, Florian Weimer wrote: >> On 06/19/2017 03:48 PM, Florian Weimer wrote: >>> 2017-06-19 Florian Weimer >>> >>> * stdio-common/tst-vfprintf-user-type.c: New file. >>> * stdio-common/Makefile (tests): Add tst-vfprintf-user-type. >> >> I am going to commit this soon. >> > > It fails on i686: > > tst-vfprintf-user-type.c: In function \u2018my_printf_function\u2019: > tst-vfprintf-user-type.c:58:55: error: format \u2018%c\u2019 expects > argument of type \u2018int\u2019, but argument 7 has type > \u2018wchar_t {aka const long int}\u2019 [-Werror=format=] > tst-vfprintf-user-type.c: In function \u2018my_arginfo_function\u2019: > tst-vfprintf-user-type.c:112:55: error: format \u2018%c\u2019 expects > argument of type \u2018int\u2019, but argument 7 has type > \u2018wchar_t {aka const long int}\u2019 [-Werror=format=] Please try the attached patch. The need for the wint_t cast looks like a GCC bug. Thanks, Florian vfprintf: Fix tst-vfprintf-mbs-prec and tst-vfprintf-user-type 2017-06-29 Florian Weimer * stdio-common/tst-vfprintf-user-type.c (my_printf_function): Adjust format string. * stdio-common/Makefile (tst-vfprintf-mbs-prec.out): Add locale dependency. diff --git a/stdio-common/Makefile b/stdio-common/Makefile index 309d83e..622a85f 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -87,6 +87,7 @@ $(objpfx)tst-grouping.out: $(gen-locales) $(objpfx)tst-sprintf.out: $(gen-locales) $(objpfx)tst-sscanf.out: $(gen-locales) $(objpfx)tst-swprintf.out: $(gen-locales) +$(objpfx)tst-vfprintf-mbs-prec.out: $(gen-locales) endif tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace diff --git a/stdio-common/tst-vfprintf-user-type.c b/stdio-common/tst-vfprintf-user-type.c index e9596c3..91ea02f 100644 --- a/stdio-common/tst-vfprintf-user-type.c +++ b/stdio-common/tst-vfprintf-user-type.c @@ -29,6 +29,7 @@ #include #include #include +#include /* Initialized by do_test using register_printf_type. */ static int user_type; @@ -55,8 +56,9 @@ my_printf_function (FILE *fp, const struct printf_info *info, const void *const *args) { if (test_verbose > 0) - printf ("info: %s (%p, %p, {%p}@%p) called for %%%c (prec %d)\n", - __func__, fp, info, args[0], args, info->spec, info->prec); + printf ("info: %s (%p, %p, {%p}@%p) called for %%%lc (prec %d)\n", + __func__, fp, info, args[0], args, (wint_t) info->spec, + info->prec); TEST_VERIFY (info->spec == 'P'); size_t nargs; @@ -109,8 +111,9 @@ my_arginfo_function (const struct printf_info *info, if (info->spec != 'P') return -1; if (test_verbose > 0) - printf ("info: %s (%p, %zu, %p, %p) called for %%%c (prec %d)\n", - __func__, info, n, argtypes, size, info->spec, info->prec); + printf ("info: %s (%p, %zu, %p, %p) called for %%%lc (prec %d)\n", + __func__, info, n, argtypes, size, (wint_t) info->spec, + info->prec); TEST_VERIFY_EXIT (n >= 1); size_t nargs;