]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
unittest fix gdb_print_local() used by _ok() to avoid "tail call"
authorAlain Spineux <alain@baculasystems.com>
Fri, 28 Feb 2020 12:31:29 +0000 (13:31 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:57 +0000 (09:02 +0100)
- compiler can do "tail call" optimization and "hide" functions
  in the "call stack" and disturb gdb_print_local() usage

bacula/src/lib/unittests.c

index 6530c5960fa9548ae48205e8260ce47f927e8764..2e6dc6cc7643a3c2826746b60282bcc39445ad04 100644 (file)
@@ -84,15 +84,15 @@ bool _ok(const char *file, int l, const char *op, int value, const char *label)
 {
    nb++;
    if (!value) {
-      err++;
       if (err < 1000) {
          Pmsg4(-1, "ERR %.80s %s:%i on %s\n", label, file, l, op);
       } else if (err == 1000) {
          Pmsg0(-1, "ERR Too much errors\n");
       }
       if (print_var) {
-         gdb_print_local(1);
+         gdb_print_local(1); // make sure this line is not the last operation before the return
       }
+      err++; // keep this line AFTER the gdb_print_local() to avoid "tail call" optimization
    } else if (!quiet) {
       Pmsg1(-1, "OK  %.80s\n", label);
    }