diff mbox

[v2] odp_example.c: fix dead code path

Message ID 1414707475-26664-1-git-send-email-mike.holmes@linaro.org
State Accepted
Commit a4f623d86c718c9f3ff14c588c667e424591d90f
Headers show

Commit Message

Mike Holmes Oct. 30, 2014, 10:17 p.m. UTC
tot is = i which cannot leave the for loop without being positive
unless it exits entirely and never reaches the test statement.
Or QUEUE_ROUNDS is #defined to 0 rather than (512*1024)
Thus tot is always true and the else cannot execute

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---

Previous patch missed a case.
Fixed indent

 example/odp_example/odp_example.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Mike Holmes Nov. 3, 2014, 6:23 p.m. UTC | #1
ping

On 30 October 2014 18:17, Mike Holmes <mike.holmes@linaro.org> wrote:

> tot is = i which cannot leave the for loop without being positive
> unless it exits entirely and never reaches the test statement.
> Or QUEUE_ROUNDS is #defined to 0 rather than (512*1024)
> Thus tot is always true and the else cannot execute
>
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>
> Previous patch missed a case.
> Fixed indent
>
>  example/odp_example/odp_example.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/example/odp_example/odp_example.c
> b/example/odp_example/odp_example.c
> index 5f25f89..1ed4a0b 100644
> --- a/example/odp_example/odp_example.c
> +++ b/example/odp_example/odp_example.c
> @@ -355,13 +355,8 @@ static int test_schedule_one_single(const char *str,
> int thr,
>         odp_barrier_sync(barrier);
>         clear_sched_queues();
>
> -       if (tot) {
> -               cycles = cycles/tot;
> -               ns     = ns/tot;
> -       } else {
> -               cycles = 0;
> -               ns     = 0;
> -       }
> +       cycles = cycles/tot;
> +       ns     = ns/tot;
>
>         printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
>                thr, str, cycles, ns);
> --
> 2.1.0
>
>
Ciprian Barbu Nov. 4, 2014, 3:04 p.m. UTC | #2
On Mon, Nov 3, 2014 at 8:23 PM, Mike Holmes <mike.holmes@linaro.org> wrote:
> ping
>
> On 30 October 2014 18:17, Mike Holmes <mike.holmes@linaro.org> wrote:
>>
>> tot is = i which cannot leave the for loop without being positive
>> unless it exits entirely and never reaches the test statement.
>> Or QUEUE_ROUNDS is #defined to 0 rather than (512*1024)
>> Thus tot is always true and the else cannot execute

Why not use QUEUE_ROUNDS instead and get rid of tot altogether ?

>>
>> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>> ---
>>
>> Previous patch missed a case.
>> Fixed indent
>>
>>  example/odp_example/odp_example.c | 9 ++-------
>>  1 file changed, 2 insertions(+), 7 deletions(-)
>>
>> diff --git a/example/odp_example/odp_example.c
>> b/example/odp_example/odp_example.c
>> index 5f25f89..1ed4a0b 100644
>> --- a/example/odp_example/odp_example.c
>> +++ b/example/odp_example/odp_example.c
>> @@ -355,13 +355,8 @@ static int test_schedule_one_single(const char *str,
>> int thr,
>>         odp_barrier_sync(barrier);
>>         clear_sched_queues();
>>
>> -       if (tot) {
>> -               cycles = cycles/tot;
>> -               ns     = ns/tot;
>> -       } else {
>> -               cycles = 0;
>> -               ns     = 0;
>> -       }
>> +       cycles = cycles/tot;
>> +       ns     = ns/tot;
>>
>>         printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
>>                thr, str, cycles, ns);
>> --
>> 2.1.0
>>
>
>
>
> --
> Mike Holmes
> Linaro  Sr Technical Manager
> LNG - ODP
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Nov. 5, 2014, 11:41 a.m. UTC | #3
Applied!

Maxim.

On 10/31/2014 01:17 AM, Mike Holmes wrote:
> tot is = i which cannot leave the for loop without being positive
> unless it exits entirely and never reaches the test statement.
> Or QUEUE_ROUNDS is #defined to 0 rather than (512*1024)
> Thus tot is always true and the else cannot execute
>
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>
> Previous patch missed a case.
> Fixed indent
>
>   example/odp_example/odp_example.c | 9 ++-------
>   1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c
> index 5f25f89..1ed4a0b 100644
> --- a/example/odp_example/odp_example.c
> +++ b/example/odp_example/odp_example.c
> @@ -355,13 +355,8 @@ static int test_schedule_one_single(const char *str, int thr,
>   	odp_barrier_sync(barrier);
>   	clear_sched_queues();
>   
> -	if (tot) {
> -		cycles = cycles/tot;
> -		ns     = ns/tot;
> -	} else {
> -		cycles = 0;
> -		ns     = 0;
> -	}
> +	cycles = cycles/tot;
> +	ns     = ns/tot;
>   
>   	printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
>   	       thr, str, cycles, ns);
diff mbox

Patch

diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c
index 5f25f89..1ed4a0b 100644
--- a/example/odp_example/odp_example.c
+++ b/example/odp_example/odp_example.c
@@ -355,13 +355,8 @@  static int test_schedule_one_single(const char *str, int thr,
 	odp_barrier_sync(barrier);
 	clear_sched_queues();
 
-	if (tot) {
-		cycles = cycles/tot;
-		ns     = ns/tot;
-	} else {
-		cycles = 0;
-		ns     = 0;
-	}
+	cycles = cycles/tot;
+	ns     = ns/tot;
 
 	printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
 	       thr, str, cycles, ns);