Merge "Sync with upstream up to revision 55bd3d128891:" am: 8ca792c051 am: e9bcbc39e0
am: 458bc479fd

Change-Id: Ia590b00c215380cde4ee9529fb2a7c0c9e0e54c5
diff --git a/dir.c b/dir.c
index b990b0c..e59536f 100644
--- a/dir.c
+++ b/dir.c
@@ -115,7 +115,7 @@
 	struct dosDirEntry *de;
 
 	if (!(de = freede)) {
-		if (!(de = (struct dosDirEntry *)malloc(sizeof *de)))
+		if (!(de = malloc(sizeof *de)))
 			return 0;
 	} else
 		freede = de->next;
@@ -140,7 +140,7 @@
 	struct dirTodoNode *dt;
 
 	if (!(dt = freedt)) {
-		if (!(dt = (struct dirTodoNode *)malloc(sizeof *dt)))
+		if (!(dt = malloc(sizeof *dt)))
 			return 0;
 	} else
 		freedt = dt->next;
diff --git a/fat.c b/fat.c
index 328b62f..97bfdab 100644
--- a/fat.c
+++ b/fat.c
@@ -645,8 +645,8 @@
 				break;
 			if (fat[cl].next == CLUST_FREE)
 				boot->NumFree++;
-			*p++ |= (u_char)(fat[cl + 1].next << 4);
-			*p++ = (u_char)(fat[cl + 1].next >> 4);
+			*p++ |= (u_char)(fat[cl].next << 4);
+			*p++ = (u_char)(fat[cl].next >> 4);
 			break;
 		}
 	}