a5bd9f6
From 75bd81540fab6830213d51e024b53d51f3fe6dcb Mon Sep 17 00:00:00 2001
a5bd9f6
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
a5bd9f6
Date: Fri, 11 Jan 2013 07:41:05 +0100
a5bd9f6
Subject: [PATCH 093/364] 	* grub-core/fs/ntfs.c: Ue more appropriate
a5bd9f6
 types. 	* grub-core/fs/ntfscomp.c: Likewise. 	* include/grub/ntfs.h:
a5bd9f6
 Likewise.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog               |   6 +++
a5bd9f6
 grub-core/fs/ntfs.c     | 140 +++++++++++++++++++++++++-----------------------
a5bd9f6
 grub-core/fs/ntfscomp.c |  16 +++---
a5bd9f6
 include/grub/ntfs.h     |  20 +++----
a5bd9f6
 4 files changed, 96 insertions(+), 86 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index 4567cae..41dbadd 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,5 +1,11 @@
a5bd9f6
 2013-01-10  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
 
a5bd9f6
+	* grub-core/fs/ntfs.c: Ue more appropriate types.
a5bd9f6
+	* grub-core/fs/ntfscomp.c: Likewise.
a5bd9f6
+	* include/grub/ntfs.h: Likewise.
a5bd9f6
+
a5bd9f6
+2013-01-10  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
+
a5bd9f6
 	Support Apple FAT binaries on non-Apple platforms.
a5bd9f6
 
a5bd9f6
 	* include/grub/macho.h (GRUB_MACHO_FAT_EFI_MAGIC): New define.
a5bd9f6
diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c
a5bd9f6
index 6004e1f..e7861d8 100644
a5bd9f6
--- a/grub-core/fs/ntfs.c
a5bd9f6
+++ b/grub-core/fs/ntfs.c
a5bd9f6
@@ -55,10 +55,10 @@ u64at (void *ptr, grub_size_t ofs)
a5bd9f6
 grub_ntfscomp_func_t grub_ntfscomp_func;
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
-fixup (char *buf, int len, const char *magic)
a5bd9f6
+fixup (grub_uint8_t *buf, grub_size_t len, const grub_uint8_t *magic)
a5bd9f6
 {
a5bd9f6
-  int ss;
a5bd9f6
-  char *pu;
a5bd9f6
+  grub_uint16_t ss;
a5bd9f6
+  grub_uint8_t *pu;
a5bd9f6
   grub_uint16_t us;
a5bd9f6
 
a5bd9f6
   COMPILE_TIME_ASSERT ((1 << GRUB_NTFS_BLK_SHR) == GRUB_DISK_SECTOR_SIZE);
a5bd9f6
@@ -86,9 +86,9 @@ fixup (char *buf, int len, const char *magic)
a5bd9f6
   return 0;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
-static grub_err_t read_mft (struct grub_ntfs_data *data, char *buf,
a5bd9f6
+static grub_err_t read_mft (struct grub_ntfs_data *data, grub_uint8_t *buf,
a5bd9f6
 			    grub_uint32_t mftno);
a5bd9f6
-static grub_err_t read_attr (struct grub_ntfs_attr *at, char *dest,
a5bd9f6
+static grub_err_t read_attr (struct grub_ntfs_attr *at, grub_uint8_t *dest,
a5bd9f6
 			     grub_disk_addr_t ofs, grub_size_t len,
a5bd9f6
 			     int cached,
a5bd9f6
 			     void
a5bd9f6
@@ -97,7 +97,8 @@ static grub_err_t read_attr (struct grub_ntfs_attr *at, char *dest,
a5bd9f6
 							    unsigned offset,
a5bd9f6
 							    unsigned length));
a5bd9f6
 
a5bd9f6
-static grub_err_t read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
a5bd9f6
+static grub_err_t read_data (struct grub_ntfs_attr *at, grub_uint8_t *pa,
a5bd9f6
+			     grub_uint8_t *dest,
a5bd9f6
 			     grub_disk_addr_t ofs, grub_size_t len,
a5bd9f6
 			     int cached,
a5bd9f6
 			     void
a5bd9f6
@@ -123,8 +124,8 @@ free_attr (struct grub_ntfs_attr *at)
a5bd9f6
   grub_free (at->sbuf);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
-static char *
a5bd9f6
-find_attr (struct grub_ntfs_attr *at, unsigned char attr)
a5bd9f6
+static grub_uint8_t *
a5bd9f6
+find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr)
a5bd9f6
 {
a5bd9f6
   if (at->flags & GRUB_NTFS_AF_ALST)
a5bd9f6
     {
a5bd9f6
@@ -133,9 +134,9 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
a5bd9f6
 	{
a5bd9f6
 	  at->attr_cur = at->attr_nxt;
a5bd9f6
 	  at->attr_nxt += u16at (at->attr_cur, 4);
a5bd9f6
-	  if (((unsigned char) *at->attr_cur == attr) || (attr == 0))
a5bd9f6
+	  if ((*at->attr_cur == attr) || (attr == 0))
a5bd9f6
 	    {
a5bd9f6
-	      char *new_pos;
a5bd9f6
+	      grub_uint8_t *new_pos;
a5bd9f6
 
a5bd9f6
 	      if (at->flags & GRUB_NTFS_AF_MMFT)
a5bd9f6
 		{
a5bd9f6
@@ -148,7 +149,8 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
a5bd9f6
 			512, at->emft_buf + 512)))
a5bd9f6
 		    return NULL;
a5bd9f6
 
a5bd9f6
-		  if (fixup (at->emft_buf, at->mft->data->mft_size, "FILE"))
a5bd9f6
+		  if (fixup (at->emft_buf, at->mft->data->mft_size,
a5bd9f6
+			     (const grub_uint8_t *) "FILE"))
a5bd9f6
 		    return NULL;
a5bd9f6
 		}
a5bd9f6
 	      else
a5bd9f6
@@ -159,10 +161,9 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
a5bd9f6
 		}
a5bd9f6
 
a5bd9f6
 	      new_pos = &at->emft_buf[u16at (at->emft_buf, 0x14)];
a5bd9f6
-	      while ((unsigned char) *new_pos != 0xFF)
a5bd9f6
+	      while (*new_pos != 0xFF)
a5bd9f6
 		{
a5bd9f6
-		  if (((unsigned char) *new_pos ==
a5bd9f6
-		       (unsigned char) *at->attr_cur)
a5bd9f6
+		  if ((*new_pos == *at->attr_cur)
a5bd9f6
 		      && (u16at (new_pos, 0xE) == u16at (at->attr_cur, 0x18)))
a5bd9f6
 		    {
a5bd9f6
 		      return new_pos;
a5bd9f6
@@ -178,18 +179,18 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
a5bd9f6
       return NULL;
a5bd9f6
     }
a5bd9f6
   at->attr_cur = at->attr_nxt;
a5bd9f6
-  while ((unsigned char) *at->attr_cur != 0xFF)
a5bd9f6
+  while (*at->attr_cur != 0xFF)
a5bd9f6
     {
a5bd9f6
       at->attr_nxt += u16at (at->attr_cur, 4);
a5bd9f6
-      if ((unsigned char) *at->attr_cur == GRUB_NTFS_AT_ATTRIBUTE_LIST)
a5bd9f6
+      if (*at->attr_cur == GRUB_NTFS_AT_ATTRIBUTE_LIST)
a5bd9f6
 	at->attr_end = at->attr_cur;
a5bd9f6
-      if (((unsigned char) *at->attr_cur == attr) || (attr == 0))
a5bd9f6
+      if ((*at->attr_cur == attr) || (attr == 0))
a5bd9f6
 	return at->attr_cur;
a5bd9f6
       at->attr_cur = at->attr_nxt;
a5bd9f6
     }
a5bd9f6
   if (at->attr_end)
a5bd9f6
     {
a5bd9f6
-      char *pa;
a5bd9f6
+      grub_uint8_t *pa;
a5bd9f6
 
a5bd9f6
       at->emft_buf = grub_malloc (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR);
a5bd9f6
       if (at->emft_buf == NULL)
a5bd9f6
@@ -198,7 +199,7 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
a5bd9f6
       pa = at->attr_end;
a5bd9f6
       if (pa[8])
a5bd9f6
 	{
a5bd9f6
-          int n;
a5bd9f6
+          grub_uint32_t n;
a5bd9f6
 
a5bd9f6
           n = ((u32at (pa, 0x30) + GRUB_DISK_SECTOR_SIZE - 1)
a5bd9f6
                & (~(GRUB_DISK_SECTOR_SIZE - 1)));
a5bd9f6
@@ -223,7 +224,7 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
a5bd9f6
       at->flags |= GRUB_NTFS_AF_ALST;
a5bd9f6
       while (at->attr_nxt < at->attr_end)
a5bd9f6
 	{
a5bd9f6
-	  if (((unsigned char) *at->attr_nxt == attr) || (attr == 0))
a5bd9f6
+	  if ((*at->attr_nxt == attr) || (attr == 0))
a5bd9f6
 	    break;
a5bd9f6
 	  at->attr_nxt += u16at (at->attr_nxt, 4);
a5bd9f6
 	}
a5bd9f6
@@ -243,7 +244,7 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
a5bd9f6
 	  pa = at->attr_nxt + u16at (pa, 4);
a5bd9f6
 	  while (pa < at->attr_end)
a5bd9f6
 	    {
a5bd9f6
-	      if ((unsigned char) *pa != attr)
a5bd9f6
+	      if (*pa != attr)
a5bd9f6
 		break;
a5bd9f6
 	      if (read_attr
a5bd9f6
 		  (at, pa + 0x10,
a5bd9f6
@@ -260,11 +261,11 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
a5bd9f6
   return NULL;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
-static char *
a5bd9f6
+static grub_uint8_t *
a5bd9f6
 locate_attr (struct grub_ntfs_attr *at, struct grub_ntfs_file *mft,
a5bd9f6
-	     unsigned char attr)
a5bd9f6
+	     grub_uint8_t attr)
a5bd9f6
 {
a5bd9f6
-  char *pa;
a5bd9f6
+  grub_uint8_t *pa;
a5bd9f6
 
a5bd9f6
   init_attr (at, mft);
a5bd9f6
   pa = find_attr (at, attr);
a5bd9f6
@@ -288,8 +289,8 @@ locate_attr (struct grub_ntfs_attr *at, struct grub_ntfs_file *mft,
a5bd9f6
   return pa;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
-static char *
a5bd9f6
-read_run_data (char *run, int nn, grub_disk_addr_t * val, int sig)
a5bd9f6
+static grub_uint8_t *
a5bd9f6
+read_run_data (grub_uint8_t *run, int nn, grub_disk_addr_t * val, int sig)
a5bd9f6
 {
a5bd9f6
   grub_disk_addr_t r, v;
a5bd9f6
 
a5bd9f6
@@ -298,7 +299,7 @@ read_run_data (char *run, int nn, grub_disk_addr_t * val, int sig)
a5bd9f6
 
a5bd9f6
   while (nn--)
a5bd9f6
     {
a5bd9f6
-      r += v * (*(unsigned char *) (run++));
a5bd9f6
+      r += v * (*(run++));
a5bd9f6
       v <<= 8;
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
@@ -312,14 +313,14 @@ read_run_data (char *run, int nn, grub_disk_addr_t * val, int sig)
a5bd9f6
 grub_err_t
a5bd9f6
 grub_ntfs_read_run_list (struct grub_ntfs_rlst * ctx)
a5bd9f6
 {
a5bd9f6
-  int c1, c2;
a5bd9f6
+  grub_uint8_t c1, c2;
a5bd9f6
   grub_disk_addr_t val;
a5bd9f6
-  char *run;
a5bd9f6
+  grub_uint8_t *run;
a5bd9f6
 
a5bd9f6
   run = ctx->cur_run;
a5bd9f6
 retry:
a5bd9f6
-  c1 = ((unsigned char) (*run) & 0xF);
a5bd9f6
-  c2 = ((unsigned char) (*run) >> 4);
a5bd9f6
+  c1 = ((*run) & 0xF);
a5bd9f6
+  c2 = ((*run) >> 4);
a5bd9f6
   if (!c1)
a5bd9f6
     {
a5bd9f6
       if ((ctx->attr) && (ctx->attr->flags & GRUB_NTFS_AF_ALST))
a5bd9f6
@@ -330,7 +331,7 @@ retry:
a5bd9f6
 
a5bd9f6
 	  save_hook = ctx->comp.disk->read_hook;
a5bd9f6
 	  ctx->comp.disk->read_hook = 0;
a5bd9f6
-	  run = find_attr (ctx->attr, (unsigned char) *ctx->attr->attr_cur);
a5bd9f6
+	  run = find_attr (ctx->attr, *ctx->attr->attr_cur);
a5bd9f6
 	  ctx->comp.disk->read_hook = save_hook;
a5bd9f6
 	  if (run)
a5bd9f6
 	    {
a5bd9f6
@@ -376,7 +377,7 @@ grub_ntfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t block)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
-read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
a5bd9f6
+read_data (struct grub_ntfs_attr *at, grub_uint8_t *pa, grub_uint8_t *dest,
a5bd9f6
 	   grub_disk_addr_t ofs, grub_size_t len, int cached,
a5bd9f6
 	   void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
a5bd9f6
 					       unsigned offset,
a5bd9f6
@@ -479,7 +480,7 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
a5bd9f6
   if (!(ctx->flags & GRUB_NTFS_RF_COMP))
a5bd9f6
     {
a5bd9f6
       grub_fshelp_read_file (ctx->comp.disk, (grub_fshelp_node_t) ctx,
a5bd9f6
-			     read_hook, ofs, len, dest,
a5bd9f6
+			     read_hook, ofs, len, (char *) dest,
a5bd9f6
 			     grub_ntfs_read_block, ofs + len,
a5bd9f6
 			     ctx->comp.log_spc, 0);
a5bd9f6
       return grub_errno;
a5bd9f6
@@ -492,23 +493,23 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
-read_attr (struct grub_ntfs_attr *at, char *dest, grub_disk_addr_t ofs,
a5bd9f6
+read_attr (struct grub_ntfs_attr *at, grub_uint8_t *dest, grub_disk_addr_t ofs,
a5bd9f6
 	   grub_size_t len, int cached,
a5bd9f6
 	   void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
a5bd9f6
 					       unsigned offset,
a5bd9f6
 					       unsigned length))
a5bd9f6
 {
a5bd9f6
-  char *save_cur;
a5bd9f6
-  unsigned char attr;
a5bd9f6
-  char *pp;
a5bd9f6
+  grub_uint8_t *save_cur;
a5bd9f6
+  grub_uint8_t attr;
a5bd9f6
+  grub_uint8_t *pp;
a5bd9f6
   grub_err_t ret;
a5bd9f6
 
a5bd9f6
   save_cur = at->attr_cur;
a5bd9f6
   at->attr_nxt = at->attr_cur;
a5bd9f6
-  attr = (unsigned char) *at->attr_nxt;
a5bd9f6
+  attr = *at->attr_nxt;
a5bd9f6
   if (at->flags & GRUB_NTFS_AF_ALST)
a5bd9f6
     {
a5bd9f6
-      char *pa;
a5bd9f6
+      grub_uint8_t *pa;
a5bd9f6
       grub_disk_addr_t vcn;
a5bd9f6
 
a5bd9f6
       /* If compression is possible make sure that we include possible
a5bd9f6
@@ -521,7 +522,7 @@ read_attr (struct grub_ntfs_attr *at, char *dest, grub_disk_addr_t ofs,
a5bd9f6
       pa = at->attr_nxt + u16at (at->attr_nxt, 4);
a5bd9f6
       while (pa < at->attr_end)
a5bd9f6
 	{
a5bd9f6
-	  if ((unsigned char) *pa != attr)
a5bd9f6
+	  if (*pa != attr)
a5bd9f6
 	    break;
a5bd9f6
 	  if (u32at (pa, 8) > vcn)
a5bd9f6
 	    break;
a5bd9f6
@@ -541,13 +542,13 @@ read_attr (struct grub_ntfs_attr *at, char *dest, grub_disk_addr_t ofs,
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
-read_mft (struct grub_ntfs_data *data, char *buf, grub_uint32_t mftno)
a5bd9f6
+read_mft (struct grub_ntfs_data *data, grub_uint8_t *buf, grub_uint32_t mftno)
a5bd9f6
 {
a5bd9f6
   if (read_attr
a5bd9f6
       (&data->mmft.attr, buf, mftno * ((grub_disk_addr_t) data->mft_size << GRUB_NTFS_BLK_SHR),
a5bd9f6
        data->mft_size << GRUB_NTFS_BLK_SHR, 0, 0))
a5bd9f6
     return grub_error (GRUB_ERR_BAD_FS, "read MFT 0x%X fails", mftno);
a5bd9f6
-  return fixup (buf, data->mft_size, "FILE");
a5bd9f6
+  return fixup (buf, data->mft_size, (const grub_uint8_t *) "FILE");
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
@@ -570,7 +571,7 @@ init_file (struct grub_ntfs_file *mft, grub_uint32_t mftno)
a5bd9f6
 
a5bd9f6
   if ((flag & 2) == 0)
a5bd9f6
     {
a5bd9f6
-      char *pa;
a5bd9f6
+      grub_uint8_t *pa;
a5bd9f6
 
a5bd9f6
       pa = locate_attr (&mft->attr, mft, GRUB_NTFS_AT_DATA);
a5bd9f6
       if (pa == NULL)
a5bd9f6
@@ -598,24 +599,25 @@ free_file (struct grub_ntfs_file *mft)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static int
a5bd9f6
-list_file (struct grub_ntfs_file *diro, char *pos,
a5bd9f6
+list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos,
a5bd9f6
 	   int NESTED_FUNC_ATTR
a5bd9f6
 	   (*hook) (const char *filename,
a5bd9f6
 		    enum grub_fshelp_filetype filetype,
a5bd9f6
 		    grub_fshelp_node_t node))
a5bd9f6
 {
a5bd9f6
-  char *np;
a5bd9f6
+  grub_uint8_t *np;
a5bd9f6
   int ns;
a5bd9f6
 
a5bd9f6
   while (1)
a5bd9f6
     {
a5bd9f6
-      char *ustr, namespace;
a5bd9f6
+      grub_uint8_t namespace;
a5bd9f6
+      char *ustr;
a5bd9f6
 
a5bd9f6
       if (pos[0xC] & 2)		/* end signature */
a5bd9f6
 	break;
a5bd9f6
 
a5bd9f6
       np = pos + 0x50;
a5bd9f6
-      ns = (unsigned char) *(np++);
a5bd9f6
+      ns = *(np++);
a5bd9f6
       namespace = *(np++);
a5bd9f6
 
a5bd9f6
       /*
a5bd9f6
@@ -698,7 +700,7 @@ grub_ntfs_read_symlink (grub_fshelp_node_t node)
a5bd9f6
   char *buf, *end;
a5bd9f6
   grub_size_t len;
a5bd9f6
   grub_size_t i;
a5bd9f6
-  char *pa;
a5bd9f6
+  grub_uint8_t *pa;
a5bd9f6
   grub_size_t off;
a5bd9f6
 
a5bd9f6
   mft = (struct grub_ntfs_file *) node;
a5bd9f6
@@ -717,7 +719,7 @@ grub_ntfs_read_symlink (grub_fshelp_node_t node)
a5bd9f6
       return NULL;
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
-  err = read_attr (&mft->attr, (char *) &symdesc, 0,
a5bd9f6
+  err = read_attr (&mft->attr, (grub_uint8_t *) &symdesc, 0,
a5bd9f6
 		   sizeof (struct symlink_descriptor), 1, 0);
a5bd9f6
   if (err)
a5bd9f6
     return NULL;
a5bd9f6
@@ -744,7 +746,7 @@ grub_ntfs_read_symlink (grub_fshelp_node_t node)
a5bd9f6
   if (!buf16)
a5bd9f6
     return NULL;
a5bd9f6
 
a5bd9f6
-  err = read_attr (&mft->attr, (char *) buf16, off, len, 1, 0);
a5bd9f6
+  err = read_attr (&mft->attr, (grub_uint8_t *) buf16, off, len, 1, 0);
a5bd9f6
   if (err)
a5bd9f6
     return NULL;
a5bd9f6
 
a5bd9f6
@@ -781,9 +783,9 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
a5bd9f6
 				enum grub_fshelp_filetype filetype,
a5bd9f6
 				grub_fshelp_node_t node))
a5bd9f6
 {
a5bd9f6
-  unsigned char *bitmap;
a5bd9f6
+  grub_uint8_t *bitmap;
a5bd9f6
   struct grub_ntfs_attr attr, *at;
a5bd9f6
-  char *cur_pos, *indx, *bmp;
a5bd9f6
+  grub_uint8_t *cur_pos, *indx, *bmp;
a5bd9f6
   int ret = 0;
a5bd9f6
   grub_size_t bitmap_len;
a5bd9f6
   struct grub_ntfs_file *mft;
a5bd9f6
@@ -834,7 +836,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
a5bd9f6
     {
a5bd9f6
       int ofs;
a5bd9f6
 
a5bd9f6
-      ofs = (unsigned char) cur_pos[0xA];
a5bd9f6
+      ofs = cur_pos[0xA];
a5bd9f6
       /* Namelen=4, Name="$I30" */
a5bd9f6
       if ((cur_pos[9] == 4) &&
a5bd9f6
 	  (u32at (cur_pos, ofs) == 0x490024) &&
a5bd9f6
@@ -851,7 +853,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
a5bd9f6
 
a5bd9f6
 	  if (is_resident)
a5bd9f6
 	    {
a5bd9f6
-              grub_memcpy (bmp, (char *) (cur_pos + u16at (cur_pos, 0x14)),
a5bd9f6
+              grub_memcpy (bmp, cur_pos + u16at (cur_pos, 0x14),
a5bd9f6
                            bitmap_len);
a5bd9f6
 	    }
a5bd9f6
           else
a5bd9f6
@@ -865,7 +867,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
a5bd9f6
               bitmap_len = u32at (cur_pos, 0x30);
a5bd9f6
             }
a5bd9f6
 
a5bd9f6
-          bitmap = (unsigned char *) bmp;
a5bd9f6
+          bitmap = bmp;
a5bd9f6
 	  break;
a5bd9f6
 	}
a5bd9f6
     }
a5bd9f6
@@ -904,7 +906,8 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
a5bd9f6
 	      if ((read_attr
a5bd9f6
 		   (at, indx, i * (mft->data->idx_size << GRUB_NTFS_BLK_SHR),
a5bd9f6
 		    (mft->data->idx_size << GRUB_NTFS_BLK_SHR), 0, 0))
a5bd9f6
-		  || (fixup (indx, mft->data->idx_size, "INDX")))
a5bd9f6
+		  || (fixup (indx, mft->data->idx_size,
a5bd9f6
+			     (const grub_uint8_t *) "INDX")))
a5bd9f6
 		goto done;
a5bd9f6
 	      ret = list_file (mft, &indx[0x18 + u16at (indx, 0x18)], hook);
a5bd9f6
 	      if (ret)
a5bd9f6
@@ -963,14 +966,15 @@ grub_ntfs_mount (grub_disk_t disk)
a5bd9f6
   for (data->log_spc = 0; (1U << data->log_spc) < spc; data->log_spc++);
a5bd9f6
 
a5bd9f6
   if (bpb.clusters_per_mft > 0)
a5bd9f6
-    data->mft_size = bpb.clusters_per_mft << data->log_spc;
a5bd9f6
+    data->mft_size = ((grub_disk_addr_t) bpb.clusters_per_mft) << data->log_spc;
a5bd9f6
   else
a5bd9f6
-    data->mft_size = 1 << (-bpb.clusters_per_mft - GRUB_NTFS_BLK_SHR);
a5bd9f6
+    data->mft_size = 1ULL << (-bpb.clusters_per_mft - GRUB_NTFS_BLK_SHR);
a5bd9f6
 
a5bd9f6
   if (bpb.clusters_per_index > 0)
a5bd9f6
-    data->idx_size = bpb.clusters_per_index << data->log_spc;
a5bd9f6
+    data->idx_size = (((grub_disk_addr_t) bpb.clusters_per_index)
a5bd9f6
+		      << data->log_spc);
a5bd9f6
   else
a5bd9f6
-    data->idx_size = 1 << (-bpb.clusters_per_index - GRUB_NTFS_BLK_SHR);
a5bd9f6
+    data->idx_size = 1ULL << (-bpb.clusters_per_index - GRUB_NTFS_BLK_SHR);
a5bd9f6
 
a5bd9f6
   data->mft_start = grub_le_to_cpu64 (bpb.mft_lcn) << data->log_spc;
a5bd9f6
 
a5bd9f6
@@ -990,7 +994,7 @@ grub_ntfs_mount (grub_disk_t disk)
a5bd9f6
 
a5bd9f6
   data->uuid = grub_le_to_cpu64 (bpb.num_serial);
a5bd9f6
 
a5bd9f6
-  if (fixup (data->mmft.buf, data->mft_size, "FILE"))
a5bd9f6
+  if (fixup (data->mmft.buf, data->mft_size, (const grub_uint8_t *) "FILE"))
a5bd9f6
     goto fail;
a5bd9f6
 
a5bd9f6
   if (!locate_attr (&data->mmft.attr, &data->mmft, GRUB_NTFS_AT_DATA))
a5bd9f6
@@ -1130,7 +1134,8 @@ grub_ntfs_read (grub_file_t file, char *buf, grub_size_t len)
a5bd9f6
   if (file->read_hook)
a5bd9f6
     mft->attr.save_pos = 1;
a5bd9f6
 
a5bd9f6
-  read_attr (&mft->attr, buf, file->offset, len, 1, file->read_hook);
a5bd9f6
+  read_attr (&mft->attr, (grub_uint8_t *) buf, file->offset, len, 1,
a5bd9f6
+	     file->read_hook);
a5bd9f6
   return (grub_errno) ? -1 : (grub_ssize_t) len;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
@@ -1158,7 +1163,7 @@ grub_ntfs_label (grub_device_t device, char **label)
a5bd9f6
 {
a5bd9f6
   struct grub_ntfs_data *data = 0;
a5bd9f6
   struct grub_fshelp_node *mft = 0;
a5bd9f6
-  char *pa;
a5bd9f6
+  grub_uint8_t *pa;
a5bd9f6
 
a5bd9f6
   grub_dl_ref (my_mod);
a5bd9f6
 
a5bd9f6
@@ -1188,7 +1193,7 @@ grub_ntfs_label (grub_device_t device, char **label)
a5bd9f6
   pa = find_attr (&mft->attr, GRUB_NTFS_AT_VOLUME_NAME);
a5bd9f6
   if ((pa) && (pa[8] == 0) && (u32at (pa, 0x10)))
a5bd9f6
     {
a5bd9f6
-      char *buf;
a5bd9f6
+      grub_uint8_t *buf;
a5bd9f6
       int len;
a5bd9f6
 
a5bd9f6
       len = u32at (pa, 0x10) / 2;
a5bd9f6
@@ -1199,10 +1204,9 @@ grub_ntfs_label (grub_device_t device, char **label)
a5bd9f6
 	int i;
a5bd9f6
 	for (i = 0; i < len; i++)
a5bd9f6
 	  tmp[i] = grub_le_to_cpu16 (grub_get_unaligned16 (pa + 2 * i));
a5bd9f6
-	*grub_utf16_to_utf8 ((grub_uint8_t *) buf, tmp, len) =
a5bd9f6
-	  '\0';
a5bd9f6
+	*grub_utf16_to_utf8 (buf, tmp, len) = '\0';
a5bd9f6
       }
a5bd9f6
-      *label = buf;
a5bd9f6
+      *label = (char *) buf;
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
 fail:
a5bd9f6
diff --git a/grub-core/fs/ntfscomp.c b/grub-core/fs/ntfscomp.c
a5bd9f6
index 9b3b75d..02ea9fd 100644
a5bd9f6
--- a/grub-core/fs/ntfscomp.c
a5bd9f6
+++ b/grub-core/fs/ntfscomp.c
a5bd9f6
@@ -45,21 +45,21 @@ decomp_nextvcn (struct grub_ntfs_comp *cc)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
-decomp_getch (struct grub_ntfs_comp *cc, unsigned char *res)
a5bd9f6
+decomp_getch (struct grub_ntfs_comp *cc, grub_uint8_t *res)
a5bd9f6
 {
a5bd9f6
   if (cc->cbuf_ofs >= (1U << (cc->log_spc + GRUB_NTFS_BLK_SHR)))
a5bd9f6
     {
a5bd9f6
       if (decomp_nextvcn (cc))
a5bd9f6
 	return grub_errno;
a5bd9f6
     }
a5bd9f6
-  *res = (unsigned char) cc->cbuf[cc->cbuf_ofs++];
a5bd9f6
+  *res = cc->cbuf[cc->cbuf_ofs++];
a5bd9f6
   return 0;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
 decomp_get16 (struct grub_ntfs_comp *cc, grub_uint16_t * res)
a5bd9f6
 {
a5bd9f6
-  unsigned char c1 = 0, c2 = 0;
a5bd9f6
+  grub_uint8_t c1 = 0, c2 = 0;
a5bd9f6
 
a5bd9f6
   if ((decomp_getch (cc, &c1)) || (decomp_getch (cc, &c2)))
a5bd9f6
     return grub_errno;
a5bd9f6
@@ -69,7 +69,7 @@ decomp_get16 (struct grub_ntfs_comp *cc, grub_uint16_t * res)
a5bd9f6
 
a5bd9f6
 /* Decompress a block (4096 bytes) */
a5bd9f6
 static grub_err_t
a5bd9f6
-decomp_block (struct grub_ntfs_comp *cc, char *dest)
a5bd9f6
+decomp_block (struct grub_ntfs_comp *cc, grub_uint8_t *dest)
a5bd9f6
 {
a5bd9f6
   grub_uint16_t flg, cnt;
a5bd9f6
 
a5bd9f6
@@ -81,7 +81,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
a5bd9f6
     {
a5bd9f6
       if (flg & 0x8000)
a5bd9f6
 	{
a5bd9f6
-	  unsigned char tag;
a5bd9f6
+	  grub_uint8_t tag;
a5bd9f6
 	  grub_uint32_t bits, copied;
a5bd9f6
 
a5bd9f6
 	  bits = copied = tag = 0;
a5bd9f6
@@ -136,7 +136,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
a5bd9f6
 		}
a5bd9f6
 	      else
a5bd9f6
 		{
a5bd9f6
-		  unsigned char ch = 0;
a5bd9f6
+		  grub_uint8_t ch = 0;
a5bd9f6
 
a5bd9f6
 		  if (decomp_getch (cc, &ch))
a5bd9f6
 		    return grub_errno;
a5bd9f6
@@ -177,7 +177,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
-read_block (struct grub_ntfs_rlst *ctx, char *buf, grub_size_t num)
a5bd9f6
+read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
a5bd9f6
 {
a5bd9f6
   int log_cpb = GRUB_NTFS_LOG_COM_SEC - ctx->comp.log_spc;
a5bd9f6
 
a5bd9f6
@@ -289,7 +289,7 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, grub_size_t num)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
-ntfscomp (struct grub_ntfs_attr *at, char *dest, grub_disk_addr_t ofs,
a5bd9f6
+ntfscomp (struct grub_ntfs_attr *at, grub_uint8_t *dest, grub_disk_addr_t ofs,
a5bd9f6
 	  grub_size_t len, struct grub_ntfs_rlst *ctx, grub_disk_addr_t vcn)
a5bd9f6
 {
a5bd9f6
   grub_err_t ret;
a5bd9f6
diff --git a/include/grub/ntfs.h b/include/grub/ntfs.h
a5bd9f6
index cc28a01..37983c4 100644
a5bd9f6
--- a/include/grub/ntfs.h
a5bd9f6
+++ b/include/grub/ntfs.h
a5bd9f6
@@ -132,17 +132,17 @@ struct grub_ntfs_bpb
a5bd9f6
 struct grub_ntfs_attr
a5bd9f6
 {
a5bd9f6
   int flags;
a5bd9f6
-  char *emft_buf, *edat_buf;
a5bd9f6
-  char *attr_cur, *attr_nxt, *attr_end;
a5bd9f6
+  grub_uint8_t *emft_buf, *edat_buf;
a5bd9f6
+  grub_uint8_t *attr_cur, *attr_nxt, *attr_end;
a5bd9f6
   grub_uint32_t save_pos;
a5bd9f6
-  char *sbuf;
a5bd9f6
+  grub_uint8_t *sbuf;
a5bd9f6
   struct grub_ntfs_file *mft;
a5bd9f6
 };
a5bd9f6
 
a5bd9f6
 struct grub_ntfs_file
a5bd9f6
 {
a5bd9f6
   struct grub_ntfs_data *data;
a5bd9f6
-  char *buf;
a5bd9f6
+  grub_uint8_t *buf;
a5bd9f6
   grub_uint64_t size;
a5bd9f6
   grub_uint64_t mtime;
a5bd9f6
   grub_uint32_t ino;
a5bd9f6
@@ -155,10 +155,10 @@ struct grub_ntfs_data
a5bd9f6
   struct grub_ntfs_file cmft;
a5bd9f6
   struct grub_ntfs_file mmft;
a5bd9f6
   grub_disk_t disk;
a5bd9f6
-  grub_uint32_t mft_size;
a5bd9f6
-  grub_uint32_t idx_size;
a5bd9f6
+  grub_uint64_t mft_size;
a5bd9f6
+  grub_uint64_t idx_size;
a5bd9f6
   int log_spc;
a5bd9f6
-  grub_uint32_t mft_start;
a5bd9f6
+  grub_uint64_t mft_start;
a5bd9f6
   grub_uint64_t uuid;
a5bd9f6
 };
a5bd9f6
 
a5bd9f6
@@ -175,20 +175,20 @@ struct grub_ntfs_comp
a5bd9f6
   struct grub_ntfs_comp_table_element comp_table[16];
a5bd9f6
   grub_uint32_t cbuf_ofs, cbuf_vcn;
a5bd9f6
   int log_spc;
a5bd9f6
-  char *cbuf;
a5bd9f6
+  grub_uint8_t *cbuf;
a5bd9f6
 };
a5bd9f6
 
a5bd9f6
 struct grub_ntfs_rlst
a5bd9f6
 {
a5bd9f6
   int flags;
a5bd9f6
   grub_disk_addr_t target_vcn, curr_vcn, next_vcn, curr_lcn;
a5bd9f6
-  char *cur_run;
a5bd9f6
+  grub_uint8_t *cur_run;
a5bd9f6
   struct grub_ntfs_attr *attr;
a5bd9f6
   struct grub_ntfs_comp comp;
a5bd9f6
 };
a5bd9f6
 
a5bd9f6
 typedef grub_err_t (*grub_ntfscomp_func_t) (struct grub_ntfs_attr * at,
a5bd9f6
-					    char *dest,
a5bd9f6
+					    grub_uint8_t *dest,
a5bd9f6
 					    grub_disk_addr_t ofs,
a5bd9f6
 					    grub_size_t len,
a5bd9f6
 					    struct grub_ntfs_rlst * ctx,
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6