-Wwrite-strings: gdbserver's 'port' parsing

-Wwrite-strings flags this assignment as requiring a cast:

		  port = STDIO_CONNECTION_NAME;

because 'port' is a "char *", and STDIO_CONNECTION_NAME is a string
literal.

gdb/gdbserver/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

        * remote-utils.c (remote_prepare, remote_open): Constify.
        * remote-utils.h (remote_prepare, remote_open): Constify.
        * server.c (captured_main): Constify 'port' handling.
This commit is contained in:
Pedro Alves
2017-04-05 19:21:35 +01:00
parent fdf9e36fa2
commit fb32b4f700
4 changed files with 21 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2017-04-05 Pedro Alves <palves@redhat.com>
* remote-utils.c (remote_prepare, remote_open): Constify.
* remote-utils.h (remote_prepare, remote_open): Constify.
* server.c (captured_main): Constify 'port' handling.
2017-04-04 Simon Marchi <simon.marchi@ericsson.com> 2017-04-04 Simon Marchi <simon.marchi@ericsson.com>
* Makefile.in (clean): Clear .deps. * Makefile.in (clean): Clear .deps.

View File

@ -217,9 +217,9 @@ handle_accept_event (int err, gdb_client_data client_data)
NAME is the filename used for communication. */ NAME is the filename used for communication. */
void void
remote_prepare (char *name) remote_prepare (const char *name)
{ {
char *port_str; const char *port_str;
#ifdef USE_WIN32API #ifdef USE_WIN32API
static int winsock_initialized; static int winsock_initialized;
#endif #endif
@ -284,9 +284,9 @@ remote_prepare (char *name)
NAME is the filename used for communication. */ NAME is the filename used for communication. */
void void
remote_open (char *name) remote_open (const char *name)
{ {
char *port_str; const char *port_str;
port_str = strchr (name, ':'); port_str = strchr (name, ':');
#ifdef USE_WIN32API #ifdef USE_WIN32API

View File

@ -35,8 +35,8 @@ int putpkt (char *buf);
int putpkt_binary (char *buf, int len); int putpkt_binary (char *buf, int len);
int putpkt_notif (char *buf); int putpkt_notif (char *buf);
int getpkt (char *buf); int getpkt (char *buf);
void remote_prepare (char *name); void remote_prepare (const char *name);
void remote_open (char *name); void remote_open (const char *name);
void remote_close (void); void remote_close (void);
void write_ok (char *buf); void write_ok (char *buf);
void write_enn (char *buf); void write_enn (char *buf);

View File

@ -3511,7 +3511,8 @@ captured_main (int argc, char *argv[])
{ {
int bad_attach; int bad_attach;
int pid; int pid;
char *arg_end, *port; char *arg_end;
const char *port = NULL;
char **next_arg = &argv[1]; char **next_arg = &argv[1];
volatile int multi_mode = 0; volatile int multi_mode = 0;
volatile int attach = 0; volatile int attach = 0;
@ -3608,7 +3609,8 @@ captured_main (int argc, char *argv[])
{ {
/* "-" specifies a stdio connection and is a form of port /* "-" specifies a stdio connection and is a form of port
specification. */ specification. */
*next_arg = STDIO_CONNECTION_NAME; port = STDIO_CONNECTION_NAME;
next_arg++;
break; break;
} }
else if (strcmp (*next_arg, "--disable-randomization") == 0) else if (strcmp (*next_arg, "--disable-randomization") == 0)
@ -3627,8 +3629,11 @@ captured_main (int argc, char *argv[])
continue; continue;
} }
port = *next_arg; if (port == NULL)
next_arg++; {
port = *next_arg;
next_arg++;
}
if (port == NULL || (!attach && !multi_mode && *next_arg == NULL)) if (port == NULL || (!attach && !multi_mode && *next_arg == NULL))
{ {
gdbserver_usage (stderr); gdbserver_usage (stderr);