* [PATCH] gdbserver: remove unused variable
@ 2022-07-11 12:53 Enze Li
2022-07-11 13:52 ` Luis Machado
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Enze Li @ 2022-07-11 12:53 UTC (permalink / raw)
To: gdb-patches
When building with clang 15, I got this error:
CXX server.o
server.cc:2985:10: error: variable 'new_argc' set but not used [-Werror,-Wunused-but-set-variable]
int i, new_argc;
^
Remove the unused variable to eliminate the error.
Tested by rebuilding on x86_64-linux with clang 15.
---
gdbserver/server.cc | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index f9c02a9c6dac..c619206d5d2d 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2982,14 +2982,10 @@ handle_v_run (char *own_buf)
char *p, *next_p;
std::vector<char *> new_argv;
char *new_program_name = NULL;
- int i, new_argc;
+ int i;
- new_argc = 0;
for (p = own_buf + strlen ("vRun;"); p && *p; p = strchr (p, ';'))
- {
- p++;
- new_argc++;
- }
+ p++;
for (i = 0, p = own_buf + strlen ("vRun;"); *p; p = next_p, ++i)
{
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gdbserver: remove unused variable
2022-07-11 12:53 [PATCH] gdbserver: remove unused variable Enze Li
@ 2022-07-11 13:52 ` Luis Machado
2022-07-11 15:38 ` Andrew Burgess
2022-07-13 15:37 ` Pedro Alves
2 siblings, 0 replies; 5+ messages in thread
From: Luis Machado @ 2022-07-11 13:52 UTC (permalink / raw)
To: Enze Li, gdb-patches
On 7/11/22 13:53, Enze Li via Gdb-patches wrote:
> When building with clang 15, I got this error:
>
> CXX server.o
> server.cc:2985:10: error: variable 'new_argc' set but not used [-Werror,-Wunused-but-set-variable]
> int i, new_argc;
> ^
> Remove the unused variable to eliminate the error.
>
> Tested by rebuilding on x86_64-linux with clang 15.
> ---
> gdbserver/server.cc | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/gdbserver/server.cc b/gdbserver/server.cc
> index f9c02a9c6dac..c619206d5d2d 100644
> --- a/gdbserver/server.cc
> +++ b/gdbserver/server.cc
> @@ -2982,14 +2982,10 @@ handle_v_run (char *own_buf)
> char *p, *next_p;
> std::vector<char *> new_argv;
> char *new_program_name = NULL;
> - int i, new_argc;
> + int i;
>
> - new_argc = 0;
> for (p = own_buf + strlen ("vRun;"); p && *p; p = strchr (p, ';'))
> - {
> - p++;
> - new_argc++;
> - }
> + p++;
>
> for (i = 0, p = own_buf + strlen ("vRun;"); *p; p = next_p, ++i)
> {
Looks reasonable to me. Someone else should OK it though.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gdbserver: remove unused variable
2022-07-11 12:53 [PATCH] gdbserver: remove unused variable Enze Li
2022-07-11 13:52 ` Luis Machado
@ 2022-07-11 15:38 ` Andrew Burgess
2022-07-13 12:13 ` Enze Li
2022-07-13 15:37 ` Pedro Alves
2 siblings, 1 reply; 5+ messages in thread
From: Andrew Burgess @ 2022-07-11 15:38 UTC (permalink / raw)
To: Enze Li, gdb-patches
Enze Li via Gdb-patches <gdb-patches@sourceware.org> writes:
> When building with clang 15, I got this error:
>
> CXX server.o
> server.cc:2985:10: error: variable 'new_argc' set but not used [-Werror,-Wunused-but-set-variable]
> int i, new_argc;
> ^
> Remove the unused variable to eliminate the error.
LGTM. Please apply it.
Thanks,
Andrew
>
> Tested by rebuilding on x86_64-linux with clang 15.
> ---
> gdbserver/server.cc | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/gdbserver/server.cc b/gdbserver/server.cc
> index f9c02a9c6dac..c619206d5d2d 100644
> --- a/gdbserver/server.cc
> +++ b/gdbserver/server.cc
> @@ -2982,14 +2982,10 @@ handle_v_run (char *own_buf)
> char *p, *next_p;
> std::vector<char *> new_argv;
> char *new_program_name = NULL;
> - int i, new_argc;
> + int i;
>
> - new_argc = 0;
> for (p = own_buf + strlen ("vRun;"); p && *p; p = strchr (p, ';'))
> - {
> - p++;
> - new_argc++;
> - }
> + p++;
>
> for (i = 0, p = own_buf + strlen ("vRun;"); *p; p = next_p, ++i)
> {
> --
> 2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gdbserver: remove unused variable
2022-07-11 15:38 ` Andrew Burgess
@ 2022-07-13 12:13 ` Enze Li
0 siblings, 0 replies; 5+ messages in thread
From: Enze Li @ 2022-07-13 12:13 UTC (permalink / raw)
To: Andrew Burgess, luis.machado; +Cc: gdb-patches
On Mon, 2022-07-11 at 16:38 +0100, Andrew Burgess wrote:
> Enze Li via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> > When building with clang 15, I got this error:
> >
> > CXX server.o
> > server.cc:2985:10: error: variable 'new_argc' set but not used [-
> > Werror,-Wunused-but-set-variable]
> > int i, new_argc;
> > ^
> > Remove the unused variable to eliminate the error.
>
> LGTM. Please apply it.
Okay, I'm checking this in now.
Thanks,
Enze
>
> Thanks,
> Andrew
>
> >
> > Tested by rebuilding on x86_64-linux with clang 15.
> > ---
> > gdbserver/server.cc | 8 ++------
> > 1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/gdbserver/server.cc b/gdbserver/server.cc
> > index f9c02a9c6dac..c619206d5d2d 100644
> > --- a/gdbserver/server.cc
> > +++ b/gdbserver/server.cc
> > @@ -2982,14 +2982,10 @@ handle_v_run (char *own_buf)
> > char *p, *next_p;
> > std::vector<char *> new_argv;
> > char *new_program_name = NULL;
> > - int i, new_argc;
> > + int i;
> >
> > - new_argc = 0;
> > for (p = own_buf + strlen ("vRun;"); p && *p; p = strchr (p,
> > ';'))
> > - {
> > - p++;
> > - new_argc++;
> > - }
> > + p++;
> >
> > for (i = 0, p = own_buf + strlen ("vRun;"); *p; p = next_p, ++i)
> > {
> > --
> > 2.30.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gdbserver: remove unused variable
2022-07-11 12:53 [PATCH] gdbserver: remove unused variable Enze Li
2022-07-11 13:52 ` Luis Machado
2022-07-11 15:38 ` Andrew Burgess
@ 2022-07-13 15:37 ` Pedro Alves
2 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2022-07-13 15:37 UTC (permalink / raw)
To: Enze Li, gdb-patches
On 2022-07-11 1:53 p.m., Enze Li via Gdb-patches wrote:
> When building with clang 15, I got this error:
>
> CXX server.o
> server.cc:2985:10: error: variable 'new_argc' set but not used [-Werror,-Wunused-but-set-variable]
> int i, new_argc;
> ^
> Remove the unused variable to eliminate the error.
>
> Tested by rebuilding on x86_64-linux with clang 15.
> ---
> gdbserver/server.cc | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/gdbserver/server.cc b/gdbserver/server.cc
> index f9c02a9c6dac..c619206d5d2d 100644
> --- a/gdbserver/server.cc
> +++ b/gdbserver/server.cc
> @@ -2982,14 +2982,10 @@ handle_v_run (char *own_buf)
> char *p, *next_p;
> std::vector<char *> new_argv;
> char *new_program_name = NULL;
> - int i, new_argc;
> + int i;
>
> - new_argc = 0;
> for (p = own_buf + strlen ("vRun;"); p && *p; p = strchr (p, ';'))
> - {
> - p++;
> - new_argc++;
> - }
> + p++;
>
The for loop below starts by reinitializing 'p' to 'own_buf + strlen ("vRun;")',
which makes the whole loop above unnecessary, if I'm reading it right.
> for (i = 0, p = own_buf + strlen ("vRun;"); *p; p = next_p, ++i)
> {
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-13 15:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-11 12:53 [PATCH] gdbserver: remove unused variable Enze Li
2022-07-11 13:52 ` Luis Machado
2022-07-11 15:38 ` Andrew Burgess
2022-07-13 12:13 ` Enze Li
2022-07-13 15:37 ` Pedro Alves
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).