]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb] Make variable printed bool in info_checkpoints_command
authorTom de Vries <tdevries@suse.de>
Wed, 10 Jan 2024 10:27:34 +0000 (11:27 +0100)
committerTom de Vries <tdevries@suse.de>
Wed, 10 Jan 2024 10:27:34 +0000 (11:27 +0100)
While reading info_checkpoints_command, I noticed variable printed:
...
  const fork_info *printed = NULL;
  ...
  for (const fork_info &fi : fork_list)
    {
      if (requested > 0 && fi.num != requested)
continue;

      printed = &fi;
      ...
    }
  if (printed == NULL)
...
has pointer type, but is just used as bool.

Make this explicit by changing the variable type to bool.

Tested on x86_64-linux.

Approved-By: Kevin Buettner <kevinb@redhat.com>
gdb/linux-fork.c

index 1430ff89fa73e5e90f1b3ae897a94e745e2e03c2..177a012ec08ce30b99909ee5e4a5bac7f7e711c2 100644 (file)
@@ -583,7 +583,7 @@ info_checkpoints_command (const char *arg, int from_tty)
 {
   struct gdbarch *gdbarch = get_current_arch ();
   int requested = -1;
-  const fork_info *printed = NULL;
+  bool printed = false;
 
   if (arg && *arg)
     requested = (int) parse_and_eval_long (arg);
@@ -592,8 +592,8 @@ info_checkpoints_command (const char *arg, int from_tty)
     {
       if (requested > 0 && fi.num != requested)
        continue;
+      printed = true;
 
-      printed = &fi;
       if (fi.ptid == inferior_ptid)
        gdb_printf ("* ");
       else
@@ -623,7 +623,8 @@ info_checkpoints_command (const char *arg, int from_tty)
 
       gdb_putc ('\n');
     }
-  if (printed == NULL)
+
+  if (!printed)
     {
       if (requested > 0)
        gdb_printf (_("No checkpoint number %d.\n"), requested);