2022-05-25 20:12:37

by Vasily Averin

[permalink] [raw]
Subject: Re: [PATCH] ipc: Remove dead code in perform_atomic_semop()

On 5/24/22 21:22, Gautam Menghani wrote:
> Remove the line which is dead code. Fixes the clang scan warning:
> warning: Value stored to 'result' is never read [deadcode.DeadStores]
> result = curr->semval;
>
> Signed-off-by: Gautam Menghani <[email protected]>
> ---
> ipc/sem.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/ipc/sem.c b/ipc/sem.c
> index 0dbdb98fdf2d..156824bcda47 100644
> --- a/ipc/sem.c
> +++ b/ipc/sem.c
> @@ -766,7 +766,6 @@ static int perform_atomic_semop(struct sem_array *sma, struct sem_queue *q)
> for (sop = sops; sop < sops + nsops; sop++) {
> curr = &sma->sems[sop->sem_num];
> sem_op = sop->sem_op;
> - result = curr->semval;
>
> if (sop->sem_flg & SEM_UNDO) {
> int undo = un->semadj[sop->sem_num] - sem_op;

Perhaps it would be better to keep the "result" but use it in the
marked line below, like it was done in previous part of this function?

un->semadj[sop->sem_num] = undo;
}
curr->semval += sem_op; <<<<<< VvS: here ?
ipc_update_pid(&curr->sempid, q->pid);

Thank you,
Vasily Averin


2022-05-26 00:07:55

by Vasily Averin

[permalink] [raw]
Subject: Re: [PATCH] ipc: Remove dead code in perform_atomic_semop()

On 5/25/22 02:12, [email protected] wrote:
> On 5/24/22 21:22, Gautam Menghani wrote:
>> Remove the line which is dead code. Fixes the clang scan warning:
>> warning: Value stored to 'result' is never read [deadcode.DeadStores]
>> result = curr->semval;
>>
>> Signed-off-by: Gautam Menghani <[email protected]>
>> ---
>> ipc/sem.c | 1 -
>> 1 file changed, 1 deletion(-)
>>
>> diff --git a/ipc/sem.c b/ipc/sem.c
>> index 0dbdb98fdf2d..156824bcda47 100644
>> --- a/ipc/sem.c
>> +++ b/ipc/sem.c
>> @@ -766,7 +766,6 @@ static int perform_atomic_semop(struct sem_array *sma, struct sem_queue *q)
>> for (sop = sops; sop < sops + nsops; sop++) {
>> curr = &sma->sems[sop->sem_num];
>> sem_op = sop->sem_op;
>> - result = curr->semval;
>>
>> if (sop->sem_flg & SEM_UNDO) {
>> int undo = un->semadj[sop->sem_num] - sem_op;
>
> Perhaps it would be better to keep the "result" but use it in the
> marked line below, like it was done in previous part of this function?

Sorry, I was wrong.
Reviewed-by: Vasily Averin <[email protected]>