From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by sourceware.org (Postfix) with ESMTPS id 303C33858D3C for ; Fri, 2 Jun 2023 10:01:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 303C33858D3C 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 D27995C1908; Fri, 2 Jun 2023 10:01:34 +0000 (UTC) Received: from pdx1-sub0-mail-a269.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 5C4A05C124B; Fri, 2 Jun 2023 10:01:34 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1685700094; a=rsa-sha256; cv=none; b=NndRQXsV5440ZPP1CktCEV3rkQQ68AjbkzMnAC7VDXdTq8+EDZu50YwAO55vhl/R1/5AvL UNAsTxtHs/BWK2Psd0vrC7su0M4IdQvzNzbTqz1awFVFpTF6DWTXr8e3P7jgvwZIKsmvrT FIj9NKC2ukZnskfJHU5v96ZYZa2IfBFAnq8/jgPqvsWfCXueF09c5A17OAs9QyXHExEWxl O94bgYFyFm4Ow903tXWIfkzNxsateCOUGBF6UbH+BBZq+pvmKwKPvOBrb5+0fQ730Rkbai 4IvfnJprj8N3VZNELq3yHo2cr1881YvK/ODhuqe0siLfGrMuBWxib0VTI0HpOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1685700094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc: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=p2HIiptDQPuvcKtwxmQIhTUzmWrIiJ/pnA30S2lHllM=; b=fvG+MzTa4b5NtB5t9vbhsTSLyPmHvqwL6yNACY8Wa7T3MEXIkrB+LxfFYBkzd4p6qlNAso XRZqGlzDHCBurEcifrV6Px8NEL/VzoDK1kNIf8n1PFKACN7g6TtXzLgPXRomlHc7ZBE2za rMvngJNaXuoidKCXEiD9XsV74+0+DjbOX4+Tn52Swg6Ja85On/4sqI/uljyQ5NVe0Y3wZS AKvwjpbVVv+tAL6Y84c8H8yBTnG9AZ2Y3RNBePYWBnw3OEo71a8YpbiQNiEgVfyaHSJXQ5 NW0JKbLdvTjkW1URNS4vu9zETe0/yEGxMEcSCUrW3xdSF41hZYs+Q2J1Dis+XA== ARC-Authentication-Results: i=1; rspamd-58dcc7d645-fdsj6; 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-Trouble-Oafish: 56c6b0e176aa6943_1685700094601_555536759 X-MC-Loop-Signature: 1685700094601:3226306432 X-MC-Ingress-Time: 1685700094601 Received: from pdx1-sub0-mail-a269.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.125.42.141 (trex/6.8.1); Fri, 02 Jun 2023 10:01:34 +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 (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a269.dreamhost.com (Postfix) with ESMTPSA id 4QXdnV0DgMz8T; Fri, 2 Jun 2023 03:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1685700094; bh=p2HIiptDQPuvcKtwxmQIhTUzmWrIiJ/pnA30S2lHllM=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=KXkHKrUbrBYfbBqz8h232z1ZtoZmmPsUs+yK6JWc9/uqaKS3f8tnuuHnOvrWmpU8W YT+9taLXrHuEoYlWfY8PWM/XkGHXk7UqeW6z5jCsMReKO+729orTdgVt6VjFhc7O+K gDV1Qw/723Umwqme+0mDU9I/D2VmoOogr85t9sjRdHExJAdI+Ysw19jd86WuinA8dI K5k9mEzEEbyKilacNXhb8Nppi2ByMYzOjPDw/eDe5ztJtLFrPp+LxRifj4B8NQ2YBn nnS3CEH8A1EUzAsGccWFXimVRme+T/bEXoGKYxVBk600YWbZwD7gNcID4kGj+Thppq u4l4PIFjWghwA== Message-ID: <98a43ee2-1e36-e3bd-a303-6943b2abd0b4@gotplt.org> Date: Fri, 2 Jun 2023 06:01:32 -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] Move {read,write}_all functions to a dedicated header Content-Language: en-US To: Frederic Berat Cc: libc-alpha@sourceware.org References: <20230601155556.104745-1-fberat@redhat.com> From: Siddhesh Poyarekar In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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_H5,RCVD_IN_MSPIKE_WL,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-06-02 02:10, Frederic Berat wrote: >> >> This needs a copyright header. >> > > What's the rule for that ? It's a bit confusing since there isn't a > copyright header in most of the headers in "include", so I assumed it > didn't need it. I don't know if there's a rule for it, but AFAICT, most recently added files appear to have the copyright header. > >>> @@ -0,0 +1,48 @@ >>> +#ifndef _UNISTD_EXT_H >>> +#define _UNISTD_EXT_H >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +/* Helpers used in catgets/gencat.c and malloc/memusage*.c */ >>> +static inline 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, >>> + gettext ("write of %zu bytes failed after %td: %m"), >>> + length, p - (const char *) buffer); >>> + >>> + if (ret == 0) >>> + error (EXIT_FAILURE, 0, >>> + gettext ("write returned 0 after writing %td bytes of %zu"), >>> + p - (const char *) buffer, length); >>> + p += ret; >>> + } >>> +} >>> + >>> +static inline void >>> +read_all (int fd, void *buffer, size_t length) >>> +{ >>> + char *p = buffer; >>> + char *end = p + length; >>> + while (p < end) >>> + { >>> + ssize_t ret = read (fd, p, end - p); >>> + if (ret < 0) >>> + error (EXIT_FAILURE, errno, >>> + gettext ("read of %zu bytes failed after %td: %m"), >>> + length, p - (char *) buffer); >>> + >>> + p += ret; >>> + } >>> +} >>> + >>> +#endif >>> diff --git a/malloc/memusage.c b/malloc/memusage.c >>> index 53a3630651..1c6930188c 100644 >>> --- a/malloc/memusage.c >>> +++ b/malloc/memusage.c >>> @@ -18,10 +18,7 @@ >>> >>> #include >>> #include >>> -#include >>> -#include >>> #include >>> -#include >> >> You shouldn't remove these headers because gettext gets used despite the >> unistd_ext.h usage, resulting in an implicit, transitive dependency. >> Does it break anything if you don't remove these includes? >> > > Nothing breaks if I keep these headers. > I actually removed them because they were added in the patch that > introduced write_all/read_all. > Since I moved write/read_all in the header, I removed the headers that > were introduced with them, but I admit I didn't check if they were > actually missing before that. OK, then it makes sense to just leave them in I think, since other code in this file needs them. Thanks, Sid