All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] batman-adv: Fix the wrong definition
@ 2021-10-28  7:23 Yajun Deng
  2021-10-28  7:34 ` Sven Eckelmann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yajun Deng @ 2021-10-28  7:23 UTC (permalink / raw)
  To: mareklindner, sw, a, sven; +Cc: b.a.t.m.a.n, netdev, linux-kernel, Yajun Deng

There are three variables that are required at most,
no need to define four variables.

Fixes: 0fa4c30d710d ("batman-adv: Make sysfs support optional")
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 net/batman-adv/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 3ddd66e4c29e..758035b3796d 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -656,7 +656,7 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
 {
 	int ret = -ENOMEM;
 	struct kobject *bat_kobj;
-	char *uevent_env[4] = { NULL, NULL, NULL, NULL };
+	char *uevent_env[3] = {};
 
 	bat_kobj = &bat_priv->soft_iface->dev.kobj;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] batman-adv: Fix the wrong definition
  2021-10-28  7:23 [PATCH net-next] batman-adv: Fix the wrong definition Yajun Deng
@ 2021-10-28  7:34 ` Sven Eckelmann
  2021-10-28  7:35 ` Antonio Quartulli
  2021-10-28  7:49 ` yajun.deng
  2 siblings, 0 replies; 4+ messages in thread
From: Sven Eckelmann @ 2021-10-28  7:34 UTC (permalink / raw)
  To: mareklindner, sw, a, Yajun Deng
  Cc: b.a.t.m.a.n, netdev, linux-kernel, Yajun Deng

[-- Attachment #1: Type: text/plain, Size: 1587 bytes --]

On Thursday, 28 October 2021 09:23:06 CEST Yajun Deng wrote:
> There are three variables that are required at most,
> no need to define four variables.

NAck. This is absolutely wrong - the last one is the "STOP" info. With your 
patch, it would sometimes (action != BATADV_UEV_DEL) not have the stop NULL.
See also the second parameter in this for loop on line
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/kobject_uevent.c?id=1fc596a56b334f4d593a2b49e5ff55af6aaa0816#n548

We can discuss that this can be written in a better way. See 
https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/1403982781.9064.33.camel@joe-AO725/ 
(also the remark from Antonio).

> 
> Fixes: 0fa4c30d710d ("batman-adv: Make sysfs support optional")

Even this Fixes would be wrong. The code is there since commit
c6bda689c2c9 ("batman-adv: add wrapper function to throw uevent in 
userspace").

But even then, this would not fix anything but just be a cleanup.

> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
>  net/batman-adv/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
> index 3ddd66e4c29e..758035b3796d 100644
> --- a/net/batman-adv/main.c
> +++ b/net/batman-adv/main.c
> @@ -656,7 +656,7 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
>  {
>  	int ret = -ENOMEM;
>  	struct kobject *bat_kobj;
> -	char *uevent_env[4] = { NULL, NULL, NULL, NULL };
> +	char *uevent_env[3] = {};
>  
>  	bat_kobj = &bat_priv->soft_iface->dev.kobj;
>  
> 


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] batman-adv: Fix the wrong definition
  2021-10-28  7:23 [PATCH net-next] batman-adv: Fix the wrong definition Yajun Deng
  2021-10-28  7:34 ` Sven Eckelmann
@ 2021-10-28  7:35 ` Antonio Quartulli
  2021-10-28  7:49 ` yajun.deng
  2 siblings, 0 replies; 4+ messages in thread
From: Antonio Quartulli @ 2021-10-28  7:35 UTC (permalink / raw)
  To: Yajun Deng, mareklindner, sw, sven; +Cc: b.a.t.m.a.n, netdev, linux-kernel

Hi,

On 28/10/2021 09:23, Yajun Deng wrote:
> There are three variables that are required at most,
> no need to define four variables.
> 
> Fixes: 0fa4c30d710d ("batman-adv: Make sysfs support optional")
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>

NAK.

kobject_uevent_env() does not know how many items are stored in the
array and thus requires it to be NULL terminated.

Please check the following for reference:

https://elixir.bootlin.com/linux/v5.15-rc6/source/lib/kobject_uevent.c#L548

OTOH I guess we could still use '{}' for the initialization.

Regards,

-- 
Antonio Quartulli

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] batman-adv: Fix the wrong definition
  2021-10-28  7:23 [PATCH net-next] batman-adv: Fix the wrong definition Yajun Deng
  2021-10-28  7:34 ` Sven Eckelmann
  2021-10-28  7:35 ` Antonio Quartulli
@ 2021-10-28  7:49 ` yajun.deng
  2 siblings, 0 replies; 4+ messages in thread
From: yajun.deng @ 2021-10-28  7:49 UTC (permalink / raw)
  To: Antonio Quartulli, mareklindner, sw, sven
  Cc: b.a.t.m.a.n, netdev, linux-kernel

October 28, 2021 3:35 PM, "Antonio Quartulli" <a@unstable.cc> 写到:

> Hi,
> 
> On 28/10/2021 09:23, Yajun Deng wrote:
> 
>> There are three variables that are required at most,
>> no need to define four variables.
>> 
>> Fixes: 0fa4c30d710d ("batman-adv: Make sysfs support optional")
>> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> 
> NAK.
> 
> kobject_uevent_env() does not know how many items are stored in the
> array and thus requires it to be NULL terminated.
> 
> Please check the following for reference:
> 
> https://elixir.bootlin.com/linux/v5.15-rc6/source/lib/kobject_uevent.c#L548
> 
Oh, I didn't notice there.
> OTOH I guess we could still use '{}' for the initialization.
> 
> Regards,
> 
> --
> Antonio Quartulli

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-28  8:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28  7:23 [PATCH net-next] batman-adv: Fix the wrong definition Yajun Deng
2021-10-28  7:34 ` Sven Eckelmann
2021-10-28  7:35 ` Antonio Quartulli
2021-10-28  7:49 ` yajun.deng

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.