mirror of
https://github.com/espressif/openthread.git
synced 2026-10-04 14:57:38 +00:00
Remove _CRT_SECURE_NO_WARNINGS Usage (#1517)
* Remove usage of deprecated/unsafe CRT functions.
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>
|
||||
%(PreprocessorDefinitions);
|
||||
_CRT_SECURE_NO_WARNINGS;
|
||||
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
|
||||
OTBUILD;
|
||||
</PreprocessorDefinitions>
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#endif
|
||||
|
||||
#if _WIN32
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <windows.h>
|
||||
|
||||
@@ -98,9 +98,6 @@
|
||||
// Redefine rand to random for test code
|
||||
#define random rand
|
||||
|
||||
// Temporary !!! TODO - Remove this once we figure out the strncpy issue
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#ifdef OTBUILD
|
||||
#include <strlcat/strlcat.h>
|
||||
#include <strlcpy/strlcpy.h>
|
||||
|
||||
@@ -223,7 +223,7 @@ void NcpUart::HandleError(ThreadError aError, uint8_t *aBuf, uint16_t aBufLength
|
||||
|
||||
// We can get away with sprintf because we know
|
||||
// `hexbuf` is large enough.
|
||||
sprintf(hexbuf, "Framing error %d: [", aError);
|
||||
snprintf(hexbuf, sizeof(hexbuf), "Framing error %d: [", aError);
|
||||
|
||||
// Write out the first part of our log message.
|
||||
otNcpStreamWrite(0, reinterpret_cast<uint8_t*>(hexbuf), static_cast<int>(strlen(hexbuf)));
|
||||
@@ -235,12 +235,12 @@ void NcpUart::HandleError(ThreadError aError, uint8_t *aBuf, uint16_t aBufLength
|
||||
// We can get away with sprintf because we know
|
||||
// `hexbuf` is large enough, based on our calculations
|
||||
// above.
|
||||
sprintf(&hexbuf[i*3], " %02X", static_cast<uint8_t>(aBuf[i]));
|
||||
snprintf(&hexbuf[i*3], sizeof(hexbuf) - i*3, " %02X", static_cast<uint8_t>(aBuf[i]));
|
||||
}
|
||||
|
||||
// Append a final closing bracket and newline character
|
||||
// so our log line looks nice.
|
||||
sprintf(&hexbuf[i*3], "]\n");
|
||||
snprintf(&hexbuf[i*3], sizeof(hexbuf) - i*3, "]\n");
|
||||
|
||||
// Write out the second part of our log message.
|
||||
// We skip the first byte since it has a space in it.
|
||||
|
||||
Reference in New Issue
Block a user