aboutsummaryrefslogtreecommitdiff
path: root/gdb/ax-general.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-06-20 11:11:06 -0600
committerTom Tromey <tom@tromey.com>2023-06-20 11:21:51 -0600
commit00a854287778c852191df9f9815c5d601daa5ae1 (patch)
treeab2fe6cf4973891a98d68e9b8305349bd53a8e5f /gdb/ax-general.c
parent3ba0581955632c4b269bbcf8a458daafc9d167a6 (diff)
downloadgdb-00a854287778c852191df9f9815c5d601daa5ae1.zip
gdb-00a854287778c852191df9f9815c5d601daa5ae1.tar.gz
gdb-00a854287778c852191df9f9815c5d601daa5ae1.tar.bz2
Use ARRAY_SIZE in ax-general.c
This changes a couple of spots in ax-general.c to use ARRAY_SIZE. While making this change, I noticed that one of the bounds checks was incorrect. Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Diffstat (limited to 'gdb/ax-general.c')
-rw-r--r--gdb/ax-general.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/gdb/ax-general.c b/gdb/ax-general.c
index 4ace2b4..3c724a0 100644
--- a/gdb/ax-general.c
+++ b/gdb/ax-general.c
@@ -353,8 +353,7 @@ ax_print (struct ui_file *f, struct agent_expr *x)
{
enum agent_op op = (enum agent_op) x->buf[i];
- if (op >= (sizeof (aop_map) / sizeof (aop_map[0]))
- || !aop_map[op].name)
+ if (op >= ARRAY_SIZE (aop_map) || aop_map[op].name == nullptr)
{
gdb_printf (f, _("%3d <bad opcode %02x>\n"), i, op);
i++;
@@ -454,7 +453,7 @@ ax_reqs (struct agent_expr *ax)
for (i = 0; i < ax->buf.size (); i += 1 + op->op_size)
{
- if (ax->buf[i] > (sizeof (aop_map) / sizeof (aop_map[0])))
+ if (ax->buf[i] >= ARRAY_SIZE (aop_map))
{
ax->flaw = agent_flaw_bad_instruction;
return;