Skip to content

Commit

Permalink
suppress MSVC code analysis (PREfast) warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Satoshi Tanda <[email protected]>
  • Loading branch information
tandasat committed Sep 27, 2016
1 parent d069e2e commit f177f92
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion arch/AArch64/AArch64BaseInfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#ifdef CAPSTONE_HAS_ARM64

#if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
#pragma warning(disable:4996)
#pragma warning(disable:4996) // disable MSVC's warning on strcpy()
#pragma warning(disable:28719) // disable MSVC's warning on strcpy()
#endif

#include "../../utils.h"
Expand Down
4 changes: 4 additions & 0 deletions arch/Sparc/SparcInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#define _CRT_SECURE_NO_WARNINGS
#endif

#if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
#pragma warning(disable:28719) // disable MSVC's warning on strncpy()
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
13 changes: 5 additions & 8 deletions arch/XCore/XCoreInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

#ifdef CAPSTONE_HAS_XCORE

#if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
#pragma warning(disable : 4996) // disable MSVC's warning on strcpy()
#pragma warning(disable : 28719) // disable MSVC's warning on strcpy()
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -46,15 +51,7 @@ void XCore_insn_extract(MCInst *MI, const char *code)
char *p, *p2;
char tmp[128];

// make MSVC shut up on strcpy()
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996)
#endif
strcpy(tmp, code); // safe because code is way shorter than 128 bytes
#ifdef _MSC_VER
#pragma warning(pop)
#endif

// find the first space
p = strchr(tmp, ' ');
Expand Down
3 changes: 2 additions & 1 deletion cs.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* Capstone Disassembly Engine */
/* By Nguyen Anh Quynh <[email protected]>, 2013-2014 */
#if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
#pragma warning(disable:4996)
#pragma warning(disable:4996) // disable MSVC's warning on strcpy()
#pragma warning(disable:28719) // disable MSVC's warning on strcpy()
#endif
#if defined(CAPSTONE_HAS_OSXKERNEL)
#include <libkern/libkern.h>
Expand Down
2 changes: 2 additions & 0 deletions windows/winkernel_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ void * CAPSTONE_API cs_winkernel_malloc(size_t size)
// in many cases, indicate a potential validation issue in the calling code.
NT_ASSERT(size);

// FP; a use of NonPagedPool is required for Windows 7 support
#pragma prefast(suppress : 30030) // Allocating executable POOL_TYPE memory
CS_WINKERNEL_MEMBLOCK *block = (CS_WINKERNEL_MEMBLOCK *)ExAllocatePoolWithTag(
NonPagedPool, size + sizeof(CS_WINKERNEL_MEMBLOCK), CS_WINKERNEL_POOL_TAG);
if (!block) {
Expand Down

0 comments on commit f177f92

Please sign in to comment.