diff mbox series

main: Select only the targets specified on cmdline

Message ID 20180702041132.26078-1-amitay@ozlabs.org
State Accepted
Headers show
Series main: Select only the targets specified on cmdline | expand

Commit Message

Amitay Isaacs July 2, 2018, 4:11 a.m. UTC
This fixes the problem of incorrectly selecting threads for following
command-line without any thread specification.

   pdbg -p 0 -c 0 ...

Before iterating through [pct]_list, confirm that [pct]_count > 0.

Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 src/main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Michael Neuling July 3, 2018, 7:09 a.m. UTC | #1
I think this solves the same problem as my patch here:

https://lists.ozlabs.org/pipermail/pdbg/2018-July/000531.html

I think my solution is probably better since it init's [cpt]_list correctly
rather than making them rely on [cpt]_count. YMMV

Mikey

On Mon, 2018-07-02 at 14:11 +1000, Amitay Isaacs wrote:
> This fixes the problem of incorrectly selecting threads for following
> command-line without any thread specification.
> 
>    pdbg -p 0 -c 0 ...
> 
> Before iterating through [pct]_list, confirm that [pct]_count > 0.
> 
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> ---
>  src/main.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/main.c b/src/main.c
> index 53e1c2b..4956740 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -379,18 +379,27 @@ static bool parse_options(int argc, char *argv[])
>  		return false;
>  	}
>  
> +	if (p_count == 0)
> +		return true;
> +
>  	for (i = 0; i < MAX_PROCESSORS; i++) {
>  		if (p_list[i] == 0)
>  			continue;
>  
>  		processorsel[i] = &chipsel[i][0];
>  
> +		if (c_count == 0)
> +			continue;
> +
>  		for (j = 0; j < MAX_CHIPS; j++) {
>  			if (c_list[j] == 0)
>  				continue;
>  
>  			chipsel[i][j] = &threadsel[i][j][0];
>  
> +			if (t_count == 0)
> +				continue;
> +
>  			for (k = 0; k < MAX_THREADS; k++) {
>  				if (t_list[k] == 0)
>  					continue;
> -- 
> 2.17.1
>
Amitay Isaacs July 3, 2018, 7:50 a.m. UTC | #2
On Tue, 2018-07-03 at 17:09 +1000, Michael Neuling wrote:
> I think this solves the same problem as my patch here:
> 
> https://lists.ozlabs.org/pipermail/pdbg/2018-July/000531.html
> 
> I think my solution is probably better since it init's [cpt]_list
> correctly
> rather than making them rely on [cpt]_count. YMMV

Sure. :-)

My patch will avoid running through the loop when the whole array is
set to zero.

Amitay.

> 
> Mikey
> 
> On Mon, 2018-07-02 at 14:11 +1000, Amitay Isaacs wrote:
> > This fixes the problem of incorrectly selecting threads for
> > following
> > command-line without any thread specification.
> > 
> >    pdbg -p 0 -c 0 ...
> > 
> > Before iterating through [pct]_list, confirm that [pct]_count > 0.
> > 
> > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> > ---
> >  src/main.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/src/main.c b/src/main.c
> > index 53e1c2b..4956740 100644
> > --- a/src/main.c
> > +++ b/src/main.c
> > @@ -379,18 +379,27 @@ static bool parse_options(int argc, char
> > *argv[])
> >  		return false;
> >  	}
> >  
> > +	if (p_count == 0)
> > +		return true;
> > +
> >  	for (i = 0; i < MAX_PROCESSORS; i++) {
> >  		if (p_list[i] == 0)
> >  			continue;
> >  
> >  		processorsel[i] = &chipsel[i][0];
> >  
> > +		if (c_count == 0)
> > +			continue;
> > +
> >  		for (j = 0; j < MAX_CHIPS; j++) {
> >  			if (c_list[j] == 0)
> >  				continue;
> >  
> >  			chipsel[i][j] = &threadsel[i][j][0];
> >  
> > +			if (t_count == 0)
> > +				continue;
> > +
> >  			for (k = 0; k < MAX_THREADS; k++) {
> >  				if (t_list[k] == 0)
> >  					continue;
> > -- 
> > 2.17.1
> > 

Amitay.
Alistair Popple July 12, 2018, 5:56 a.m. UTC | #3
On Tuesday, 3 July 2018 5:50:32 PM AEST Amitay Isaacs wrote:
> On Tue, 2018-07-03 at 17:09 +1000, Michael Neuling wrote:
> > I think this solves the same problem as my patch here:
> > 
> > https://lists.ozlabs.org/pipermail/pdbg/2018-July/000531.html
> > 
> > I think my solution is probably better since it init's [cpt]_list
> > correctly
> > rather than making them rely on [cpt]_count. YMMV
> 
> Sure. :-)
> 
> My patch will avoid running through the loop when the whole array is
> set to zero.

I've taken both, thanks all!

- Alistair

> Amitay.
> 
> > 
> > Mikey
> > 
> > On Mon, 2018-07-02 at 14:11 +1000, Amitay Isaacs wrote:
> > > This fixes the problem of incorrectly selecting threads for
> > > following
> > > command-line without any thread specification.
> > > 
> > >    pdbg -p 0 -c 0 ...
> > > 
> > > Before iterating through [pct]_list, confirm that [pct]_count > 0.
> > > 
> > > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> > > ---
> > >  src/main.c | 9 +++++++++
> > >  1 file changed, 9 insertions(+)
> > > 
> > > diff --git a/src/main.c b/src/main.c
> > > index 53e1c2b..4956740 100644
> > > --- a/src/main.c
> > > +++ b/src/main.c
> > > @@ -379,18 +379,27 @@ static bool parse_options(int argc, char
> > > *argv[])
> > >  		return false;
> > >  	}
> > >  
> > > +	if (p_count == 0)
> > > +		return true;
> > > +
> > >  	for (i = 0; i < MAX_PROCESSORS; i++) {
> > >  		if (p_list[i] == 0)
> > >  			continue;
> > >  
> > >  		processorsel[i] = &chipsel[i][0];
> > >  
> > > +		if (c_count == 0)
> > > +			continue;
> > > +
> > >  		for (j = 0; j < MAX_CHIPS; j++) {
> > >  			if (c_list[j] == 0)
> > >  				continue;
> > >  
> > >  			chipsel[i][j] = &threadsel[i][j][0];
> > >  
> > > +			if (t_count == 0)
> > > +				continue;
> > > +
> > >  			for (k = 0; k < MAX_THREADS; k++) {
> > >  				if (t_list[k] == 0)
> > >  					continue;
> 
> Amitay.
>
diff mbox series

Patch

diff --git a/src/main.c b/src/main.c
index 53e1c2b..4956740 100644
--- a/src/main.c
+++ b/src/main.c
@@ -379,18 +379,27 @@  static bool parse_options(int argc, char *argv[])
 		return false;
 	}
 
+	if (p_count == 0)
+		return true;
+
 	for (i = 0; i < MAX_PROCESSORS; i++) {
 		if (p_list[i] == 0)
 			continue;
 
 		processorsel[i] = &chipsel[i][0];
 
+		if (c_count == 0)
+			continue;
+
 		for (j = 0; j < MAX_CHIPS; j++) {
 			if (c_list[j] == 0)
 				continue;
 
 			chipsel[i][j] = &threadsel[i][j][0];
 
+			if (t_count == 0)
+				continue;
+
 			for (k = 0; k < MAX_THREADS; k++) {
 				if (t_list[k] == 0)
 					continue;