public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: tbsaunde+binutils@tbsaunde.org
To: binutils@sourceware.org
Cc: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
Subject: [PATCH 1/7] cast literal to char * when assigning to input_line_ptr
Date: Wed, 30 Mar 2016 01:08:00 -0000	[thread overview]
Message-ID: <1459300381-19313-2-git-send-email-tbsaunde+binutils@tbsaunde.org> (raw)
In-Reply-To: <1459300381-19313-1-git-send-email-tbsaunde+binutils@tbsaunde.org>

From: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>

various places either directly or indirectly set input_line_pointer to point at
a literal.  Currently lots of places modify the string input_line_pointer
points at, so making it const isn't easy.  Since most if not all of these
places assign to input_line_pointer to parse an expression it would probably be
best to add ways to generate and deal with expressions that doesn't involve
parsing strings, but for now adding some casts seems easiest.

gas/ChangeLog:

2016-03-29  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* config/tc-i960.c (parse_expr): Cast to char * when assigning to
	input_line_pointer.
	* config/tc-m32r.c (expand_debug_syms): Likewise.
	* config/tc-msp430.c (msp430_dstoperand): Likewise.
	* config/tc-z80.c (md_begin): Likewise.
	* stabs.c (stabs_generate_asm_func): Likewise.
---
 gas/config/tc-i960.c   | 10 +++++-----
 gas/config/tc-m32r.c   |  2 +-
 gas/config/tc-msp430.c |  2 +-
 gas/config/tc-z80.c    |  2 +-
 gas/stabs.c            |  2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c
index 8a8f31c..45e8a44 100644
--- a/gas/config/tc-i960.c
+++ b/gas/config/tc-i960.c
@@ -450,7 +450,7 @@ static int br_cnt;
 /* Name of the table of pointers to branches.  A local (i.e.,
    non-external) symbol.  */
 
-static void ctrl_fmt (char *, long, int);
+static void ctrl_fmt (const char *, long, int);
 
 \f
 void
@@ -495,7 +495,7 @@ md_begin (void)
    string is not consumed in the evaluation -- tolerate no dangling junk!  */
 
 static void
-parse_expr (char *textP,		/* Text of expression to be parsed.  */
+parse_expr (const char *textP,		/* Text of expression to be parsed.  */
 	    expressionS *expP)		/* Where to put the results of parsing.  */
 {
   char *save_in;		/* Save global here.  */
@@ -513,7 +513,7 @@ parse_expr (char *textP,		/* Text of expression to be parsed.  */
   else
     {
       save_in = input_line_pointer;	/* Save global.  */
-      input_line_pointer = textP;	/* Make parser work for us.  */
+      input_line_pointer = (char *) textP;	/* Make parser work for us.  */
 
       (void) expression (expP);
       if ((size_t) (input_line_pointer - textP) != strlen (textP))
@@ -558,7 +558,7 @@ emit (long instr)		/* Word to be output, host byte order.  */
   		address displacement is greater than 13 bits.  */
 
 static void
-get_cdisp (char *dispP, /* Displacement as specified in source instruction.  */
+get_cdisp (const char *dispP, /* Displacement as specified in source instruction.  */
 	   const char *ifmtP, /* "COBR" or "CTRL" (for use in error message).  */
 	   long instr,  /* Instruction needing the displacement.  */
 	   int numbits, /* # bits of displacement (13 for COBR, 24 for CTRL).  */
@@ -1494,7 +1494,7 @@ brlab_next (void)
 }
 
 static void
-ctrl_fmt (char *targP,		/* Pointer to text of lone operand (if any).  */
+ctrl_fmt (const char *targP,		/* Pointer to text of lone operand (if any).  */
 	  long opcode,		/* Template of instruction.  */
 	  int num_ops)		/* Number of operands.  */
 {
diff --git a/gas/config/tc-m32r.c b/gas/config/tc-m32r.c
index 7621832..89205f8 100644
--- a/gas/config/tc-m32r.c
+++ b/gas/config/tc-m32r.c
@@ -613,7 +613,7 @@ expand_debug_syms (sym_linkS *syms, int align)
     {
       symbolS *symbolP = syms->symbol;
       next_syms = syms->next;
-      input_line_pointer = ".\n";
+      input_line_pointer = (char *) ".\n";
       pseudo_set (symbolP);
       free ((char *) syms);
     }
diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c
index ae28984..98910aa 100644
--- a/gas/config/tc-msp430.c
+++ b/gas/config/tc-msp430.c
@@ -2156,7 +2156,7 @@ msp430_dstoperand (struct msp430_operand_s * op,
 
   if (op->am == 2)
     {
-      char *__tl = "0";
+      char *__tl = (char *) "0";
 
       op->mode = OP_EXP;
       op->am = 1;
diff --git a/gas/config/tc-z80.c b/gas/config/tc-z80.c
index 094b8e6..535ae22 100644
--- a/gas/config/tc-z80.c
+++ b/gas/config/tc-z80.c
@@ -249,7 +249,7 @@ md_begin (void)
         }
     }
   p = input_line_pointer;
-  input_line_pointer = "0";
+  input_line_pointer = (char *) "0";
   nul.X_md=0;
   expression (& nul);
   input_line_pointer = p;
diff --git a/gas/stabs.c b/gas/stabs.c
index 8d54f73..bc983c9 100644
--- a/gas/stabs.c
+++ b/gas/stabs.c
@@ -666,7 +666,7 @@ stabs_generate_asm_func (const char *funcname, const char *startlabname)
 
   if (! void_emitted_p)
     {
-      input_line_pointer = "\"void:t1=1\",128,0,0,0";
+      input_line_pointer = (char *) "\"void:t1=1\",128,0,0,0";
       s_stab ('s');
       void_emitted_p = 1;
     }
-- 
2.1.4

  reply	other threads:[~2016-03-30  1:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30  1:08 [PATCH 0/7] enable -Wwrite-strings for gas tbsaunde+binutils
2016-03-30  1:08 ` tbsaunde+binutils [this message]
2016-03-30  1:08 ` [PATCH 2/7] work around get_symbol_name () in sparc and ia64 tbsaunde+binutils
2016-03-30  1:08 ` [PATCH 3/7] cast to char * when assigning to optarg tbsaunde+binutils
2016-03-30  1:08 ` [PATCH 5/7] tc-i960.c: add some casts when assigning literals to args[i] tbsaunde+binutils
2016-03-30  1:08 ` [PATCH 7/7] enable -Wwrite-strings for gas tbsaunde+binutils
2016-04-01 11:22   ` Jiong Wang
2016-04-01 12:17     ` Trevor Saunders
2016-04-01 12:40     ` Alan Modra
2016-04-01 13:10       ` Trevor Saunders
2016-03-30  1:14 ` [PATCH 6/7] make xtensa_section_rename () take const char * tbsaunde+binutils
2016-03-30  1:14 ` [PATCH 4/7] cast the arg to md_assemble () to " tbsaunde+binutils
2016-03-31 10:34 ` [PATCH 0/7] enable -Wwrite-strings for gas Alan Modra
2016-05-01 16:44 ` Andrew Pinski
2016-05-02 18:25   ` Trevor Saunders
2016-05-02 19:38     ` Andrew Pinski
2016-05-03  8:12       ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1459300381-19313-2-git-send-email-tbsaunde+binutils@tbsaunde.org \
    --to=tbsaunde+binutils@tbsaunde.org \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).