From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UdbiANyMomq0gTwAWB0awg (envelope-from ) for ; Thu, 10 Sep 2026 06:56:28 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YIb4z2jJ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F21ED1E09E; Thu, 10 Sep 2026 06:56:27 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 713A21E091 for ; Thu, 10 Sep 2026 06:56:27 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B9E3A4BA79B4 for ; Thu, 10 Sep 2026 10:56:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9E3A4BA79B4 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YIb4z2jJ Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id AD8EE4BB58D2 for ; Thu, 10 Sep 2026 10:55:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD8EE4BB58D2 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AD8EE4BB58D2 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789037747; cv=none; b=qrM7HsYaZYPXD8VuT0/7tmhVkJ0lBrguZWroQVaiJPrd0rVqz3ahS3ajHBaj+0ONTyByhzumIXXIqAotpy0w+0cDGx0XSbma917rpoBUAvG7cAXyjOGgqMrfRLll1000+ojC5NXCc3JlY0SNu29L+OrhchgnGsojXOvqw4BEUCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789037747; c=relaxed/simple; bh=+ZJx9IdCNjbZssFOevx1ku+znFKO4H3QtwQcdJx9blk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=iv4xi11Efe5TG3MDiVfPzQ4O51LNRn+oPVVUoapw1DcXquScuBTDHtmruGt7oUykavZNX9BW5yw/R+7SAOXk1N5EoUJlXIjHT4BVvcOi8882NjHQbx3PelcFhsbBUx6Pf9eMh71TdtuVCipvPTvR0wQCKdWCDLs0fV3dGa5YznY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YIb4z2jJ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD8EE4BB58D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789037746; 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=E6zblS06DNRqPhgMuddK5IY+Xgzwi1HK8J0Y3niwRec=; b=YIb4z2jJhnwHnJopCVoeNS+tjM7WJktMXxTAM1c5Ln8BTpvTiCPwMZk1CA+OpRR6wbox73 SKe/W3dMWiOjYdtwxetEHJebiW3anwrUABvh4G8XNMpeVfNKefZmFgisY6EcjhdqVE1rXV lFOFW18PEWM4ScONn4x+5OGsewse2+s= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-nRyqXkBbPH6JX9-Fqf-Mbw-1; Thu, 10 Sep 2026 06:55:45 -0400 X-MC-Unique: nRyqXkBbPH6JX9-Fqf-Mbw-1 X-Mimecast-MFC-AGG-ID: nRyqXkBbPH6JX9-Fqf-Mbw_1789037744 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49cd74fc1aaso39861995e9.1 for ; Thu, 10 Sep 2026 03:55:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789037744; x=1789642544; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=E6zblS06DNRqPhgMuddK5IY+Xgzwi1HK8J0Y3niwRec=; b=TPWhq6KpWWH8o12nHMO2M+KBp0z0OVaViIfqbYbYg++UwiYgpwjz1t+zw55DZL0/TR CH5bEWxrYgSzsGsOjkkO+anmeZxj0f1yHnoiARqcbqToUGP2UrYHf7Zq6LdWHEUbS0V8 GbCEIOqeQPf2GtTkYNuo0OBaPHJimzRmeYwrzfr6zG0Kc/OqJo/4aSvMqBG0rnH5O/i/ rSR+sfiz7hNcYjm0hJzl6R3fNKwUOcWUfnHizFZD0gomHYN+VHS+9envjkpsvo8pw74p syUGCVlA9bTR86HXLgNjdlLgo6fBct8AfD6aQgLPeagYHp32RGr986Ery3ddwGdsZqGT MAhQ== X-Forwarded-Encrypted: i=1; AKwUvBzS3YUQ8dFKYE+iJ2W91x/BmN3CubdfYoYHL+Z12AIQEw0TNW1EwolcEg6rdaUclNfWF0RiXyIe36ILAg==@sourceware.org X-Gm-Message-State: AFuF++kU280tyTAItOSH4inTgad1U2KfeqXZGzfHyWOp6eoSw4nXeTCo wv5FFA7PagGwmbGbSQJteMCKgM4vRmilndHKewL6NrPwhzsZfSHuFHv/7d468GbLkfLMzmwVd+g ZE43FaNzZXNJQktii8QgOSApdG7nxKP+pBftDz95EWKFdgfoO1bqb/j84eEFggDE= X-Gm-Gg: AYBFou0smEgQh/+tEkB5JC98YjA1+KClQfuwrqwycL6o7RKAdzmDCsHR2XsF2R6loHK sdm8s/FG5imMllnTB76/PU/oNnntGTQJcbzFR3jc0DL8pOLFTIOK1824LREREQAitcwXR31xT+N t1k/4H1U5s/kxmftopYTBg/olm+Dj2STl/EKFOMnJkYCM+DOgxcxQrVs/cCR+S1hQyu47dIA64y IIX/x+oUsNRmYadl/dC0gZFx4wFCh1YM8O5xgJliKIZ9Qfc3E+ztU5vJP47fMRWcRTyR/hZRhzB qmfzokqLgSjWpCD95B342Kivabn5BNDeuvxLoW9XXZARsTd67xOT+rHzvAtR8iT0Fydq8+IIvTS 49UPYxCJc8KwONjFA X-Received: by 2002:a05:600c:37c8:b0:49c:cee2:a508 with SMTP id 5b1f17b1804b1-49cf826c4e2mr392452895e9.16.1789037743834; Thu, 10 Sep 2026 03:55:43 -0700 (PDT) X-Received: by 2002:a05:600c:37c8:b0:49c:cee2:a508 with SMTP id 5b1f17b1804b1-49cf826c4e2mr392452685e9.16.1789037743408; Thu, 10 Sep 2026 03:55:43 -0700 (PDT) Received: from localhost (59.6.93.209.dyn.plus.net. [209.93.6.59]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be5b72sm57964105e9.4.2026.09.10.03.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 03:55:42 -0700 (PDT) From: Andrew Burgess To: Matthieu Longo , gdb-patches@sourceware.org Cc: Simon Marchi , Thiago Jung Bauermann , Luis Machado , Luis Machado , Christina Joos , Kevin Buettner , Matthieu Longo Subject: Re: [PATCH v2 1/6] target_fileio_read_stralloc: add an optional length parameter In-Reply-To: <20260825100912.514232-2-matthieu.longo@arm.com> References: <20260825100912.514232-1-matthieu.longo@arm.com> <20260825100912.514232-2-matthieu.longo@arm.com> Date: Thu, 10 Sep 2026 11:55:41 +0100 Message-ID: <87ld99e5oy.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: K3Z2Vs3p9c1_AG-0VLBTL7GyUKG6yvz6mH10PLVCcWM_1789037744 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Matthieu Longo writes: > Extend target_fileio_read_stralloc with an optional output parameter > that returns the number of bytes read, excluding the terminating NUL > byte. > > Most callers only need the returned NUL-terminated buffer and can > ignore the new parameter, but callers that need the number of bytes > read can now obtain it without recomputing it. > > While updating the function, make a couple of minor cleanups by using > '\0' instead of 0 for character literals and clarifying the function > documentation. This looks fine with on minor nit, see below... > > Reviewed-By: Thiago Jung Bauermann > --- > gdb/target.c | 11 ++++++++--- > gdb/target.h | 20 ++++++++++++-------- > 2 files changed, 20 insertions(+), 11 deletions(-) > > diff --git a/gdb/target.c b/gdb/target.c > index 5d937f3ae85..ebf0f30092c 100644 > --- a/gdb/target.c > +++ b/gdb/target.c > @@ -3547,7 +3547,8 @@ target_fileio_read_alloc (struct inferior *inf, const char *filename, > /* See target.h. */ > > gdb::unique_xmalloc_ptr > -target_fileio_read_stralloc (struct inferior *inf, const char *filename) > +target_fileio_read_stralloc (struct inferior *inf, const char *filename, > + LONGEST *len) > { > gdb_byte *buffer; > char *bufstr; > @@ -3556,17 +3557,21 @@ target_fileio_read_stralloc (struct inferior *inf, const char *filename) > transferred = target_fileio_read_alloc_1 (inf, filename, &buffer, 1); > bufstr = (char *) buffer; > > + /* Note: on failure, target_fileio_read_alloc_1 returns -1. */ There is no needs for a 'Note:' prefix. By definition, comments are things about which we should take note. Just: /* On failure target_fileio_read_alloc_1 returns -1. */ Is fine. With that fixed: Approved-By: Andrew Burgess thanks, Andrew