All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: Use str_yes_no() and str_no_yes() helper functions
@ 2024-10-26 11:29 Thorsten Blum
  2024-10-26 14:54 ` Willem de Bruijn
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2024-10-26 11:29 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Willem de Bruijn, Gou Hao, Mina Almasry,
	Abhishek Chauhan, Kuniyuki Iwashima
  Cc: Thorsten Blum, netdev, linux-kernel

Remove hard-coded strings by using the str_yes_no() and str_no_yes()
helper functions.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 net/core/sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 039be95c40cf..132c8d2cda26 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -4140,7 +4140,7 @@ static long sock_prot_memory_allocated(struct proto *proto)
 static const char *sock_prot_memory_pressure(struct proto *proto)
 {
 	return proto->memory_pressure != NULL ?
-	proto_memory_pressure(proto) ? "yes" : "no" : "NI";
+		str_yes_no(proto_memory_pressure(proto)) : "NI";
 }
 
 static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
@@ -4154,7 +4154,7 @@ static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
 		   sock_prot_memory_allocated(proto),
 		   sock_prot_memory_pressure(proto),
 		   proto->max_header,
-		   proto->slab == NULL ? "no" : "yes",
+		   str_no_yes(proto->slab == NULL),
 		   module_name(proto->owner),
 		   proto_method_implemented(proto->close),
 		   proto_method_implemented(proto->connect),
-- 
2.47.0


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

* Re: [PATCH net-next] net: Use str_yes_no() and str_no_yes() helper functions
  2024-10-26 11:29 [PATCH net-next] net: Use str_yes_no() and str_no_yes() helper functions Thorsten Blum
@ 2024-10-26 14:54 ` Willem de Bruijn
  2024-10-26 15:14   ` Thorsten Blum
  0 siblings, 1 reply; 3+ messages in thread
From: Willem de Bruijn @ 2024-10-26 14:54 UTC (permalink / raw)
  To: Thorsten Blum, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Willem de Bruijn, Gou Hao,
	Mina Almasry, Abhishek Chauhan, Kuniyuki Iwashima
  Cc: Thorsten Blum, netdev, linux-kernel

Thorsten Blum wrote:
> Remove hard-coded strings by using the str_yes_no() and str_no_yes()
> helper functions.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  net/core/sock.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 039be95c40cf..132c8d2cda26 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -4140,7 +4140,7 @@ static long sock_prot_memory_allocated(struct proto *proto)
>  static const char *sock_prot_memory_pressure(struct proto *proto)
>  {
>  	return proto->memory_pressure != NULL ?
> -	proto_memory_pressure(proto) ? "yes" : "no" : "NI";
> +		str_yes_no(proto_memory_pressure(proto)) : "NI";
>  }
>  
>  static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
> @@ -4154,7 +4154,7 @@ static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
>  		   sock_prot_memory_allocated(proto),
>  		   sock_prot_memory_pressure(proto),
>  		   proto->max_header,
> -		   proto->slab == NULL ? "no" : "yes",
> +		   str_no_yes(proto->slab == NULL),

Just one opinion, but to reiterate from a previous similar patch:

I find this less readable than the original open code variant.

include/linux/string_choices.h mentions three goals: elegance,
consistency and binary size. The third goal could be an argument for
this change perhaps.

proto->slab : "yes" : "no" would arguably be even easier than the
current form, and a conversion could similarly use str_yes_no.


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

* Re: [PATCH net-next] net: Use str_yes_no() and str_no_yes() helper functions
  2024-10-26 14:54 ` Willem de Bruijn
@ 2024-10-26 15:14   ` Thorsten Blum
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2024-10-26 15:14 UTC (permalink / raw)
  To: Willem de Bruijn
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Willem de Bruijn, Gou Hao, Mina Almasry,
	Abhishek Chauhan, Kuniyuki Iwashima, netdev, linux-kernel

On 26. Oct 2024, at 16:54, Willem de Bruijn wrote:
> proto->slab : "yes" : "no" would arguably be even easier than the
> current form, and a conversion could similarly use str_yes_no.

Happy to change this and submit a v2.

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

end of thread, other threads:[~2024-10-26 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-26 11:29 [PATCH net-next] net: Use str_yes_no() and str_no_yes() helper functions Thorsten Blum
2024-10-26 14:54 ` Willem de Bruijn
2024-10-26 15:14   ` Thorsten Blum

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.