Skip to contentSkip to conversation

lib/vsprintf: define special_hex_number_unsigned_long()

PATCH In review Andy Shevchenko 2 participants 3 messages Jan 14, 2016 – Jan 27, 2016

Subsystems (2)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH 1/1 lib/vsprintf: define special_hex_number_unsigned_long()

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.

---
 lib/vsprintf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/vsprintf.c +5 -2
index 3c8e563..0af7cf1 100644
@@ -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
 	}
 }
Signature · 1 line
2.6.4
maintainer
#1 lore raw
Quoted 29 lines · On Thu, 14 Jan 2016 14:34:49 +0200 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.

...

lib/vsprintf.c +4 -1
@@ -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
 }
 

lib/vsprintf.c char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, · line 1455

Quoted 8 lines
lib/vsprintf.c +1 -1
@@ -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.

author reviewer
#2 lore raw
Quoted 45 lines · Andrew Morton
Quoted 42 lines · On Thu, 14 Jan 2016 14:34:49 +0200 Andy Shevchenko <andriy.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.

...

lib/vsprintf.c +0 -0
@@ -529,6 +529,9 @@ char *special_hex_number(char *buf, char *end,
 unsigned long long num, int size)
  	return number(buf, end, num, spec);
  }

lib/vsprintf.c +2 -0
+#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;

lib/vsprintf.c +0 -0
@@ -684,7 +687,7 @@ char *symbol_string(char *buf, char *end, void
 *ptr,


  return string(buf, end, sym, spec);
 #else

lib/vsprintf.c +0 -1
-	return special_hex_number(buf, end, value, sizeof(void

*));

lib/vsprintf.c +1 -0
+	return special_hex_number_unsigned_long(buf, end, value);

 #endif
 }

lib/vsprintf.c +0 -1
@@ -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
Quoted 8 lines
Quoted 6 lines
lib/vsprintf.c +1 -0
 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.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy