[Tinyos-beta-commits] CVS: tinyos-1.x/beta/AT45DB FormatStorageM.nc, 1.2, 1.3

David Gay idgay at users.sourceforge.net
Mon Jun 20 14:57:14 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/AT45DB
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31348

Modified Files:
	FormatStorageM.nc 
Log Message:
allow for possibility of padding in volume header


Index: FormatStorageM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/AT45DB/FormatStorageM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FormatStorageM.nc	8 Jun 2005 23:27:29 -0000	1.2
--- FormatStorageM.nc	20 Jun 2005 21:57:12 -0000	1.3
***************
*** 170,177 ****
     
    uint16_t computeSectorTableCrc() {
!     uint16_t crc = crcByte(0, header.nvolumes);
      unsigned char *vtable = (unsigned char *)volumes;
      size_t i;
  
      for (i = 0; i < header.nvolumes * sizeof *volumes; i++)
        crc = crcByte(crc, vtable[i]);
--- 170,182 ----
     
    uint16_t computeSectorTableCrc() {
!     uint16_t crc;
      unsigned char *vtable = (unsigned char *)volumes;
+     size_t nvOffset = offsetof(struct volume_definition_header_t, nvolumes);
      size_t i;
  
+     crc = 0;
+     /* There may be padding after nvolumes, hence this loop */
+     for (i = nvOffset; i < sizeof header; i++)
+       crc = crcByte(crc, ((unsigned char *)&header)[i]);
      for (i = 0; i < header.nvolumes * sizeof *volumes; i++)
        crc = crcByte(crc, vtable[i]);



More information about the Tinyos-beta-commits mailing list