opcodes: constify & local meps macros

Message ID 20210627061828.26650-1-vapier@gentoo.org
State New
Headers show
Series
  • opcodes: constify & local meps macros
Related show

Commit Message

Nick Alcock via Binutils June 27, 2021, 6:18 a.m.
Avoid exporting this common variable name into writable data.
---
 opcodes/mep-asm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.31.1

Comments

Nick Alcock via Binutils July 1, 2021, 10:10 a.m. | #1
Hi Mike,

> Avoid exporting this common variable name into writable data.

> 


Approved - please apply - with a ChangeLog entry.

Cheers
   Nick

Patch

diff --git a/opcodes/mep-asm.c b/opcodes/mep-asm.c
index 78c4066049cf..b2fae277733f 100644
--- a/opcodes/mep-asm.c
+++ b/opcodes/mep-asm.c
@@ -582,7 +582,7 @@  typedef struct
   int len;
 } arg;
 
-macro macros[] =
+static macro const macros[] =
 {
   { "sizeof", "(`1.end + (- `1))"},
   { "startof", "(`1 | 0)" },
@@ -615,10 +615,10 @@  str_append (char *dest, const char *input, int len)
   return strncat (new_dest, input, len);
 }
 
-static macro *
+static const macro *
 lookup_macro (const char *name)
 {
-  macro *m;
+  const macro *m;
 
   for (m = macros; m->name; ++m)
     if (strncmp (m->name, name, strlen(m->name)) == 0)
@@ -628,7 +628,7 @@  lookup_macro (const char *name)
 }
 
 static char *
-expand_macro (arg *args, int narg, macro *mac)
+expand_macro (arg *args, int narg, const macro *mac)
 {
   char *result = 0, *rescanned_result = 0;
   char *e = mac->expansion;
@@ -678,7 +678,7 @@  expand_string (const char *in, int first_only)
   arg args[MAXARGS];
   int state = IN_TEXT;
   const char *mark = in;
-  macro *pmacro = NULL;
+  const macro *pmacro = NULL;
   char *expansion = 0;
   char *result = 0;