[PATCH 10/10] filetype: Make buf in file_detect_type const

Sascha Hauer s.hauer at pengutronix.de
Sun Jan 20 10:35:19 EST 2013


This function has no business changing the buffer.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/filetype.c  |   10 +++++-----
 include/filetype.h |    2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/common/filetype.c b/common/filetype.c
index 748e364..5941ad2 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -106,12 +106,12 @@ enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec)
 	return filetype_mbr;
 }
 
-enum filetype file_detect_type(void *_buf, size_t bufsize)
+enum filetype file_detect_type(const void *_buf, size_t bufsize)
 {
-	u32 *buf = _buf;
-	u64 *buf64 = _buf;
-	u8 *buf8 = _buf;
-	u16 *buf16 = _buf;
+	const u32 *buf = _buf;
+	const u64 *buf64 = _buf;
+	const u8 *buf8 = _buf;
+	const u16 *buf16 = _buf;
 	enum filetype type;
 
 	if (bufsize < 9)
diff --git a/include/filetype.h b/include/filetype.h
index 91139db..502b920 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -30,7 +30,7 @@ enum filetype {
 
 const char *file_type_to_string(enum filetype f);
 const char *file_type_to_short_string(enum filetype f);
-enum filetype file_detect_type(void *_buf, size_t bufsize);
+enum filetype file_detect_type(const void *_buf, size_t bufsize);
 enum filetype file_name_detect_type(const char *filename);
 enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec);
 
-- 
1.7.10.4




More information about the barebox mailing list