linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] lib/vsprintf: define special_hex_number_unsigned_long()
@ 2016-01-14 12:34 Andy Shevchenko
  2016-01-27  4:44 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2016-01-14 12:34 UTC (permalink / raw)
  To: Rasmus Villemoes, Andrew Morton, linux-kernel; +Cc: Andy Shevchenko

Define a macro for convenient use with values of unsigned long type.

The value in symbol_string() is type of unsigned long. Use it instead of void *
when getting sizeof() of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 lib/vsprintf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 3c8e563..0af7cf1 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -529,6 +529,9 @@ char *special_hex_number(char *buf, char *end, unsigned long long num, int size)
 	return number(buf, end, num, spec);
 }
 
+#define special_hex_number_unsigned_long(buf, end, n) \
+	special_hex_number(buf, end, (unsigned long)n, sizeof(unsigned long))
+
 static void move_right(char *buf, char *end, unsigned len, unsigned spaces)
 {
 	size_t size;
@@ -684,7 +687,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
 
 	return string(buf, end, sym, spec);
 #else
-	return special_hex_number(buf, end, value, sizeof(void *));
+	return special_hex_number_unsigned_long(buf, end, value);
 #endif
 }
 
@@ -1446,7 +1449,7 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
 #ifdef CONFIG_COMMON_CLK
 		return string(buf, end, __clk_get_name(clk), spec);
 #else
-		return special_hex_number(buf, end, (unsigned long)clk, sizeof(unsigned long));
+		return special_hex_number_unsigned_long(buf, end, clk);
 #endif
 	}
 }
-- 
2.6.4

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

* Re: [PATCH v1 1/1] lib/vsprintf: define special_hex_number_unsigned_long()
  2016-01-14 12:34 [PATCH v1 1/1] lib/vsprintf: define special_hex_number_unsigned_long() Andy Shevchenko
@ 2016-01-27  4:44 ` Andrew Morton
  2016-01-27 12:19   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2016-01-27  4:44 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Rasmus Villemoes, linux-kernel

On Thu, 14 Jan 2016 14:34:49 +0200 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Define a macro for convenient use with values of unsigned long type.
> 
> The value in symbol_string() is type of unsigned long. Use it instead of void *
> when getting sizeof() of it.
> 
> ...
>
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -529,6 +529,9 @@ char *special_hex_number(char *buf, char *end, unsigned long long num, int size)
>  	return number(buf, end, num, spec);
>  }
>  
> +#define special_hex_number_unsigned_long(buf, end, n) \
> +	special_hex_number(buf, end, (unsigned long)n, sizeof(unsigned long))
> +
>  static void move_right(char *buf, char *end, unsigned len, unsigned spaces)
>  {
>  	size_t size;
> @@ -684,7 +687,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
>  
>  	return string(buf, end, sym, spec);
>  #else
> -	return special_hex_number(buf, end, value, sizeof(void *));
> +	return special_hex_number_unsigned_long(buf, end, value);
>  #endif
>  }
>  
> @@ -1446,7 +1449,7 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
>  #ifdef CONFIG_COMMON_CLK
>  		return string(buf, end, __clk_get_name(clk), spec);
>  #else
> -		return special_hex_number(buf, end, (unsigned long)clk, sizeof(unsigned long));
> +		return special_hex_number_unsigned_long(buf, end, clk);
>  #endif
>  	}
>  }

I'm not sure this is worth the effort.

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

* Re: [PATCH v1 1/1] lib/vsprintf: define special_hex_number_unsigned_long()
  2016-01-27  4:44 ` Andrew Morton
@ 2016-01-27 12:19   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2016-01-27 12:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Rasmus Villemoes, linux-kernel

On Tue, 2016-01-26 at 20:44 -0800, Andrew Morton wrote:
> On Thu, 14 Jan 2016 14:34:49 +0200 Andy Shevchenko <andriy.shevchenko
> @linux.intel.com> wrote:
> 
> > Define a macro for convenient use with values of unsigned long
> > type.
> > 
> > The value in symbol_string() is type of unsigned long. Use it
> > instead of void *
> > when getting sizeof() of it.
> > 
> > ...
> > 
> > --- a/lib/vsprintf.c
> > +++ b/lib/vsprintf.c
> > @@ -529,6 +529,9 @@ char *special_hex_number(char *buf, char *end,
> > unsigned long long num, int size)
> >  	return number(buf, end, num, spec);
> >  }
> >  
> > +#define special_hex_number_unsigned_long(buf, end, n) \
> > +	special_hex_number(buf, end, (unsigned long)n,
> > sizeof(unsigned long))
> > +
> >  static void move_right(char *buf, char *end, unsigned len,
> > unsigned spaces)
> >  {
> >  	size_t size;
> > @@ -684,7 +687,7 @@ char *symbol_string(char *buf, char *end, void
> > *ptr,
> >  
> >  	return string(buf, end, sym, spec);
> >  #else
> > -	return special_hex_number(buf, end, value, sizeof(void
> > *));
> > +	return special_hex_number_unsigned_long(buf, end, value);
> >  #endif
> >  }
> >  
> > @@ -1446,7 +1449,7 @@ char *clock(char *buf, char *end, struct clk
> > *clk, struct printf_spec spec,
> >  #ifdef CONFIG_COMMON_CLK
> >  		return string(buf, end, __clk_get_name(clk),
> > spec);
> >  #else
> > -		return special_hex_number(buf, end, (unsigned
> > long)clk, sizeof(unsigned long));
> > +		return special_hex_number_unsigned_long(buf, end,
> > clk);
> >  #endif
> >  	}
> >  }
> 
> I'm not sure this is worth the effort.

Drop it then! I'm fine with any decision.


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

end of thread, other threads:[~2016-01-27 12:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14 12:34 [PATCH v1 1/1] lib/vsprintf: define special_hex_number_unsigned_long() Andy Shevchenko
2016-01-27  4:44 ` Andrew Morton
2016-01-27 12:19   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).