* [PATCH] staging: vt6655: device_main: switch multiple assignment for one assignment per line
@ 2020-03-15 4:46 Lourdes Pedrajas
2020-03-15 8:05 ` [Outreachy kernel] " Julia Lawall
2020-03-17 11:09 ` Greg KH
0 siblings, 2 replies; 5+ messages in thread
From: Lourdes Pedrajas @ 2020-03-15 4:46 UTC (permalink / raw)
To: outreachy-kernel, gregkh, forest
One assignment per line is preferred, instead of multiple assignments.
To prevent possible undefined behavior.
Issue found with checkpath.
Signed-off-by: Lourdes Pedrajas <lu@pplo.net>
---
drivers/staging/vt6655/device_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 0442f71494b2..c271e3937125 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -708,7 +708,8 @@ static int device_init_td1_ring(struct vnt_private *priv)
if (i > 0)
priv->apTD1Rings[i - 1].next_desc = cpu_to_le32(priv->td1_pool_dma);
- priv->apTailTD[1] = priv->apCurrTD[1] = &priv->apTD1Rings[0];
+ priv->apCurrTD[1] = &priv->apTD1Rings[0];
+ priv->apTailTD[1] = &priv->apTD1Rings[0];
return 0;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: vt6655: device_main: switch multiple assignment for one assignment per line
2020-03-15 4:46 [PATCH] staging: vt6655: device_main: switch multiple assignment for one assignment per line Lourdes Pedrajas
@ 2020-03-15 8:05 ` Julia Lawall
2020-03-15 22:31 ` Lourdes Pedrajas
2020-03-17 11:09 ` Greg KH
1 sibling, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2020-03-15 8:05 UTC (permalink / raw)
To: Lourdes Pedrajas; +Cc: outreachy-kernel, gregkh, forest
On Sun, 15 Mar 2020, Lourdes Pedrajas wrote:
> One assignment per line is preferred, instead of multiple assignments.
> To prevent possible undefined behavior.
There is no possible undefined behavior. The C semantics provides a
definition of what this means. On the other hand, people don't seem to be
so familiar with what this semantics is. Looking quickly with Google, I
find some pages that think that it is the value of the left side
expression and some pages that this that it is the value of the right side
expression. This can have an impact if the types are different and the
assignment involves an implicit cast. Here all the types are the same.
I'm not really sure which would be preferred. The original code is a bit
more concise. The modified code is a bit more clear, because one can find
what is assigned by just looking in one standard place, ie the left side
of the code.
> Issue found with checkpath.
checkpatch :)
julia
>
> Signed-off-by: Lourdes Pedrajas <lu@pplo.net>
> ---
> drivers/staging/vt6655/device_main.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
> index 0442f71494b2..c271e3937125 100644
> --- a/drivers/staging/vt6655/device_main.c
> +++ b/drivers/staging/vt6655/device_main.c
> @@ -708,7 +708,8 @@ static int device_init_td1_ring(struct vnt_private *priv)
>
> if (i > 0)
> priv->apTD1Rings[i - 1].next_desc = cpu_to_le32(priv->td1_pool_dma);
> - priv->apTailTD[1] = priv->apCurrTD[1] = &priv->apTD1Rings[0];
> + priv->apCurrTD[1] = &priv->apTD1Rings[0];
> + priv->apTailTD[1] = &priv->apTD1Rings[0];
>
> return 0;
>
> --
> 2.17.1
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20200315044620.14104-1-lu%40pplo.net.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: vt6655: device_main: switch multiple assignment for one assignment per line
2020-03-15 8:05 ` [Outreachy kernel] " Julia Lawall
@ 2020-03-15 22:31 ` Lourdes Pedrajas
0 siblings, 0 replies; 5+ messages in thread
From: Lourdes Pedrajas @ 2020-03-15 22:31 UTC (permalink / raw)
To: Julia Lawall; +Cc: outreachy-kernel, gregkh, forest
On Sun, Mar 15, 2020 at 09:05:02AM +0100, Julia Lawall wrote:
>
>
> On Sun, 15 Mar 2020, Lourdes Pedrajas wrote:
>
> > One assignment per line is preferred, instead of multiple assignments.
> > To prevent possible undefined behavior.
>
> There is no possible undefined behavior. The C semantics provides a
> definition of what this means. On the other hand, people don't seem to be
> so familiar with what this semantics is. Looking quickly with Google, I
> find some pages that think that it is the value of the left side
> expression and some pages that this that it is the value of the right side
> expression. This can have an impact if the types are different and the
> assignment involves an implicit cast. Here all the types are the same.
>
> I'm not really sure which would be preferred. The original code is a bit
> more concise. The modified code is a bit more clear, because one can find
> what is assigned by just looking in one standard place, ie the left side
> of the code.
>
> > Issue found with checkpath.
>
> checkpatch :)
>
> julia
>
I also was unsure if it was undefined behavior as checkpatch says, it
assign 3rd value to 2nd, and then to 1st, to me is clear.
The change may make the code more readable and would help people that is not
familiar with multiple assignments.
If the maintainer agree, I will simply correct the typo in checkpatch :)
Thank you Julia!
Lourdes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: vt6655: device_main: switch multiple assignment for one assignment per line
2020-03-15 4:46 [PATCH] staging: vt6655: device_main: switch multiple assignment for one assignment per line Lourdes Pedrajas
2020-03-15 8:05 ` [Outreachy kernel] " Julia Lawall
@ 2020-03-17 11:09 ` Greg KH
2020-03-17 17:29 ` Lourdes Pedrajas
1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2020-03-17 11:09 UTC (permalink / raw)
To: Lourdes Pedrajas; +Cc: outreachy-kernel, forest
On Sun, Mar 15, 2020 at 05:46:20AM +0100, Lourdes Pedrajas wrote:
> One assignment per line is preferred, instead of multiple assignments.
> To prevent possible undefined behavior.
> Issue found with checkpath.
>
> Signed-off-by: Lourdes Pedrajas <lu@pplo.net>
> ---
> drivers/staging/vt6655/device_main.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
> index 0442f71494b2..c271e3937125 100644
> --- a/drivers/staging/vt6655/device_main.c
> +++ b/drivers/staging/vt6655/device_main.c
> @@ -708,7 +708,8 @@ static int device_init_td1_ring(struct vnt_private *priv)
>
> if (i > 0)
> priv->apTD1Rings[i - 1].next_desc = cpu_to_le32(priv->td1_pool_dma);
> - priv->apTailTD[1] = priv->apCurrTD[1] = &priv->apTD1Rings[0];
> + priv->apCurrTD[1] = &priv->apTD1Rings[0];
> + priv->apTailTD[1] = &priv->apTD1Rings[0];
As others said here, there is no undefined behavior, the original code
is just fine.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: vt6655: device_main: switch multiple assignment for one assignment per line
2020-03-17 11:09 ` Greg KH
@ 2020-03-17 17:29 ` Lourdes Pedrajas
0 siblings, 0 replies; 5+ messages in thread
From: Lourdes Pedrajas @ 2020-03-17 17:29 UTC (permalink / raw)
To: Greg KH; +Cc: outreachy-kernel, forest
On Tue, Mar 17, 2020 at 12:09:38PM +0100, Greg KH wrote:
> On Sun, Mar 15, 2020 at 05:46:20AM +0100, Lourdes Pedrajas wrote:
> > One assignment per line is preferred, instead of multiple assignments.
> > To prevent possible undefined behavior.
> > Issue found with checkpath.
> >
> > Signed-off-by: Lourdes Pedrajas <lu@pplo.net>
> > ---
> > drivers/staging/vt6655/device_main.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
> > index 0442f71494b2..c271e3937125 100644
> > --- a/drivers/staging/vt6655/device_main.c
> > +++ b/drivers/staging/vt6655/device_main.c
> > @@ -708,7 +708,8 @@ static int device_init_td1_ring(struct vnt_private *priv)
> >
> > if (i > 0)
> > priv->apTD1Rings[i - 1].next_desc = cpu_to_le32(priv->td1_pool_dma);
> > - priv->apTailTD[1] = priv->apCurrTD[1] = &priv->apTD1Rings[0];
> > + priv->apCurrTD[1] = &priv->apTD1Rings[0];
> > + priv->apTailTD[1] = &priv->apTD1Rings[0];
>
> As others said here, there is no undefined behavior, the original code
> is just fine.
>
> thanks,
>
> greg k-h
I agree, thank you,
Lourdes
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-17 17:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-15 4:46 [PATCH] staging: vt6655: device_main: switch multiple assignment for one assignment per line Lourdes Pedrajas
2020-03-15 8:05 ` [Outreachy kernel] " Julia Lawall
2020-03-15 22:31 ` Lourdes Pedrajas
2020-03-17 11:09 ` Greg KH
2020-03-17 17:29 ` Lourdes Pedrajas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.