[En-Nut-Discussion] SVN compilation fix: fs/fat.c

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Mon Oct 5 18:35:33 CEST 2009


Hello,

with (avr-)gcc version 4.4.1 [gcc-4_4-branch revision 150839] (SUSE Linux)
recent Sourceforge SVN doesn't compile nut/fs/fat.c:
cc1: warnings being treated as errors
../.././/fs/fat.c: In function 'MountATAPI':
../.././/fs/fat.c:934: error: dereferencing type-punned pointer will break strict-aliasing rules
../.././/fs/fat.c:935: error: dereferencing type-punned pointer will break strict-aliasing rules

Appended patch defines the structure with the types later used.

Bye
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: nut/fs/fat.c
===================================================================
--- nut/fs/fat.c	(Revision 2740)
+++ nut/fs/fat.c	(Arbeitskopie)
@@ -367,8 +367,8 @@
     BYTE volseqnum[4];
     BYTE seksize[4];
     BYTE pathtablen[8];
-    BYTE firstsek_LEpathtab1_LE[4];
-    BYTE firstsek_LEpathtab2_LE[4];
+    DWORD firstsek_LEpathtab1_LE;
+    DWORD firstsek_LEpathtab2_LE;
     BYTE firstsek_BEpathtab1_BE[4];
     BYTE firstsek_BEpathtab2_BE[4];
     BYTE rootdir[34];
@@ -931,8 +931,8 @@
 
         pDrive->bSectorsPerCluster = 1;
         pDrive->dwFirstRootDirSector = *(DWORD *) & pPVD->rootdir[2];
-        pDrive->dwFAT1StartSector = *(DWORD *) & pPVD->firstsek_LEpathtab1_LE[0];
-        pDrive->dwFAT2StartSector = *(DWORD *) & pPVD->firstsek_LEpathtab2_LE[0];
+        pDrive->dwFAT1StartSector = pPVD->firstsek_LEpathtab1_LE;
+        pDrive->dwFAT2StartSector = pPVD->firstsek_LEpathtab2_LE;
 
         pDrive->dwRootDirSectors = pDrive->dwFAT1StartSector - pDrive->dwFirstRootDirSector;
         pDrive->dwRootCluster = pDrive->dwFirstRootDirSector;



More information about the En-Nut-Discussion mailing list