]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
add safe tinyos annotations
authorregehr <regehr>
Sun, 1 Jun 2008 04:24:33 +0000 (04:24 +0000)
committerregehr <regehr>
Sun, 1 Jun 2008 04:24:33 +0000 (04:24 +0000)
tos/chips/at45db/At45db.nc
tos/chips/at45db/At45dbP.nc
tos/chips/at45db/BlockStorageP.nc
tos/chips/at45db/HplAt45db.nc
tos/chips/at45db/HplAt45dbByteC.nc

index 8f08ef4f4a89d875366146b7daf5369139cc2d8f..203f09889a0659d901df935a33176ef83b09c22e 100644 (file)
@@ -60,7 +60,7 @@ interface At45db {
    *   AT45_PAGE_SIZE
    */
   command void write(at45page_t page, at45pageoffset_t offset,
-                    void *PASS data, at45pageoffset_t n);
+                    void *PASS COUNT(n) data, at45pageoffset_t n);
   /**
    * Signal completion of a write operation. The buffer passed to write
    * is implictly returned.
@@ -153,7 +153,7 @@ interface At45db {
    *   AT45_PAGE_SIZE
    */
   command void read(at45page_t page, at45pageoffset_t offset,
-                   void *PASS data, at45pageoffset_t n);
+                   void *PASS COUNT(n) data, at45pageoffset_t n);
   /**
    * Signal completion of a read operation. The buffer passed to read
    * is implictly returned.
index ebc6b81ccce44a7b8bc23cfab98990c754eb5a47..10619baf9dbfab32e99547e6c0da861c2c71ab34 100644 (file)
@@ -80,8 +80,8 @@ implementation
     BROKEN // Write failed. Fail all subsequent requests.
   };
   uint8_t request;
-  uint8_t *reqBuf;
   at45pageoffset_t reqOffset, reqBytes;
+  uint8_t * COUNT_NOK(reqBytes) reqBuf;
   at45page_t reqPage;
 
   enum {
@@ -364,7 +364,7 @@ implementation
   }
 
   void newRequest(uint8_t req, at45page_t page, at45pageoffset_t offset,
-                 void *reqdata, at45pageoffset_t n) {
+                 void * COUNT_NOK(n) reqdata, at45pageoffset_t n) {
     request = req;
 
     reqBuf = reqdata;
@@ -398,7 +398,7 @@ implementation
                                        at45pageoffset_t n,
                                        uint16_t baseCrc) {
     /* This is a hack (store crc in reqBuf), but it saves 2 bytes of RAM */
-    reqBuf = (uint8_t *)baseCrc;
+    reqBuf = TCAST(uint8_t * COUNT(baseCrc), baseCrc);
     newRequest(R_READCRC, page, offset, reqBuf, n);
   }
 
index c241b428579d4987c02beca316491663ba5ca33f..284c369bf08b0c28fe11e96024dfb8beb77e1ec7 100644 (file)
@@ -93,7 +93,7 @@ implementation
   struct {
     /* The latest request made for this client, and it's arguments */
     uint8_t request; /* automatically initialised to R_IDLE */
-    uint8_t *buf;
+    uint8_t * COUNT_NOK(len) buf;
     storage_addr_t addr;
     storage_len_t len;
   } s[N];
@@ -179,7 +179,7 @@ implementation
   }
 
   error_t newRequest(uint8_t newState, uint8_t id,
-                      storage_addr_t addr, uint8_t* buf, storage_len_t len) {
+                      storage_addr_t addr, uint8_t* COUNT_NOK(len) buf, storage_len_t len) {
     storage_len_t vsize;
 
     if (s[id].request != R_IDLE)
@@ -336,7 +336,7 @@ implementation
   /* ------------------------------------------------------------------ */
 
   command error_t BlockRead.computeCrc[uint8_t id](storage_addr_t addr, storage_len_t len, uint16_t basecrc) {
-    return newRequest(R_CRC, id, addr, (void *)basecrc, len);
+    return newRequest(R_CRC, id, addr, TCAST(void * COUNT(len),basecrc), len);
   }
 
   /* ------------------------------------------------------------------ */
index 69cf51638fcf6bb1e80a23c6a357d60cf60a5034..b308505e13e29f688fef5daaeb6cbe59c16b738a 100644 (file)
@@ -117,7 +117,7 @@ interface HplAt45db {
    *   AT45_PAGE_SIZE
    */
   command void readBuffer(uint8_t cmd, at45pageoffset_t offset,
-                   uint8_t *PASS data, uint16_t n);
+                   uint8_t *PASS COUNT_NOK(n) data, uint16_t n);
 
   /**
    * Read directly from flash. readDone will be signaled.
@@ -132,7 +132,7 @@ interface HplAt45db {
    * @param n Number of bytes to read (> 0).
    */
   command void read(uint8_t cmd, at45page_t page, at45pageoffset_t offset,
-                   uint8_t *PASS data, at45pageoffset_t n);
+                   uint8_t *PASS COUNT_NOK(n) data, at45pageoffset_t n);
 
   /**
    * Signaled when data has been read from the buffer. The data buffer
@@ -176,7 +176,7 @@ interface HplAt45db {
    *   AT45_PAGE_SIZE
    */
   command void write(uint8_t cmd, at45page_t page, at45pageoffset_t offset,
-                    uint8_t *PASS data, at45pageoffset_t n);
+                    uint8_t *PASS COUNT_NOK(n) data, at45pageoffset_t n);
 
   /**
    * Signaled when data has been written to the buffer. The data buffer
index b07db61a093eb22717518ff8dd7b366ce7819bf4..57557675af2da87a6b34bbc7441f41180b82d7f4 100644 (file)
@@ -48,8 +48,8 @@ implementation
   };
   uint8_t status = P_IDLE;
   uint8_t flashCmd[4];
-  uint8_t *data;
   at45pageoffset_t dataCount;
+  uint8_t * COUNT_NOK(dataCount) data;
   uint8_t dontCare;
 
   void complete(uint16_t crc) {
@@ -172,7 +172,7 @@ implementation
 
   void execCommand(uint8_t op, uint8_t reqCmd, uint8_t reqDontCare,
                   at45page_t reqPage, at45pageoffset_t reqOffset,
-                  uint8_t *reqData, at45pageoffset_t reqCount) {
+                  uint8_t * COUNT_NOK(reqCount) reqData, at45pageoffset_t reqCount) {
     status = op;
 
     // page (2 bytes) and highest bit of offset
@@ -244,7 +244,7 @@ implementation
                             at45page_t page, at45pageoffset_t offset,
                             at45pageoffset_t count,
                             uint16_t baseCrc) {
-    execCommand(P_READ_CRC, cmd, 2, page, offset, (uint8_t *)baseCrc, count);
+    execCommand(P_READ_CRC, cmd, 2, page, offset, TCAST(uint8_t * COUNT(count), baseCrc), count);
   }
 
   command void HplAt45db.write(uint8_t cmd,