Skip to contentSkip to conversation

lib/string_choices: Sorting function order

PATCH Applied R Sundar 5 participants 8 messages Nov 19, 2024 – Mar 3, 2025 Generic string library

lore
Share & tools
lore

R Sundar

author
#0 lore raw

v2 cover lib/string_choices: Sorting function order

This patch series rearrange misplaced functions in sorted order and add str_locked_unlocked() helper.

---

Changes in v2: Rearrange functions in sorted order as seperate patch.

Changes in v1: Add str_locked_unlocked helper function alone.
link to v1: https://lore.kernel.org/all/[email protected]/
---

R Sundar (2):
lib/string_choices: Rearrange functions in sorted order lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked()
helper

 include/linux/string_choices.h | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/2 lib/string_choices: Rearrange functions in sorted order

Rearrange misplaced functions in sorted order.

---
 include/linux/string_choices.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
include/linux/string_choices.h +12 -12
index 120ca0f28e95..f3ba4f52ff26 100644
@@ -41,23 +41,23 @@ static inline const char *str_high_low(bool v)
 }
 #define str_low_high(v)		str_high_low(!(v))
 
-static inline const char *str_read_write(bool v)
-{
-	return v ? "read" : "write";
-}
-#define str_write_read(v)		str_read_write(!(v))
-
 static inline const char *str_on_off(bool v)
 {
 	return v ? "on" : "off";
 }
 #define str_off_on(v)		str_on_off(!(v))
 
-static inline const char *str_yes_no(bool v)
+static inline const char *str_read_write(bool v)
 {
-	return v ? "yes" : "no";
+	return v ? "read" : "write";
 }
-#define str_no_yes(v)		str_yes_no(!(v))
+#define str_write_read(v)		str_read_write(!(v))
+
+static inline const char *str_true_false(bool v)
+{
+	return v ? "true" : "false";
+}
+#define str_false_true(v)		str_true_false(!(v))
 
 static inline const char *str_up_down(bool v)
 {
@@ -65,11 +65,11 @@ static inline const char *str_up_down(bool v)
 }
 #define str_down_up(v)		str_up_down(!(v))
 
-static inline const char *str_true_false(bool v)
+static inline const char *str_yes_no(bool v)
 {
-	return v ? "true" : "false";
+	return v ? "yes" : "no";
 }
-#define str_false_true(v)		str_true_false(!(v))
+#define str_no_yes(v)		str_yes_no(!(v))
 
 /**
  * str_plural - Return the simple pluralization based on English counts
Signature · 1 line
2.34.1
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 linux-next 1/2] lib/string_choices: Rearrange functions in sorted order

Quoted 4 lines · R Sundar

Rearrange misplaced functions in sorted order.

This is a much-needed patch.

R Sundar,
Can I pick it into my series in case it will not be accepted in the nearest future? (I do not promise this, but there is a chance)

Quoted 59 lines
---
 include/linux/string_choices.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
include/linux/string_choices.h +12 -12
index 120ca0f28e95..f3ba4f52ff26 100644
@@ -41,23 +41,23 @@ static inline const char *str_high_low(bool v)
 }
 #define str_low_high(v)		str_high_low(!(v))
 
-static inline const char *str_read_write(bool v)
-{
-	return v ? "read" : "write";
-}
-#define str_write_read(v)		str_read_write(!(v))
-
 static inline const char *str_on_off(bool v)
 {
 	return v ? "on" : "off";
 }
 #define str_off_on(v)		str_on_off(!(v))
 
-static inline const char *str_yes_no(bool v)
+static inline const char *str_read_write(bool v)
 {
-	return v ? "yes" : "no";
+	return v ? "read" : "write";
 }
-#define str_no_yes(v)		str_yes_no(!(v))
+#define str_write_read(v)		str_read_write(!(v))
+
+static inline const char *str_true_false(bool v)
+{
+	return v ? "true" : "false";
+}
+#define str_false_true(v)		str_true_false(!(v))
 
 static inline const char *str_up_down(bool v)
 {
@@ -65,11 +65,11 @@ static inline const char *str_up_down(bool v)
 }
 #define str_down_up(v)		str_up_down(!(v))
 
-static inline const char *str_true_false(bool v)
+static inline const char *str_yes_no(bool v)
 {
-	return v ? "true" : "false";
+	return v ? "yes" : "no";
 }
-#define str_false_true(v)		str_true_false(!(v))
+#define str_no_yes(v)		str_yes_no(!(v))
 
 /**
  * str_plural - Return the simple pluralization based on English counts
Signature · 1 line
2.34.1
author
#3 lore raw

Re: [PATCH v2 linux-next 1/2] lib/string_choices: Rearrange functions in sorted order

Quoted 6 lines · Larysa Zaremba
Quoted 4 lines · R Sundar

Rearrange misplaced functions in sorted order.

Quoted 8 lines

This is a much-needed patch.

R Sundar,
Can I pick it into my series in case it will not be accepted in the nearest future? (I do not promise this, but there is a chance)

Hi,

Yes, Please.

Thanks.

Best Regards,
Sundar

Quoted 59 lines
Quoted 59 lines
---
  include/linux/string_choices.h | 24 ++++++++++++------------
  1 file changed, 12 insertions(+), 12 deletions(-)
include/linux/string_choices.h +12 -12
index 120ca0f28e95..f3ba4f52ff26 100644
@@ -41,23 +41,23 @@ static inline const char *str_high_low(bool v)
  }
  #define str_low_high(v)		str_high_low(!(v))
 
-static inline const char *str_read_write(bool v)
-{
-	return v ? "read" : "write";
-}
-#define str_write_read(v)		str_read_write(!(v))
-
  static inline const char *str_on_off(bool v)
  {
  	return v ? "on" : "off";
  }
  #define str_off_on(v)		str_on_off(!(v))
 
-static inline const char *str_yes_no(bool v)
+static inline const char *str_read_write(bool v)
  {
-	return v ? "yes" : "no";
+	return v ? "read" : "write";
  }
-#define str_no_yes(v)		str_yes_no(!(v))
+#define str_write_read(v)		str_read_write(!(v))
+
+static inline const char *str_true_false(bool v)
+{
+	return v ? "true" : "false";
+}
+#define str_false_true(v)		str_true_false(!(v))
 
  static inline const char *str_up_down(bool v)
  {
@@ -65,11 +65,11 @@ static inline const char *str_up_down(bool v)
  }
  #define str_down_up(v)		str_up_down(!(v))
 
-static inline const char *str_true_false(bool v)
+static inline const char *str_yes_no(bool v)
  {
-	return v ? "true" : "false";
+	return v ? "yes" : "no";
  }
-#define str_false_true(v)		str_true_false(!(v))
+#define str_no_yes(v)		str_yes_no(!(v))
 
  /**
   * str_plural - Return the simple pluralization based on English counts
Signature · 1 line
2.34.1
maintainer Applied
#4 lore raw

Re: (subset) [PATCH v2 linux-next 1/2] lib/string_choices: Rearrange functions in sorted order

In reply to R Sundar
Quoted 3 lines · R Sundar

Rearrange misplaced functions in sorted order.

Applied to for-next/hardening, thanks!

[1/2] lib/string_choices: Rearrange functions in sorted order

      https://git.kernel.org/kees/c/e8cd61e403ea

Take care,

Signature · 1 line
Kees Cook
author
#5 lore raw

PATCH v2 2/2 lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked() helper

In reply to R Sundar

Add str_locked_unlocked()/str_unlocked_locked() helper to return "locked" or "unlocked" string literal.

---
 include/linux/string_choices.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/linux/string_choices.h +6 -0
index f3ba4f52ff26..a6bbf4e42c13 100644
@@ -41,6 +41,12 @@ static inline const char *str_high_low(bool v)
 }
 #define str_low_high(v)		str_high_low(!(v))
 
+static inline const char *str_locked_unlocked(bool v)
+{
+	return v ? "locked" : "unlocked";
+}
+#define str_unlocked_locked(v)         str_locked_unlocked(!(v))
+
 static inline const char *str_on_off(bool v)
 {
 	return v ? "on" : "off";
Signature · 1 line
2.34.1
#7 lore raw
In reply to R Sundar
Quoted 2 lines · R Sundar

This patch series rearrange misplaced functions in sorted order and add str_locked_unlocked() helper.

Kees, anything preventing us to apply the first patch from the series?

Signature · 2 lines
With Best Regards,
Andy Shevchenko