All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values
@ 2023-07-03 14:58 Andy Shevchenko
  2023-07-03 14:58 ` [PATCH v1 2/2] docs: printk-formats: Treat char as always unsigned Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andy Shevchenko @ 2023-07-03 14:58 UTC (permalink / raw)
  To: linux-doc, linux-kernel
  Cc: Petr Mladek, Steven Rostedt, Sergey Senozhatsky, Andy Shevchenko,
	Rasmus Villemoes, Jonathan Corbet

The commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of
unnecessary %h[xudi] and %hh[xudi]") obviously missed the point of sign
promotion for the signed values lesser than int. In such case %x prints
not the same as %h[h]x. Restore back those specifiers for the signed hex
cases.

Fixes: cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 Documentation/core-api/printk-formats.rst | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index dfe7e75a71de..2f3a6e0b3fc4 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -15,9 +15,9 @@ Integer types
 
 	If variable is of Type,		use printk format specifier:
 	------------------------------------------------------------
-		char			%d or %x
+		char			%d or %hhx
 		unsigned char		%u or %x
-		short int		%d or %x
+		short int		%d or %hx
 		unsigned short int	%u or %x
 		int			%d or %x
 		unsigned int		%u or %x
@@ -27,9 +27,9 @@ Integer types
 		unsigned long long	%llu or %llx
 		size_t			%zu or %zx
 		ssize_t			%zd or %zx
-		s8			%d or %x
+		s8			%d or %hhx
 		u8			%u or %x
-		s16			%d or %x
+		s16			%d or %hx
 		u16			%u or %x
 		s32			%d or %x
 		u32			%u or %x
-- 
2.40.0.1.gaa8946217a0b


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

* [PATCH v1 2/2] docs: printk-formats: Treat char as always unsigned
  2023-07-03 14:58 [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values Andy Shevchenko
@ 2023-07-03 14:58 ` Andy Shevchenko
  2023-07-14 15:34   ` Petr Mladek
  2023-07-03 15:08 ` [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values Andy Shevchenko
  2023-07-14 15:32 ` Petr Mladek
  2 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2023-07-03 14:58 UTC (permalink / raw)
  To: linux-doc, linux-kernel
  Cc: Petr Mladek, Steven Rostedt, Sergey Senozhatsky, Andy Shevchenko,
	Rasmus Villemoes, Jonathan Corbet

The Linux kernel switched to have char be equivalent to usigned char.
Reflect this in the printk specifiers.

Fixes: 3bc753c06dd0 ("kbuild: treat char as always unsigned")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 Documentation/core-api/printk-formats.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index 2f3a6e0b3fc4..4451ef501936 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -15,8 +15,9 @@ Integer types
 
 	If variable is of Type,		use printk format specifier:
 	------------------------------------------------------------
-		char			%d or %hhx
+		signed char		%d or %hhx
 		unsigned char		%u or %x
+		char			%u or %x
 		short int		%d or %hx
 		unsigned short int	%u or %x
 		int			%d or %x
-- 
2.40.0.1.gaa8946217a0b


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

* Re: [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values
  2023-07-03 14:58 [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values Andy Shevchenko
  2023-07-03 14:58 ` [PATCH v1 2/2] docs: printk-formats: Treat char as always unsigned Andy Shevchenko
@ 2023-07-03 15:08 ` Andy Shevchenko
  2023-07-14 15:32 ` Petr Mladek
  2 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2023-07-03 15:08 UTC (permalink / raw)
  To: linux-doc, linux-kernel
  Cc: Petr Mladek, Steven Rostedt, Sergey Senozhatsky,
	Rasmus Villemoes, Jonathan Corbet

On Mon, Jul 03, 2023 at 05:58:38PM +0300, Andy Shevchenko wrote:
> The commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of
> unnecessary %h[xudi] and %hh[xudi]") obviously missed the point of sign
> promotion for the signed values lesser than int. In such case %x prints
> not the same as %h[h]x. Restore back those specifiers for the signed hex
> cases.

FWIW, currently we luckily have only one ABI case
drivers/power/supply/bq24190_charger.c:466
which luckily uses unsigned value for that specifier.

The rest is debug and error messages along with tracepoints.
The tracepoints might have an undesired, but not critical,
deviation. Nevertheless, promoting sign for hex values seems
to me the wrong suggestion.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values
  2023-07-03 14:58 [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values Andy Shevchenko
  2023-07-03 14:58 ` [PATCH v1 2/2] docs: printk-formats: Treat char as always unsigned Andy Shevchenko
  2023-07-03 15:08 ` [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values Andy Shevchenko
@ 2023-07-14 15:32 ` Petr Mladek
  2 siblings, 0 replies; 7+ messages in thread
From: Petr Mladek @ 2023-07-14 15:32 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-doc, linux-kernel, Steven Rostedt, Sergey Senozhatsky,
	Rasmus Villemoes, Jonathan Corbet

On Mon 2023-07-03 17:58:38, Andy Shevchenko wrote:
> The commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of
> unnecessary %h[xudi] and %hh[xudi]") obviously missed the point of sign
> promotion for the signed values lesser than int. In such case %x prints
> not the same as %h[h]x. Restore back those specifiers for the signed hex
> cases.
> 
> Fixes: cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Makes sense. %d would print the same (small) negative number even when
casted do int. But %x would always add more "ff"s up to 4 bytes.

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

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

* Re: [PATCH v1 2/2] docs: printk-formats: Treat char as always unsigned
  2023-07-03 14:58 ` [PATCH v1 2/2] docs: printk-formats: Treat char as always unsigned Andy Shevchenko
@ 2023-07-14 15:34   ` Petr Mladek
  2023-07-14 16:04     ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Mladek @ 2023-07-14 15:34 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-doc, linux-kernel, Steven Rostedt, Sergey Senozhatsky,
	Rasmus Villemoes, Jonathan Corbet

On Mon 2023-07-03 17:58:39, Andy Shevchenko wrote:
> The Linux kernel switched to have char be equivalent to usigned char.
> Reflect this in the printk specifiers.
> 
> Fixes: 3bc753c06dd0 ("kbuild: treat char as always unsigned")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Makes sense.

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

PS: I am going to queue both patches for 6.6. They are not
    urgent to be added in the -rc phase.

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

* Re: [PATCH v1 2/2] docs: printk-formats: Treat char as always unsigned
  2023-07-14 15:34   ` Petr Mladek
@ 2023-07-14 16:04     ` Andy Shevchenko
  2023-07-18 11:46       ` Petr Mladek
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2023-07-14 16:04 UTC (permalink / raw)
  To: Petr Mladek
  Cc: linux-doc, linux-kernel, Steven Rostedt, Sergey Senozhatsky,
	Rasmus Villemoes, Jonathan Corbet

On Fri, Jul 14, 2023 at 05:34:35PM +0200, Petr Mladek wrote:
> On Mon 2023-07-03 17:58:39, Andy Shevchenko wrote:

...

> Reviewed-by: Petr Mladek <pmladek@suse.com>

Thank you for the review!

> PS: I am going to queue both patches for 6.6. They are not
>     urgent to be added in the -rc phase.

Sure, works for me.


-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 2/2] docs: printk-formats: Treat char as always unsigned
  2023-07-14 16:04     ` Andy Shevchenko
@ 2023-07-18 11:46       ` Petr Mladek
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Mladek @ 2023-07-18 11:46 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-doc, linux-kernel, Steven Rostedt, Sergey Senozhatsky,
	Rasmus Villemoes, Jonathan Corbet

On Fri 2023-07-14 19:04:43, Andy Shevchenko wrote:
> On Fri, Jul 14, 2023 at 05:34:35PM +0200, Petr Mladek wrote:
> > On Mon 2023-07-03 17:58:39, Andy Shevchenko wrote:
> 
> > PS: I am going to queue both patches for 6.6. They are not
> >     urgent to be added in the -rc phase.
> 
> Sure, works for me.

JFYI, both patches have been pushed into printk/linux.git,
branch for-6.6-vsprintf-doc.

Best Regards,
Petr

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

end of thread, other threads:[~2023-07-18 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03 14:58 [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values Andy Shevchenko
2023-07-03 14:58 ` [PATCH v1 2/2] docs: printk-formats: Treat char as always unsigned Andy Shevchenko
2023-07-14 15:34   ` Petr Mladek
2023-07-14 16:04     ` Andy Shevchenko
2023-07-18 11:46       ` Petr Mladek
2023-07-03 15:08 ` [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values Andy Shevchenko
2023-07-14 15:32 ` Petr Mladek

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.