public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hexdump: use const notation
@ 2007-08-07 18:33 Artem Bityutskiy
  2007-08-07 18:56 ` [PATCH + forgotten signed-off] " Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Artem Bityutskiy @ 2007-08-07 18:33 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

Trivial fix: mark the buffer to hexdump as const so callers could avoid
casting their const buffers when calling print_hex_dump().

The patch is really trivial and I suggest to consider it as a fix
(it fixes GCC warnings) and push it to current tree.


diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4300bb4..b4f5b81 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -224,7 +224,7 @@ extern void hex_dump_to_buffer(const void *buf, size_t len,
 				char *linebuf, size_t linebuflen, bool ascii);
 extern void print_hex_dump(const char *level, const char *prefix_str,
 				int prefix_type, int rowsize, int groupsize,
-				void *buf, size_t len, bool ascii);
+				const void *buf, size_t len, bool ascii);
 extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
 			void *buf, size_t len);
 #define hex_asc(x)	"0123456789abcdef"[x]
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 473f5ae..16f2e29 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -145,9 +145,9 @@ EXPORT_SYMBOL(hex_dump_to_buffer);
  */
 void print_hex_dump(const char *level, const char *prefix_str, int prefix_type,
 			int rowsize, int groupsize,
-			void *buf, size_t len, bool ascii)
+			const void *buf, size_t len, bool ascii)
 {
-	u8 *ptr = buf;
+	const u8 *ptr = buf;
 	int i, linelen, remaining = len;
 	unsigned char linebuf[200];
 


-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)


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

* [PATCH + forgotten signed-off] hexdump: use const notation
  2007-08-07 18:33 [PATCH] hexdump: use const notation Artem Bityutskiy
@ 2007-08-07 18:56 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2007-08-07 18:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: dedekind, linux-kernel

From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Date: Tue, 7 Aug 2007 23:43:14 +0300
Subject: [PATCH] hexdump: use const notation

Trivial fix: mark the buffer to hexdump as const so callers could avoid
casting their const buffers when calling print_hex_dump().

The patch is really trivial and I suggest to consider it as a fix
(it fixes GCC warnings) and push it to current tree.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 include/linux/kernel.h |    2 +-
 lib/hexdump.c          |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4300bb4..b4f5b81 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -224,7 +224,7 @@ extern void hex_dump_to_buffer(const void *buf, size_t len,
 				char *linebuf, size_t linebuflen, bool ascii);
 extern void print_hex_dump(const char *level, const char *prefix_str,
 				int prefix_type, int rowsize, int groupsize,
-				void *buf, size_t len, bool ascii);
+				const void *buf, size_t len, bool ascii);
 extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
 			void *buf, size_t len);
 #define hex_asc(x)	"0123456789abcdef"[x]
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 473f5ae..16f2e29 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -145,9 +145,9 @@ EXPORT_SYMBOL(hex_dump_to_buffer);
  */
 void print_hex_dump(const char *level, const char *prefix_str, int prefix_type,
 			int rowsize, int groupsize,
-			void *buf, size_t len, bool ascii)
+			const void *buf, size_t len, bool ascii)
 {
-	u8 *ptr = buf;
+	const u8 *ptr = buf;
 	int i, linelen, remaining = len;
 	unsigned char linebuf[200];
 
-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

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

end of thread, other threads:[~2007-08-07 18:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-07 18:33 [PATCH] hexdump: use const notation Artem Bityutskiy
2007-08-07 18:56 ` [PATCH + forgotten signed-off] " Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox