From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by sourceware.org (Postfix) with ESMTPS id BE9843858D28 for ; Wed, 24 May 2023 22:47:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE9843858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 3A5AC5C17C9; Wed, 24 May 2023 22:47:18 +0000 (UTC) Received: from pdx1-sub0-mail-a306.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id A0C515C09CE; Wed, 24 May 2023 22:47:17 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1684968437; a=rsa-sha256; cv=none; b=68m59/vGuYR6jn7xX6zgGNSu/can7ArG/qb5rg5Elfb+Hnrk4ghLT4qbPGhoKflA5AEKV2 FnxIuvsW+Z1NrfWsxYnTsI5FfwC2zhhnzf4LUfHXuJztSob4FobfYJyewDi3xpZWDtnO4k rcm60p1JJF9pjldAad8nk0evWUU+JNfDi8BMuFSjSv5gCEOJ4mDQLXUIVqAC5wTBgJcnLJ v/cNRsfq1Rjuipq/JZp8e2g4f/5Do7ekQSP9k/32L40eAklzf8agdXIBUY/yP4+eVQhwdt /pAPwF5NaTfQ3QI0t987woPCrqeh+JArzYEjBSgzK2Qf9elXby7QWnu76D/70Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1684968437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9dXBcvlK1QxiFkB9lUMYrvrTzscacHyaziVk7vG4YPM=; b=PxrpC6Yzz65mJ2UaAnrvrZWqpjqE8EFegnrcY8hAP7eka5CJsl7sS0HcwNXGI4KXz/3yiS JqpZKWp6O9eJSE5Z02hqdVJhnjsBFPbVbiEL7nKS4YkLAu2imM8qaC5PsutsBkKydxnTSB qc53mMGTfb8ofuoOCVkKkGg79xXK1XMf27dW4AO0t8cLzYF+4M5KP/PL+xyg1zS4PW1qno rfvExSxVwQ9en6WE5wzE2A4iLXjLzhkVI9AFgLrrVbxsXSAq5itcJ6dus/jLIVtdSoTcbE /+nezjnqZnOR5JZY0+lbhiEnnJogxcg9F1R2Ecy8KWkzMX+QlPB3ATmD6eg5cQ== ARC-Authentication-Results: i=1; rspamd-5cdf8fd7d9-r57sl; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Lettuce-Left: 3e7282266436f0e2_1684968437911_3283018156 X-MC-Loop-Signature: 1684968437911:2794451883 X-MC-Ingress-Time: 1684968437911 Received: from pdx1-sub0-mail-a306.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.116.217.246 (trex/6.8.1); Wed, 24 May 2023 22:47:17 +0000 Received: from [192.168.0.182] (bras-vprn-toroon4834w-lp130-02-142-113-138-85.dsl.bell.ca [142.113.138.85]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a306.dreamhost.com (Postfix) with ESMTPSA id 4QRRC91Yh0zNt; Wed, 24 May 2023 15:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1684968437; bh=9dXBcvlK1QxiFkB9lUMYrvrTzscacHyaziVk7vG4YPM=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=twfNnLKPUYRH3gIIKYlQwLLqPyYyHyNPm6JJYrvIO+v5fHc261IRA9GM2crOqUfMP DlD/YvNDcojeoBeAg9niHQfNKWoywWSl8n1t9lFumj0hqy1veUZ2WyV0Wcg35mSFEo JfSx1uFIwTA17T0p/Mc/44qGhscKVva25cA4VixliO0zfTy4c1X5n70VPdsEQVkFtD 5OK+sdMVMo7B5eI4ZbxmCJnN1cI6ILg4YtIao/VF8RGvbr+wHS3m2lMDdBFNAY2F93 eBSqv0RoZ8Yg79RWi9x9T/p3pwlmn9dxMThO+MA+nh9iGNV++lpPU7NMUq2PFnyY6q WyIwK2DRi+Odg== Message-ID: <70ec4887-fcd5-ee15-0d16-e773a92ead62@gotplt.org> Date: Wed, 24 May 2023 18:47:15 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v4 01/15] catgets/gencat.c: fix warn unused result Content-Language: en-US To: =?UTF-8?B?RnLDqWTDqXJpYyBCw6lyYXQ=?= , libc-alpha@sourceware.org References: <20230428122142.928135-1-fberat@redhat.com> <20230428122142.928135-2-fberat@redhat.com> From: Siddhesh Poyarekar In-Reply-To: <20230428122142.928135-2-fberat@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3037.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2023-04-28 08:21, Frédéric Bérat wrote: > Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in > glibc. > --- > catgets/gencat.c | 41 ++++++++++++++++++++++++++++++----------- > 1 file changed, 30 insertions(+), 11 deletions(-) > > diff --git a/catgets/gencat.c b/catgets/gencat.c > index 61ac797349..ceaec67011 100644 > --- a/catgets/gencat.c > +++ b/catgets/gencat.c > @@ -838,6 +838,26 @@ invalid character: message ignored")); > return current; > } > > +static void > +write_all (int fd, const void *buffer, size_t length) > +{ > + const char *p = buffer; > + const char *end = p + length; > + while (p < end) > + { > + ssize_t ret = write (fd, p, end - p); > + if (ret < 0) > + error (EXIT_FAILURE, errno, > + "write of %zu bytes failed after %td: %m", > + length, p - (const char *) buffer); > + > + if (ret == 0) > + error (EXIT_FAILURE, 0, > + "write return 0 after writing %td bytes of %zu", > + p - (const char *) buffer, length); Shouldn't the strings be marked for translation with gettext? It looks OK to me otherwise. Thanks, Sid > + p += ret; > + } > +} > > static void > write_out (struct catalog *catalog, const char *output_name, > @@ -927,12 +947,11 @@ write_out (struct catalog *catalog, const char *output_name, > obj.plane_size = best_size; > obj.plane_depth = best_depth; > > + uint32_t array_size = best_size * best_depth * sizeof (uint32_t) * 3; > /* Allocate room for all needed arrays. */ > - array1 = > - (uint32_t *) alloca (best_size * best_depth * sizeof (uint32_t) * 3); > - memset (array1, '\0', best_size * best_depth * sizeof (uint32_t) * 3); > - array2 > - = (uint32_t *) alloca (best_size * best_depth * sizeof (uint32_t) * 3); > + array1 = (uint32_t *) alloca (array_size); > + memset (array1, '\0', array_size); > + array2 = (uint32_t *) alloca (array_size); > obstack_init (&string_pool); > > set_run = catalog->all_sets; > @@ -985,22 +1004,22 @@ write_out (struct catalog *catalog, const char *output_name, > } > > /* Write out header. */ > - write (fd, &obj, sizeof (obj)); > + write_all(fd, &obj, sizeof (obj)); > > /* We always write out the little endian version of the index > arrays. */ > #if __BYTE_ORDER == __LITTLE_ENDIAN > - write (fd, array1, best_size * best_depth * sizeof (uint32_t) * 3); > - write (fd, array2, best_size * best_depth * sizeof (uint32_t) * 3); > + write_all(fd, array1, array_size); > + write_all(fd, array2, array_size); > #elif __BYTE_ORDER == __BIG_ENDIAN > - write (fd, array2, best_size * best_depth * sizeof (uint32_t) * 3); > - write (fd, array1, best_size * best_depth * sizeof (uint32_t) * 3); > + write_all(fd, array2, array_size); > + write_all(fd, array1, array_size); > #else > # error Cannot handle __BYTE_ORDER byte order > #endif > > /* Finally write the strings. */ > - write (fd, strings, strings_size); > + write_all(fd, strings, strings_size); > > if (fd != STDOUT_FILENO) > close (fd);