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 C085B1F5AE for ; Sat, 12 Jun 2021 00:26:20 +0000 (UTC) Received: from localhost ([::1]:57948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrrTf-0008OX-QL for normalperson@yhbt.net; Fri, 11 Jun 2021 20:26:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrrTc-0008LN-2F for bug-gnulib@gnu.org; Fri, 11 Jun 2021 20:26:16 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39082) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrrTY-0003lR-Jj for bug-gnulib@gnu.org; Fri, 11 Jun 2021 20:26:15 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 03C09160125 for ; Fri, 11 Jun 2021 17:26:11 -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 UkH4TRuJq_BC; Fri, 11 Jun 2021 17:26:10 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3446C16011D; Fri, 11 Jun 2021 17:26:10 -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 xuEMvlSmXWGI; Fri, 11 Jun 2021 17:26:10 -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 0414B16011B; Fri, 11 Jun 2021 17:26:10 -0700 (PDT) From: Paul Eggert To: bug-gnulib@gnu.org Subject: [PATCH 06/13] getusershell: prefer idx_t for indexes Date: Fri, 11 Jun 2021 17:25:46 -0700 Message-Id: <20210612002553.1105537-6-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210612002553.1105537-1-eggert@cs.ucla.edu> References: <20210612002553.1105537-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/getusershell.c (line_size, readname): Prefer idx_t to size_t for indexes, using idx_t-related allocators. --- ChangeLog | 1 + lib/getusershell.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1fca94c03..84ccb3645 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ (icatalloc, enlist, allocmust, dfamust): * lib/exclude.c (struct exclude_pattern, free_exclude_segment) (file_pattern_matches, add_exclude, add_exclude_fp): + * lib/getusershell.c (line_size, readname): Prefer idx_t to size_t for indexes, and use idx_t-related allocators. * lib/basename.c: Do not include xstrndup.h. (basename): Simplify by always using memcpy. diff --git a/lib/getusershell.c b/lib/getusershell.c index be8a06845..32acd76c0 100644 --- a/lib/getusershell.c +++ b/lib/getusershell.c @@ -43,7 +43,7 @@ # include "unlocked-io.h" #endif =20 -static size_t readname (char **, size_t *, FILE *); +static idx_t readname (char **, idx_t *, FILE *); =20 #if ! defined ADDITIONAL_DEFAULT_SHELLS && defined __MSDOS__ # define ADDITIONAL_DEFAULT_SHELLS \ @@ -70,7 +70,7 @@ static FILE *shellstream =3D NULL; static char *line =3D NULL; =20 /* Number of bytes allocated for 'line'. */ -static size_t line_size =3D 0; +static idx_t line_size =3D 0; =0C /* Return an entry from the shells file, ignoring comment lines. If the file doesn't exist, use the list in DEFAULT_SHELLS (above). @@ -137,8 +137,8 @@ endusershell (void) Return the number of bytes placed in *NAME if some nonempty sequence was found, otherwise 0. */ =20 -static size_t -readname (char **name, size_t *size, FILE *stream) +static idx_t +readname (char **name, idx_t *size, FILE *stream) { int c; size_t name_index =3D 0; @@ -150,7 +150,7 @@ readname (char **name, size_t *size, FILE *stream) for (;;) { if (*size <=3D name_index) - *name =3D x2nrealloc (*name, size, sizeof **name); + *name =3D xpalloc (*name, size, 1, -1, sizeof **name); if (c =3D=3D EOF || isspace (c)) break; (*name)[name_index++] =3D c; --=20 2.30.2