From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A3D313858D20 for ; Thu, 28 Sep 2023 13:14:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A3D313858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695906875; 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: in-reply-to:in-reply-to:references:references; bh=jjl54audbWyYtDE9paBE7UG8drLaxDGvQ4ucDnDj9uo=; b=fvfGBywxm0TfqGuS+qBCAcru3QY+vp2MYq8LXkwecLeV2P3ygPQebtmMKzwCszRp/MviDl /V7OH0IVqB9FiE1lk/D9qPXD8kzPigFGW5gLw2s77pODUBJBbCFVN/fV8v5bbtwVimTT7l Ff0pGpusqe0TPw+wqTWQfgOm3lsjdOY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-530-TwdtrP1QN1ebYQM4aGGOcQ-1; Thu, 28 Sep 2023 09:14:33 -0400 X-MC-Unique: TwdtrP1QN1ebYQM4aGGOcQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94E27101A53B; Thu, 28 Sep 2023 13:14:33 +0000 (UTC) Received: from oak (unknown [10.22.34.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 777231055466; Thu, 28 Sep 2023 13:14:33 +0000 (UTC) Date: Thu, 28 Sep 2023 09:14:32 -0400 From: Joe Simmons-Talbott To: Andreas Schwab Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] nss: Get rid of alloca usage in makedb's write_output. Message-ID: <20230928131432.GB4098455@oak> References: <20230926135528.3517253-1-josimmon@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP 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 Thu, Sep 28, 2023 at 01:16:00PM +0200, Andreas Schwab wrote: > On Sep 26 2023, Joe Simmons-Talbott wrote: > > > @@ -802,6 +812,7 @@ write_output (int fd) > > assert (iov_nelts <= INT_MAX); > > if (writev (fd, iov, iov_nelts) != keydataoffset) > > { > > + scratch_buffer_free (&sbuf); > > error (0, errno, gettext ("failed to write new database file")); > > return EXIT_FAILURE; > > Does scratch_buffer_free guarantee that errno is not changed? scratch_buffer_free doesn't do anything other than call free when the buffer has been heap-allocated. IIUC free preserves errno since 2.33 in the default free. So I guess if there is a non-default free that doesn't preserve errno then there is no explicit guarantee. Should I adjust scratch_buffer_free to explicitly preserve errno (in a separate patch) or just preserve errno around this one call to scratch_buffer_free? Thanks, Joe