From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 4ABB71F4B4 for ; Mon, 19 Apr 2021 04:02:44 +0000 (UTC) Received: from localhost ([::1]:39616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYL7T-0007zc-EF for normalperson@yhbt.net; Mon, 19 Apr 2021 00:02:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYL7I-0007wr-6G for bug-gnulib@gnu.org; Mon, 19 Apr 2021 00:02:32 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:46260) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYL7G-0004Fu-DC for bug-gnulib@gnu.org; Mon, 19 Apr 2021 00:02:31 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 6DE5C16011D; Sun, 18 Apr 2021 21:02:29 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id ViT_QSh3Hene; Sun, 18 Apr 2021 21:02:28 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A34CB16011A; Sun, 18 Apr 2021 21:02:28 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id RGoFEZLhbwkS; Sun, 18 Apr 2021 21:02:28 -0700 (PDT) Received: from day.example.com (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 777D4160095; Sun, 18 Apr 2021 21:02:28 -0700 (PDT) From: Paul Eggert To: bug-gnulib@gnu.org, berrange@redhat.com Subject: [PATCH 2/8] backupfile: simplify via realloc-gnu Date: Sun, 18 Apr 2021 21:01:53 -0700 Message-Id: <20210419040158.1902066-2-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210419040158.1902066-1-eggert@cs.ucla.edu> References: <20210419040158.1902066-1-eggert@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Eggert Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" * lib/backupfile.c: Do not include xalloc-oversized.h. (numbered_backup): Simplify now that realloc will do the right thing about ptrdiff_t overflow. * modules/backupfile (Depends-on): Add realloc-gnu; remove xalloc-oversized. --- ChangeLog | 7 +++++++ lib/backupfile.c | 3 +-- modules/backupfile | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2d12058e..e00a5b7c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2021-04-18 Paul Eggert =20 + backupfile: simplify via realloc-gnu + * lib/backupfile.c: Do not include xalloc-oversized.h. + (numbered_backup): Simplify now that realloc will do the right + thing about ptrdiff_t overflow. + * modules/backupfile (Depends-on): Add realloc-gnu; + remove xalloc-oversized. + safe-alloc: improve doc * doc/safe-alloc.texi: Clarify that reallocating an array appends uninitialized storage. Say =E2=80=98sizeof *p=E2=80=99 rather than =E2= =80=98sizeof(*p)=E2=80=99 diff --git a/lib/backupfile.c b/lib/backupfile.c index 1e427e8de..bc03dd614 100644 --- a/lib/backupfile.c +++ b/lib/backupfile.c @@ -37,7 +37,6 @@ #include "intprops.h" #include "opendirat.h" #include "renameatu.h" -#include "xalloc-oversized.h" =20 #ifndef _D_EXACT_NAMLEN # define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) @@ -271,7 +270,7 @@ numbered_backup (int dir_fd, char **buffer, size_t bu= ffer_size, size_t filelen, size_t new_buffer_size =3D filelen + 2 + versionlenmax + 2; if (buffer_size < new_buffer_size) { - xalloc_count_t grown; + size_t grown; if (! INT_ADD_WRAPV (new_buffer_size, new_buffer_size >> 1, &g= rown)) new_buffer_size =3D grown; char *new_buf =3D realloc (buf, new_buffer_size); diff --git a/modules/backupfile b/modules/backupfile index 42c8c9ed5..342a7bdff 100644 --- a/modules/backupfile +++ b/modules/backupfile @@ -21,11 +21,11 @@ intprops memcmp opendirat readdir +realloc-gnu renameatu stdbool stdint xalloc-die -xalloc-oversized =20 configure.ac: gl_BACKUPFILE --=20 2.27.0