public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Costas Argyris <costas.argyris@gmail.com>
To: Jeff Law <jeffreyalaw@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] libiberty: writeargv: Simplify function error mode.
Date: Tue, 6 Jun 2023 09:44:20 +0100	[thread overview]
Message-ID: <CAHyHGCk43cYOBTHBZLqKVwLVPFFq8QBH_QYnk5k+7tA_bJotkw@mail.gmail.com> (raw)
In-Reply-To: <c06b20d6-ecea-87cd-dfa2-24b40d7c2b60@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 749 bytes --]

You are right, this is also a remnant of the old function design
that I completely missed.    Here is the follow-up patch for that.

Thanks for pointing it out.

Costas

On Tue, 6 Jun 2023 at 04:12, Jeff Law <jeffreyalaw@gmail.com> wrote:

>
>
> On 6/5/23 08:37, Costas Argyris via Gcc-patches wrote:
> > writeargv can be simplified by getting rid of the error exit mode
> > that was only relevant many years ago when the function used
> > to open the file descriptor internally.
> [ ... ]
> Thanks.  I've pushed this to the trunk.
>
> You could (as a follow-up) simplify it even further.  There's no need
> for the status variable as far as I can tell.  You could just have the
> final return be "return 0;" instead of "return status;".
>
> Jeff
>

[-- Attachment #2: 0001-libiberty-writeargv-Remove-unnecessary-status-variab.patch --]
[-- Type: text/x-patch, Size: 865 bytes --]

From 13fdfea60eeac64e028315392614b955e998487d Mon Sep 17 00:00:00 2001
From: Costas Argyris <costas.argyris@gmail.com>
Date: Tue, 6 Jun 2023 09:15:48 +0100
Subject: [PATCH] libiberty: writeargv: Remove unnecessary status variable.

Follow-up from 4d1e4ce986f pointed out by jlaw.

Signed-off-by: Costas Argyris <costas.argyris@gmail.com>
---
 libiberty/argv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libiberty/argv.c b/libiberty/argv.c
index 1a18b4d8866..c2823d3e4ba 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -299,8 +299,6 @@ non-zero if an error occurred while writing to FILE.
 int
 writeargv (char * const *argv, FILE *f)
 {
-  int status = 0;
-
   if (f == NULL)
     return 1;
 
@@ -333,7 +331,7 @@ writeargv (char * const *argv, FILE *f)
       argv++;
     }
 
-  return status;
+  return 0;
 }
 
 /*
-- 
2.30.2


  reply	other threads:[~2023-06-06  8:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05 14:37 Costas Argyris
2023-06-06  3:12 ` Jeff Law
2023-06-06  8:44   ` Costas Argyris [this message]
2023-06-07  2:52     ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHyHGCk43cYOBTHBZLqKVwLVPFFq8QBH_QYnk5k+7tA_bJotkw@mail.gmail.com \
    --to=costas.argyris@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).