From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2119) id E9B383858C54; Wed, 7 Jun 2023 02:51:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9B383858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686106290; bh=xVUY17T+YB2Bk/1x1pqY0PVf9F9CNYrcrZyKIySWQyI=; h=From:To:Subject:Date:From; b=PparHmkuTDMx413/hS1dkDTaT9IdvoVX+b6IeObN/4sAkJjaymypFhlCcArIJEDg4 NUqCj5oFt2A2QmvobQ/7GZIk9IxCLxRNDm95QZMHnKoxOz85zKZaC7x9/3ouVVTZZK 9a1v8ltpZc5WSDrYpIk/FkbQQU7U84r14eEZ2AnQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jeff Law To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1598] libiberty: writeargv: Simplify function error mode. X-Act-Checkin: gcc X-Git-Author: Costas Argyris X-Git-Refname: refs/heads/master X-Git-Oldrev: 64d90d06d2db43538c8a45adbb3d74842f7868ae X-Git-Newrev: 3fe017ee79211820ca774f4c87ef86753eeef567 Message-Id: <20230607025130.E9B383858C54@sourceware.org> Date: Wed, 7 Jun 2023 02:51:30 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3fe017ee79211820ca774f4c87ef86753eeef567 commit r14-1598-g3fe017ee79211820ca774f4c87ef86753eeef567 Author: Costas Argyris Date: Tue Jun 6 20:50:07 2023 -0600 libiberty: writeargv: Simplify function error mode. 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 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. Diff: --- 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; } /*