Fixed a build error and runtime crash (#1817)

* fix accessing non-exist argument

* fix off_t warning
This commit is contained in:
Buke Po
2017-05-23 22:41:58 -07:00
committed by Jonathan Hui
parent 7c0209785e
commit c294266fe0
2 changed files with 10 additions and 7 deletions
+3 -3
View File
@@ -114,7 +114,7 @@ otError utilsFlashErasePage(uint32_t aAddress)
// Write the page
ssize_t r;
r = pwrite(sFlashFd, &(dummyPage[0]), FLASH_PAGE_SIZE, address);
r = pwrite(sFlashFd, &(dummyPage[0]), FLASH_PAGE_SIZE, (off_t)address);
otEXPECT_ACTION(((int)r) == ((int)(FLASH_PAGE_SIZE)), error = OT_ERROR_FAILED);
@@ -141,7 +141,7 @@ uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
otEXPECT((ret = utilsFlashRead(aAddress + index, &byte, 1)) == 1);
// Use bitwise AND to emulate the behavior of flash memory
byte &= aData[index];
otEXPECT((ret = (uint32_t)pwrite(sFlashFd, &byte, 1, aAddress + index)) == 1);
otEXPECT((ret = (uint32_t)pwrite(sFlashFd, &byte, 1, (off_t)(aAddress + index))) == 1);
}
exit:
@@ -153,7 +153,7 @@ uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
uint32_t ret = 0;
otEXPECT(sFlashFd >= 0 && aAddress < FLASH_SIZE);
ret = (uint32_t)pread(sFlashFd, aData, aSize, aAddress);
ret = (uint32_t)pread(sFlashFd, aData, aSize, (off_t)aAddress);
exit:
return ret;
+7 -4
View File
@@ -328,11 +328,14 @@ otError Coap::ProcessClient(int argc, char *argv[])
}
// CoAP-Type
ConvertToLower(argv[3]);
if ((argc > 3) && (strcmp(argv[3], "con") == 0))
if (argc > 3)
{
coapType = kCoapTypeConfirmable;
ConvertToLower(argv[3]);
if (strcmp(argv[3], "con") == 0)
{
coapType = kCoapTypeConfirmable;
}
}
otCoapHeaderInit(&header, coapType, coapCode);