]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove some null checks
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:44 +0000 (07:28 -0700)
When not parsing for completion, parse_expression ensures that the
resulting expression has operations.  This patch removes a couple of
unnecessary checks for this situation.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* printcmd.c (set_command): Remove null check.
* value.c (init_if_undefined_command): Remove null check.

gdb/ChangeLog
gdb/printcmd.c
gdb/value.c

index d1cf966d21380862805ac6a3403002a8bf7dac59..2024f942ad498b59f019300167c5acb5c9be5c15 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * printcmd.c (set_command): Remove null check.
+       * value.c (init_if_undefined_command): Remove null check.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * parse.c (parser_state::push_symbol, parser_state::push_dollar):
index 2a06aea95adaf30aa8b63953057f9bab4a95482d..850890644aafd5bfe54410449aec197d6ff68257 100644 (file)
@@ -1375,21 +1375,20 @@ set_command (const char *exp, int from_tty)
 {
   expression_up expr = parse_expression (exp);
 
-  if (expr->op != nullptr)
-    switch (expr->op->opcode ())
-      {
-      case UNOP_PREINCREMENT:
-      case UNOP_POSTINCREMENT:
-      case UNOP_PREDECREMENT:
-      case UNOP_POSTDECREMENT:
-      case BINOP_ASSIGN:
-      case BINOP_ASSIGN_MODIFY:
-      case BINOP_COMMA:
-       break;
-      default:
-       warning
-         (_("Expression is not an assignment (and might have no effect)"));
-      }
+  switch (expr->op->opcode ())
+    {
+    case UNOP_PREINCREMENT:
+    case UNOP_POSTINCREMENT:
+    case UNOP_PREDECREMENT:
+    case UNOP_POSTDECREMENT:
+    case BINOP_ASSIGN:
+    case BINOP_ASSIGN_MODIFY:
+    case BINOP_COMMA:
+      break;
+    default:
+      warning
+       (_("Expression is not an assignment (and might have no effect)"));
+    }
 
   evaluate_expression (expr.get ());
 }
index df0e5c19f8cb054adf11dcdf95ab0c15481c8b92..9527186f57afeb3a88cb8e605a82fa7cdd6d77cf 100644 (file)
@@ -2015,7 +2015,7 @@ init_if_undefined_command (const char* args, int from_tty)
   /* Validate the expression.
      Was the expression an assignment?
      Or even an expression at all?  */
-  if (expr->op == nullptr || expr->first_opcode () != BINOP_ASSIGN)
+  if (expr->first_opcode () != BINOP_ASSIGN)
     error (_("Init-if-undefined requires an assignment expression."));
 
   /* Extract the variable from the parsed expression.  */