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=-4.0 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 5B1251F934 for ; Wed, 7 Apr 2021 00:52:47 +0000 (UTC) Received: from localhost ([::1]:49156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTwR4-0003AB-Bh for normalperson@yhbt.net; Tue, 06 Apr 2021 20:52:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTwQs-00039I-5X for bug-gnulib@gnu.org; Tue, 06 Apr 2021 20:52:34 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTwQg-0005cB-TM for bug-gnulib@gnu.org; Tue, 06 Apr 2021 20:52:33 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 6E5A1160105 for ; Tue, 6 Apr 2021 17:52:18 -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 w5Wo1dqf76C8; Tue, 6 Apr 2021 17:52:17 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9DDE21600FE; Tue, 6 Apr 2021 17:52:17 -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 IrAHb5Noh6tc; Tue, 6 Apr 2021 17:52:17 -0700 (PDT) Received: from day.example.com (cpe-23-243-218-95.socal.res.rr.com [23.243.218.95]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 7784B1600EA; Tue, 6 Apr 2021 17:52:17 -0700 (PDT) From: Paul Eggert To: bug-gnulib@gnu.org Subject: [PATCH 2/3] backupfile: less-aggressive buffer growth Date: Tue, 6 Apr 2021 17:52:10 -0700 Message-Id: <20210407005211.240077-2-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210407005211.240077-1-eggert@cs.ucla.edu> References: <20210407005211.240077-1-eggert@cs.ucla.edu> MIME-Version: 1.0 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: Include intprops.h. (numbered_backup): Grow buffer by the usual 50%, not 100%. This is easier to do now that we have xalloc_count_t. * modules/backup-rename, modules/backupfile: Depend on intprops. --- ChangeLog | 6 ++++++ lib/backupfile.c | 6 ++++-- modules/backup-rename | 1 + modules/backupfile | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c3ea48fe..c68da0df8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2021-04-06 Paul Eggert =20 + backupfile: less-aggressive buffer growth + * lib/backupfile.c: Include intprops.h. + (numbered_backup): Grow buffer by the usual 50%, not 100%. + This is easier to do now that we have xalloc_count_t. + * modules/backup-rename, modules/backupfile: Depend on intprops. + xalloc-oversized: export xalloc_count_t * lib/xalloc-oversized.h (__xalloc_oversized, xalloc_oversized): * lib/xmalloca.h (nmalloca): diff --git a/lib/backupfile.c b/lib/backupfile.c index c53e3f335..1e427e8de 100644 --- a/lib/backupfile.c +++ b/lib/backupfile.c @@ -34,6 +34,7 @@ #include "attribute.h" #include "basename-lgpl.h" #include "idx.h" +#include "intprops.h" #include "opendirat.h" #include "renameatu.h" #include "xalloc-oversized.h" @@ -270,8 +271,9 @@ 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) { - if (! xalloc_oversized (new_buffer_size, 2)) - new_buffer_size *=3D 2; + xalloc_count_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); if (!new_buf) { diff --git a/modules/backup-rename b/modules/backup-rename index 4497b3350..c50e874ff 100644 --- a/modules/backup-rename +++ b/modules/backup-rename @@ -17,6 +17,7 @@ closedir d-ino fcntl-h idx +intprops memcmp opendirat readdir diff --git a/modules/backupfile b/modules/backupfile index 41cf99b02..42c8c9ed5 100644 --- a/modules/backupfile +++ b/modules/backupfile @@ -17,6 +17,7 @@ closedir d-ino fcntl-h idx +intprops memcmp opendirat readdir --=20 2.27.0