From 3d73ed884eecb628f2c10cc0c5a158d0121e5c51 Mon Sep 17 00:00:00 2001 From: Jief L Date: Thu, 12 Mar 2020 19:16:18 +0300 Subject: [PATCH] VS2017 warnings. --- rEFIt_UEFI/cpp_foundation/XString.cpp | 2 +- rEFIt_UEFI/cpp_foundation/XString.h | 13 +++++++++++-- rEFIt_UEFI/cpp_foundation/printf_lite.cpp | 2 +- rEFIt_UEFI/cpp_foundation/printf_lite.h | 14 +++++++++++--- 4 files changed, 24 insertions(+), 7 deletions(-) mode change 100644 => 100755 rEFIt_UEFI/cpp_foundation/printf_lite.h diff --git a/rEFIt_UEFI/cpp_foundation/XString.cpp b/rEFIt_UEFI/cpp_foundation/XString.cpp index 9f10f5455..46e0987d0 100755 --- a/rEFIt_UEFI/cpp_foundation/XString.cpp +++ b/rEFIt_UEFI/cpp_foundation/XString.cpp @@ -83,7 +83,7 @@ void XString::StrnCpy(const char *buf, xsize len) CheckSize(len, 0); xsize idx = 0; char* p = data(); - while ( idx++ < len && (*p++ = *buf++)); + while ( idx++ < len && (*p++ = *buf++) != 0 ); SetLength(idx-1); /* SetLength fait _Data[len]=0 */ }else{ SetLength(0); /* SetLength fait _Data[len]=0 */ diff --git a/rEFIt_UEFI/cpp_foundation/XString.h b/rEFIt_UEFI/cpp_foundation/XString.h index d17ca075c..346f89d0d 100755 --- a/rEFIt_UEFI/cpp_foundation/XString.h +++ b/rEFIt_UEFI/cpp_foundation/XString.h @@ -106,10 +106,15 @@ class XString void Cat(const XString &uneXString); void vSPrintf(const char *Format, VA_LIST va); - void SPrintf(const char *format, ...) __attribute__((format (printf, 2, 3))); // 3 and 4 because of hidden parameter. + void SPrintf(const char *format, ...) + #ifndef _MSC_VER + __attribute__((format (printf, 2, 3))) // 2 and 3 because of hidden parameter. + #endif + ; const XString& takeValueFrom(const char* S) { StrCpy(S); return *this; } + const XString& takeValueFrom(const wchar_t* S) { SPrintf("%ls", S); return *this; } const XString &operator =(const XString &aString); // const XString &operator =(const XConstString &aConstString); @@ -265,7 +270,11 @@ class XString extern const XString NullXString; -XString SPrintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));; +XString SPrintf(const char *format, ...) + #ifndef _MSC_VER + __attribute__((format(printf, 1, 2))) + #endif +; XString SubString(const char *S, xsize pos, xsize count); #ifdef TODO_skqdjfhksqjhfksjqdf XString ToAlpha(const char *S); diff --git a/rEFIt_UEFI/cpp_foundation/printf_lite.cpp b/rEFIt_UEFI/cpp_foundation/printf_lite.cpp index 7500f412d..9da08cd6c 100644 --- a/rEFIt_UEFI/cpp_foundation/printf_lite.cpp +++ b/rEFIt_UEFI/cpp_foundation/printf_lite.cpp @@ -914,7 +914,7 @@ int vsnprintf(printf_char_type* buf, size_t len, const char *__restrict format, return 1; } -int snprintf(char *__restrict buf, size_t len, const char *__restrict format, ...) +int snprintf(printf_char_type*, size_t len, const char *__restrict format, ...) { va_list valist; va_start(valist, format); diff --git a/rEFIt_UEFI/cpp_foundation/printf_lite.h b/rEFIt_UEFI/cpp_foundation/printf_lite.h old mode 100644 new mode 100755 index 18b64898c..0a5a46901 --- a/rEFIt_UEFI/cpp_foundation/printf_lite.h +++ b/rEFIt_UEFI/cpp_foundation/printf_lite.h @@ -92,7 +92,7 @@ #define PRINTF_LITE_USB_SUPPORT 0 // #endif #ifndef PRINTF_LITE_SNPRINTF_SUPPORT -#define PRINTF_LITE_SNPRINTF_SUPPORT 1 // +#define PRINTF_LITE_SNPRINTF_SUPPORT 0 // #endif #ifndef PRINTF_LITE_FLASHSTRING_SUPPORT #define PRINTF_LITE_FLASHSTRING_SUPPORT 0 // @@ -117,10 +117,18 @@ extern "C" { #endif #if PRINTF_LITE_SNPRINTF_SUPPORT == 1 - int vsnprintf(char *__restrict, size_t, const char *__restrict, va_list valist) __attribute__ ((__format__ (__printf__, 3, 0))); // have to return int to conform stdio.h. Always return 1; + int vsnprintf(printf_char_type*, size_t, const char *__restrict, va_list valist) + #ifndef _MSC_VER + __attribute__ ((__format__ (__printf__, 3, 0))) + #endif + ; // have to return int to conform stdio.h. Always return 1; // gcc-4.9.2-atmel3.5.4-arduino2 report snprintf to undefined. Change the name and it'll work. String isn't it ? - int snprintf(char *__restrict buf, size_t len, const char *__restrict format, ...) __attribute__((__format__ (__printf__, 3, 4))); // have to return int to conform stdio.h. Always return 1; + int snprintf(printf_char_type*, size_t len, const char *__restrict format, ...) + #ifndef _MSC_VER + __attribute__((__format__ (__printf__, 3, 4))) + #endif + ; // have to return int to conform stdio.h. Always return 1; #endif #if PRINTF_LITE_UART_SUPPORT == 1