From bf3a910f6b7f9c6de4e3e92a5f083da890ec28ec Mon Sep 17 00:00:00 2001 From: regehr Date: Sun, 1 Jun 2008 04:24:33 +0000 Subject: [PATCH] add safe tinyos annotations --- tos/chips/at45db/At45db.nc | 4 ++-- tos/chips/at45db/At45dbP.nc | 6 +++--- tos/chips/at45db/BlockStorageP.nc | 6 +++--- tos/chips/at45db/HplAt45db.nc | 6 +++--- tos/chips/at45db/HplAt45dbByteC.nc | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tos/chips/at45db/At45db.nc b/tos/chips/at45db/At45db.nc index 8f08ef4f..203f0988 100644 --- a/tos/chips/at45db/At45db.nc +++ b/tos/chips/at45db/At45db.nc @@ -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. diff --git a/tos/chips/at45db/At45dbP.nc b/tos/chips/at45db/At45dbP.nc index ebc6b81c..10619baf 100644 --- a/tos/chips/at45db/At45dbP.nc +++ b/tos/chips/at45db/At45dbP.nc @@ -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); } diff --git a/tos/chips/at45db/BlockStorageP.nc b/tos/chips/at45db/BlockStorageP.nc index c241b428..284c369b 100644 --- a/tos/chips/at45db/BlockStorageP.nc +++ b/tos/chips/at45db/BlockStorageP.nc @@ -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); } /* ------------------------------------------------------------------ */ diff --git a/tos/chips/at45db/HplAt45db.nc b/tos/chips/at45db/HplAt45db.nc index 69cf5163..b308505e 100644 --- a/tos/chips/at45db/HplAt45db.nc +++ b/tos/chips/at45db/HplAt45db.nc @@ -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 diff --git a/tos/chips/at45db/HplAt45dbByteC.nc b/tos/chips/at45db/HplAt45dbByteC.nc index b07db61a..57557675 100644 --- a/tos/chips/at45db/HplAt45dbByteC.nc +++ b/tos/chips/at45db/HplAt45dbByteC.nc @@ -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, -- 2.39.2