This is an automated email from Gerrit.

"Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>" just uploaded a new patch 
set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8666

-- gerrit

commit b40a2a1aeab23c2ac7e3603625295c438835687c
Author: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>
Date:   Tue Dec 17 18:13:00 2024 +0300

    helper/options: handle errors in `-l`
    
    Before the patch an error in opening the log file (e.g. can't write a
    file) was ignored when specified via `-l`.
    E.g.:
    ```
    > touch log
    > chmod -w log
    > openocd -l log -c shutdown
    ...
    failed to open output log "log"
    shutdown command invoked
    > echo $?
    0
    ```
    
    After the patch:
    ```
    ...
    > openocd -l log -c shutdown
    ...
    failed to open output log "log"
    > echo $?
    1
    ```
    
    Change-Id: Ibab45f580dc46a499bf967c4afad071f9c2972a2
    Signed-off-by: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>

diff --git a/src/helper/options.c b/src/helper/options.c
index 61a1014697..8f6a021c73 100644
--- a/src/helper/options.c
+++ b/src/helper/options.c
@@ -303,8 +303,11 @@ int parse_cmdline_args(struct command_context *cmd_ctx, 
int argc, char *argv[])
                                break;
                        }
                        case 'l':               /* --log_output | -l */
-                               if (optarg)
-                                       command_run_linef(cmd_ctx, "log_output 
%s", optarg);
+                               if (optarg) {
+                                       int retval = command_run_linef(cmd_ctx, 
"log_output %s", optarg);
+                                       if (retval != ERROR_OK)
+                                               return retval;
+                               }
                                break;
                        case 'c':               /* --command | -c */
                                if (optarg)

-- 

Reply via email to