]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/at45db/LogStorageP.nc
turn on safe compilation for some modules
[tinyos-2.x.git] / tos / chips / at45db / LogStorageP.nc
index 4f384f275fb970e1346e58892a6926bb0e2a0793..bf8660ebca4cf4378ce0cf8b64c490b1610d1138 100644 (file)
@@ -1,4 +1,4 @@
-/*                                                                     tab:4
+/*
  * "Copyright (c) 2000-2004 The Regents of the University  of California.  
  * All rights reserved.
  *
@@ -38,7 +38,7 @@
  * @author: Jonathan Hui <jwhui@cs.berkeley.edu>
  */
 
-module LogStorageP {
+module LogStorageP @safe() {
   provides {
     interface LogRead[uint8_t logId];
     interface LogWrite[uint8_t logId];
@@ -267,6 +267,9 @@ implementation
   void sync() {
     metadata.flags = F_SYNC | F_LASTVALID;
     metadata.lastRecordOffset = s[client].woffset;
+    /* rend is now no longer the end of the page */
+    if (s[client].rpage == s[client].wpage)
+      s[client].rend = s[client].woffset;
     wmetadataStart();
   }
 
@@ -379,7 +382,7 @@ implementation
   }
 
   command error_t LogRead.seek[uint8_t id](storage_cookie_t offset) {
-    return newRequest(R_SEEK, id, (void *)(offset >> 16), offset);
+    return newRequest(R_SEEK, id, (void *)((uint16_t)(offset >> 16)), offset);
   }
 
   command storage_len_t LogRead.getSize[uint8_t id]() {
@@ -633,7 +636,7 @@ implementation
        would end on the last byte of the last page, as this would mean that
        we would not sync the last page, breaking the log volume
        invariant */
-    if (s[client].wpos % vlen >= vlen - len)
+    if ((s[client].wpos - PAGE_SIZE) % vlen >= vlen - len)
       sync();
     else
       {