]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libiberty: writeargv: Simplify function error mode.
authorCostas Argyris <costas.argyris@gmail.com>
Wed, 7 Jun 2023 02:50:07 +0000 (20:50 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Wed, 7 Jun 2023 02:50:07 +0000 (20:50 -0600)
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;".

libiberty/
* argv.c (writeargv): Constant propagate "0" for "status",
simplifying the code slightly.

libiberty/argv.c

index 1a18b4d886666907bdafad2c16f00f8a520557e3..c2823d3e4ba85121a3240aff63fdaf4f2679d906 100644 (file)
@@ -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;
 }
 
 /*