poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] pk_cmd_editor: Remove useless variable and test.


From: Jose E. Marchesi
Subject: Re: [PATCH 1/2] pk_cmd_editor: Remove useless variable and test.
Date: Fri, 21 Feb 2020 18:50:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hi John.

    The condition "ret == 0" is always true, because it is tested previously,
    and the function returns if the condition fails.  Ipso facto, (ret == 0)
    is redundant, and thus the entire variable "ret" is not required.

OK for master.
Thanks!

    ---
     ChangeLog       | 4 ++++
     src/pk-editor.c | 7 +++----
     2 files changed, 7 insertions(+), 4 deletions(-)
    
    diff --git a/ChangeLog b/ChangeLog
    index 4c61b8e6..29b05143 100644
    --- a/ChangeLog
    +++ b/ChangeLog
    @@ -1,3 +1,7 @@
    +2020-02-16  John Darrington <address@hidden>
    +
    +   * src/pk-editor.c (pk_cmd_editor): Remove variable "ret".
    +
     2020-02-16  John Darrington <address@hidden>
     
        * src/pk-misc (pk_cmd_jmd): Set the random seed the first
    diff --git a/src/pk-editor.c b/src/pk-editor.c
    index 728d55e8..a889e1b1 100644
    --- a/src/pk-editor.c
    +++ b/src/pk-editor.c
    @@ -32,7 +32,7 @@ pk_cmd_editor (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
       const char *editor;
       char *cmdline;
       char tmpfile[1024];
    -  int des, ret;
    +  int des;
       FILE *f;
     
       /* editor */
    @@ -68,7 +68,7 @@ pk_cmd_editor (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
       asprintf (&cmdline, "%s %s", editor, tmpfile);
     
       /* Start command.  */
    -  if ((ret = system (cmdline)) != 0)
    +  if (system (cmdline) != 0)
         {
           pk_term_class ("error");
           pk_puts ("error: ");
    @@ -82,8 +82,7 @@ pk_cmd_editor (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
       /* If the editor returned success and a file got created, read the
          contents of the file, turn newlines into spaces and execute
          it.  */
    -  if (ret == 0
    -      && (f = fopen (tmpfile, "r")) != NULL)
    +  if ((f = fopen (tmpfile, "r")) != NULL)
         {
     #define STEP 128
           char *newline = xmalloc (STEP);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]