From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65316 invoked by alias); 18 Dec 2018 13:27:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 65293 invoked by uid 89); 18 Dec 2018 13:27:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=Hx-languages-length:2204, H*F:D*br X-HELO: mo19.mail-out.ovh.net Date: Tue, 18 Dec 2018 13:37:00 -0000 From: "Gabriel F. T. Gomes" To: Florian Weimer CC: Joseph Myers , Subject: Re: [PATCH 01/14] Prepare vfprintf to use __printf_fp/__printf_fphex with float128 arg Message-ID: <20181218112739.47ad5968@tereshkova> In-Reply-To: <871s6f2iei.fsf@oldenburg2.str.redhat.com> References: <20180621021023.17036-1-gabriel@inconstante.eti.br> <20180621021023.17036-2-gabriel@inconstante.eti.br> <20181207181557.067ca7e3@tereshkova> <871s6f2iei.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 17714346184746913428 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudeikedgtdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-SW-Source: 2018-12/txt/msg00638.txt.bz2 On Tue, 18 Dec 2018, Florian Weimer wrote: >* Gabriel F. T. Gomes: >> >> @@ -1887,7 +1930,12 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format, >> (args_value[cnt].pa_user, ap_savep); >> } >> else >> - args_value[cnt].pa_long_double = 0.0; >> + { >> + args_value[cnt].pa_long_double = 0.0; >> +#if __HAVE_FLOAT128_UNLIKE_LDBL >> + args_value[cnt].pa_float128 = 0; >> +#endif >> + } > >This bit doesn't look right to me because args_value[cnt] is a union. >You need to assign to the right member, or perhaps zero-initialize using >memset. Hmm, the original code doesn't seem to be dealing with anything particular to the long double type. It seems that assigning to .pa_long_double, rather than to other members, was an arbitrary decision. Do you know why .pa_long_double was chosen? So, if this code is just zero-initializing the memory, do you think I should zero-initialize the whole of args_value/argsbuf.data when it gets expanded (see below)? Then I could remove the else block entirely. Like this: diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c index 61769e0ce1..17f1bae796 100644 --- a/stdio-common/vfprintf-internal.c +++ b/stdio-common/vfprintf-internal.c @@ -1789,10 +1789,11 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format, if (!scratch_buffer_set_array_size (&argsbuf, nargs, bytes_per_arg)) { done = -1; goto all_done; } + memset (argsbuf.data, 0, argsbuf.size); args_value = argsbuf.data; /* Set up the remaining two arrays to each point past the end of the prior array, since space for all three has been allocated now. */ args_size = &args_value[nargs].pa_int; @@ -1884,12 +1885,10 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format, { args_value[cnt].pa_user = alloca (args_size[cnt]); (*__printf_va_arg_table[args_type[cnt] - PA_LAST]) (args_value[cnt].pa_user, ap_savep); } - else - args_value[cnt].pa_long_double = 0.0; break; case -1: /* Error case. Not all parameters appear in N$ format strings. We have no way to determine their type. */ assert ((mode_flags & PRINTF_FORTIFY) != 0);