* [PATCH linux-next] lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked() helper @ 2024-11-15 14:46 R Sundar 2024-11-15 19:44 ` Andy Shevchenko 0 siblings, 1 reply; 6+ messages in thread From: R Sundar @ 2024-11-15 14:46 UTC (permalink / raw) To: Kees Cook, Andy Shevchenko Cc: linux-hardening, linux-kernel, R Sundar, Przemek Kitszel Add str_locked_unlocked()/str_unlocked_locked() helper to return "locked" or "unlocked" string literal Suggested-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Signed-off-by: R Sundar <prosunofficial@gmail.com> --- https://lore.kernel.org/all/ca4f7990-16c4-42ef-b0ae-12e64a100f5e@intel.com/ https://lore.kernel.org/all/498a3d58-55e0-4349-bd92-8ce16c6016@inria.fr/ There are about 9 occurence for locked and unlocked string combination. include/linux/string_choices.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h index 120ca0f28e95..c3ad47e1051b 100644 --- a/include/linux/string_choices.h +++ b/include/linux/string_choices.h @@ -82,4 +82,10 @@ static inline const char *str_plural(size_t num) return num == 1 ? "" : "s"; } +static inline const char *str_locked_unlocked(bool v) +{ + return v ? "locked" : "unlocked"; +} +#define str_unlocked_locked(v) str_locked_unlocked(!(v)) + #endif -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH linux-next] lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked() helper 2024-11-15 14:46 [PATCH linux-next] lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked() helper R Sundar @ 2024-11-15 19:44 ` Andy Shevchenko 2024-11-15 19:46 ` Andy Shevchenko 0 siblings, 1 reply; 6+ messages in thread From: Andy Shevchenko @ 2024-11-15 19:44 UTC (permalink / raw) To: R Sundar Cc: Kees Cook, Andy Shevchenko, linux-hardening, linux-kernel, Przemek Kitszel On Fri, Nov 15, 2024 at 4:47 PM R Sundar <prosunofficial@gmail.com> wrote: > > Add str_locked_unlocked()/str_unlocked_locked() helper to return > "locked" or "unlocked" string literal Missing period. ... > --- a/include/linux/string_choices.h > +++ b/include/linux/string_choices.h > @@ -82,4 +82,10 @@ static inline const char *str_plural(size_t num) > return num == 1 ? "" : "s"; > } > > +static inline const char *str_locked_unlocked(bool v) > +{ > + return v ? "locked" : "unlocked"; > +} > +#define str_unlocked_locked(v) str_locked_unlocked(!(v)) The rest is sorted (okay, read_write() seems to be misplaced, fix that in a separate change if you wish), please keep it that way (I believe it should go before on_off). -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH linux-next] lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked() helper 2024-11-15 19:44 ` Andy Shevchenko @ 2024-11-15 19:46 ` Andy Shevchenko 2024-11-16 3:48 ` R Sundar 0 siblings, 1 reply; 6+ messages in thread From: Andy Shevchenko @ 2024-11-15 19:46 UTC (permalink / raw) To: R Sundar Cc: Kees Cook, Andy Shevchenko, linux-hardening, linux-kernel, Przemek Kitszel On Fri, Nov 15, 2024 at 9:44 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Fri, Nov 15, 2024 at 4:47 PM R Sundar <prosunofficial@gmail.com> wrote: ... > > --- a/include/linux/string_choices.h > > +++ b/include/linux/string_choices.h > > @@ -82,4 +82,10 @@ static inline const char *str_plural(size_t num) > > return num == 1 ? "" : "s"; > > } > > > > +static inline const char *str_locked_unlocked(bool v) > > +{ > > + return v ? "locked" : "unlocked"; > > +} > > +#define str_unlocked_locked(v) str_locked_unlocked(!(v)) > > The rest is sorted (okay, read_write() seems to be misplaced, fix that > in a separate change if you wish), please keep it that way (I believe > it should go before on_off). Oh, I looked in v6.11 code, in v6.12 there are a couple of more misplacements. Can you fix them all, please? -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH linux-next] lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked() helper 2024-11-15 19:46 ` Andy Shevchenko @ 2024-11-16 3:48 ` R Sundar 2024-11-17 20:03 ` Andy Shevchenko 0 siblings, 1 reply; 6+ messages in thread From: R Sundar @ 2024-11-16 3:48 UTC (permalink / raw) To: Andy Shevchenko Cc: Kees Cook, Andy Shevchenko, linux-hardening, linux-kernel, Przemek Kitszel On 16/11/24 01:16, Andy Shevchenko wrote: > On Fri, Nov 15, 2024 at 9:44 PM Andy Shevchenko > <andy.shevchenko@gmail.com> wrote: >> On Fri, Nov 15, 2024 at 4:47 PM R Sundar <prosunofficial@gmail.com> wrote: > > ... > >>> --- a/include/linux/string_choices.h >>> +++ b/include/linux/string_choices.h >>> @@ -82,4 +82,10 @@ static inline const char *str_plural(size_t num) >>> return num == 1 ? "" : "s"; >>> } >>> >>> +static inline const char *str_locked_unlocked(bool v) >>> +{ >>> + return v ? "locked" : "unlocked"; >>> +} >>> +#define str_unlocked_locked(v) str_locked_unlocked(!(v)) >> >> The rest is sorted (okay, read_write() seems to be misplaced, fix that >> in a separate change if you wish), please keep it that way (I believe >> it should go before on_off). > Hi, Thanks for the Review and Comments provided. Please correct me, If I am wrong. The function name should be in sorted order means, str_read_write() will go after str_on_off(). For example, the sorted order of function will be like: str_on_off() str_plural() str_read_write() > Oh, I looked in v6.11 code, in v6.12 there are a couple of more > misplacements. Can you fix them all, please? > Sure, Will sort it and send as seperate patch. Thanks, Sundar ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH linux-next] lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked() helper 2024-11-16 3:48 ` R Sundar @ 2024-11-17 20:03 ` Andy Shevchenko 2024-11-18 3:10 ` R Sundar 0 siblings, 1 reply; 6+ messages in thread From: Andy Shevchenko @ 2024-11-17 20:03 UTC (permalink / raw) To: R Sundar Cc: Kees Cook, Andy Shevchenko, linux-hardening, linux-kernel, Przemek Kitszel On Sat, Nov 16, 2024 at 5:48 AM R Sundar <prosunofficial@gmail.com> wrote: > On 16/11/24 01:16, Andy Shevchenko wrote: > > On Fri, Nov 15, 2024 at 9:44 PM Andy Shevchenko > > <andy.shevchenko@gmail.com> wrote: > >> On Fri, Nov 15, 2024 at 4:47 PM R Sundar <prosunofficial@gmail.com> wrote: ... > >>> +static inline const char *str_locked_unlocked(bool v) > >>> +{ > >>> + return v ? "locked" : "unlocked"; > >>> +} > >>> +#define str_unlocked_locked(v) str_locked_unlocked(!(v)) > >> > >> The rest is sorted (okay, read_write() seems to be misplaced, fix that > >> in a separate change if you wish), please keep it that way (I believe > >> it should go before on_off). > > Thanks for the Review and Comments provided. > > Please correct me, If I am wrong. > > The function name should be in sorted order means, str_read_write() > will go after str_on_off(). > > For example, the sorted order of function will be like: > > str_on_off() > str_plural() Leave this one to be last, it's special in comparison to the rest. See what the type of the parameter it has for the details. > str_read_write() > > > Oh, I looked in v6.11 code, in v6.12 there are a couple of more > > misplacements. Can you fix them all, please? > > > Sure, Will sort it and send as seperate patch. Thank you! -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH linux-next] lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked() helper 2024-11-17 20:03 ` Andy Shevchenko @ 2024-11-18 3:10 ` R Sundar 0 siblings, 0 replies; 6+ messages in thread From: R Sundar @ 2024-11-18 3:10 UTC (permalink / raw) To: Andy Shevchenko Cc: Kees Cook, Andy Shevchenko, linux-hardening, linux-kernel, Przemek Kitszel On 18/11/24 01:33, Andy Shevchenko wrote: > On Sat, Nov 16, 2024 at 5:48 AM R Sundar <prosunofficial@gmail.com> wrote: >> On 16/11/24 01:16, Andy Shevchenko wrote: >>> On Fri, Nov 15, 2024 at 9:44 PM Andy Shevchenko >>> <andy.shevchenko@gmail.com> wrote: >>>> On Fri, Nov 15, 2024 at 4:47 PM R Sundar <prosunofficial@gmail.com> wrote: > > ... > >>>>> +static inline const char *str_locked_unlocked(bool v) >>>>> +{ >>>>> + return v ? "locked" : "unlocked"; >>>>> +} >>>>> +#define str_unlocked_locked(v) str_locked_unlocked(!(v)) >>>> >>>> The rest is sorted (okay, read_write() seems to be misplaced, fix that >>>> in a separate change if you wish), please keep it that way (I believe >>>> it should go before on_off). >> >> Thanks for the Review and Comments provided. >> >> Please correct me, If I am wrong. >> >> The function name should be in sorted order means, str_read_write() >> will go after str_on_off(). >> >> For example, the sorted order of function will be like: >> >> str_on_off() > >> str_plural() > > Leave this one to be last, it's special in comparison to the rest. See > what the type of the parameter it has for the details. > Hi, Noted. Thanks for clarifying it. With Regards, Sundar >> str_read_write() >> >>> Oh, I looked in v6.11 code, in v6.12 there are a couple of more >>> misplacements. Can you fix them all, please? >>> >> Sure, Will sort it and send as seperate patch. > > Thank you! > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-18 3:10 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-11-15 14:46 [PATCH linux-next] lib/string_choices: Add str_locked_unlocked()/str_unlocked_locked() helper R Sundar 2024-11-15 19:44 ` Andy Shevchenko 2024-11-15 19:46 ` Andy Shevchenko 2024-11-16 3:48 ` R Sundar 2024-11-17 20:03 ` Andy Shevchenko 2024-11-18 3:10 ` R Sundar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox