PERFORCE change 123096 for review

Brian Chu chub at FreeBSD.org
Sun Jul 8 08:03:58 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=123096

Change 123096 by chub at chub-msdosfs on 2007/07/08 08:03:16

	 Killed the endianness macros; using (get|put)u(long|short) defines and le(16|32)(dec|enc) functions to deal with the conversions instead.

Affected files ...

.. //depot/projects/soc2007/chub-msdosfs2/sys/geom/label/g_label_msdosfs.c#3 edit

Differences ...

==== //depot/projects/soc2007/chub-msdosfs2/sys/geom/label/g_label_msdosfs.c#3 (text+ko) ====

@@ -44,14 +44,7 @@
 #define G_LABEL_MSDOSFS_DIR	"msdosfs"
 #define LABEL_NO_NAME		"NO NAME    "
 
-/*
- * Conversion macros for little endian encoded unsigned integers
- * in byte streams to the local unsigned integer format.
- */
 #include <sys/types.h>
-#define UINT16BYTES(p) ((uint32_t)((p)[0] + (256*(p)[1])))
-#define UINT32BYTES(p) ((uint32_t)((p)[0] + (256*(p)[1]) +		\
-	    (65536*(p)[2]) + (16777216*(p)[3])))
 
 static void
 g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size)
@@ -107,7 +100,7 @@
 	/*
 	 * Test if this is really a FAT volume and determine the FAT type.
 	 */
-	if (UINT16BYTES(pfat_bpb50->bpbFATsecs) != 0) {
+	if (getushort(pfat_bpb50->bpbFATsecs) != 0) {
     /* The extended boot record is one place for FAT12/FAT16
      * and another for FAT32.
      */
@@ -141,7 +134,7 @@
 		strlcpy(label, pfat_extboot->exVolumeLabel,
 		    MIN(size, sizeof(pfat_extboot->exVolumeLabel) + 1));
 	}
-  else if (UINT32BYTES(pfat_bpb710->bpbBigFATsecs) != 0) {
+  else if (getulong(pfat_bpb710->bpbBigFATsecs) != 0) {
 		uint32_t fat_FirstDataSector, fat_BytesPerSector, offset;
 
     /* The extended boot record is one place for FAT12/FAT16
@@ -180,10 +173,10 @@
 		 * the root directory.
 		 */
 		fat_FirstDataSector =
-		    UINT16BYTES(pfat_bpb710->bpbResSectors) +
+		    getushort(pfat_bpb710->bpbResSectors) +
 		    (pfat_bpb710->bpbFATs *
-		     UINT32BYTES(pfat_bpb710->bpbBigFATsecs));
-		fat_BytesPerSector = UINT16BYTES(pfat_bpb710->bpbBytesPerSec);
+		     getulong(pfat_bpb710->bpbBigFATsecs));
+		fat_BytesPerSector = getushort(pfat_bpb710->bpbBytesPerSec);
 
 		G_LABEL_DEBUG(2,
 		    "MSDOSFS: FAT_FirstDataSector=0x%x, FAT_BytesPerSector=%d",


More information about the p4-projects mailing list