Skip to content

Commit

Permalink
Cleanup _snprintf logic
Browse files Browse the repository at this point in the history
Fix building dyninstAPI_RT with VS 2015.
Remove unnecessary overriding of _snprintf in favor of a centralized
definition.
  • Loading branch information
pefoley2 committed Jun 15, 2016
1 parent 22d9723 commit 89c7c45
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 58 deletions.
2 changes: 1 addition & 1 deletion cmake/shared.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ foreach (p LIB INCLUDE CMAKE)
endforeach()

if(PLATFORM MATCHES nt OR PLATFORM MATCHES windows)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER 19)
add_definitions(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1)
else()
add_definitions(-Dsnprintf=_snprintf)
Expand Down
6 changes: 1 addition & 5 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ if (PLATFORM MATCHES nt OR PLATFORM MATCHES windows)
# src/dthread.C
src/addrtranslate-win.C
)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19)
add_definitions(-DWIN32 -D_WIN32_WINNT=0x500)
else()
add_definitions(-DWIN32 -D_WIN32_WINNT=0x500 -Dsnprintf=_snprintf)
endif()
add_definitions(-DWIN32 -D_WIN32_WINNT=0x500)
endif()


Expand Down
4 changes: 0 additions & 4 deletions common/src/Types.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
#include <stdio.h>
#include <assert.h>

#if (defined(_MSC_VER) && _MSC_VER < 1900)
#define snprintf _snprintf
#endif

// verify the size of the defined Address type
void Address_chk ()
{
Expand Down
4 changes: 0 additions & 4 deletions common/src/serialize-bin.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
#include "common/src/Types.h"
#include "common/src/headers.h"

#if (defined(_MSC_VER) && _MSC_VER < 1900)
#define snprintf _snprintf
#endif

#if defined(SERIALIZATION_DISABLED)
unsigned short Dyninst::get_serializer_index(Dyninst::SerializerBase *) {
return 0;
Expand Down
4 changes: 0 additions & 4 deletions common/src/util.C
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
#include <map>
#include "common/h/dyntypes.h"

#if (defined(_MSC_VER) && _MSC_VER < 1900)
#define snprintf _snprintf
#endif

using namespace std;

namespace Dyninst {
Expand Down
4 changes: 0 additions & 4 deletions dyninstAPI/src/BPatch_type.C
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
#include "RegisterConversion.h"
//#include "Annotatable.h"

#if (defined(_MSC_VER) && _MSC_VER < 1900)
#define snprintf _snprintf
#endif

using namespace Dyninst;
using namespace Dyninst::SymtabAPI;

Expand Down
4 changes: 0 additions & 4 deletions dyninstAPI/src/debug.C
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ int bperr(const char *format, ...)

char syserr[128];
if (errno) {
#if defined (i386_unknown_nt4_0)
int syserrlen = _snprintf(syserr, 128," [%d: %s]", errno, strerror(errno));
#else
int syserrlen = snprintf(syserr, 128," [%d: %s]", errno, strerror(errno));
#endif
/* reset errno so that future calls to this function don't report same error */
errno = 0;

Expand Down
4 changes: 1 addition & 3 deletions dyninstAPI/src/image.C
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@
#include "libdwarf.h"
#endif

#if (defined(_MSC_VER) && _MSC_VER < 1900)
#define snprintf _snprintf
#elif defined(_MSC_VER)
#if defined(_MSC_VER)
#include <dbghelp.h>
#endif

Expand Down
4 changes: 0 additions & 4 deletions dyninstAPI/src/pdwinnt.C
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@
#include "nt_signal_emul.h"
#include "dyninstAPI/src/PCEventMuxer.h"

#if (defined(_MSC_VER) && _MSC_VER < 1900)
#define snprintf _snprintf
#endif

// prototypes of functions used in this file

void InitSymbolHandler( HANDLE hPCProcess );
Expand Down
16 changes: 0 additions & 16 deletions parseAPI/src/ParseData.C
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,11 @@ StandardParseData::get_func(CodeRegion * cr, Address entry, FuncSource src)
if(!(ret = findFunc(cr,entry))) {
reg = reglookup(cr,entry); // get the *correct* CodeRegion
if(reg && reg->isCode(entry)) {
#if defined (os_windows)
if (src == MODIFICATION) {
_snprintf_s(name,32,"mod%lx",entry);
}
else {
_snprintf_s(name,32,"targ%lx",entry);
}
#else
if (src == MODIFICATION) {
snprintf(name,32,"mod%lx",entry);
} else {
snprintf(name,32,"targ%lx",entry);
}
#endif
parsing_printf("[%s] new function for target %lx\n",FILE__,entry);
ret = _parser->factory()._mkfunc(
entry,src,name,&_parser->obj(),reg,_parser->obj().cs());
Expand Down Expand Up @@ -328,17 +319,10 @@ OverlappingParseData::get_func(CodeRegion * cr, Address addr, FuncSource src)
/* note the difference; we are limited to using the passed-in
CodeRegion in this overlapping cr case */
if(cr && cr->isCode(addr)) {
#if defined (os_windows)
if(src == GAP || src == GAPRT)
_snprintf_s(name,32,"gap%lx",addr);
else
_snprintf_s(name,32,"targ%lx",addr);
#else
if(src == GAP || src == GAPRT)
snprintf(name,32,"gap%lx",addr);
else
snprintf(name,32,"targ%lx",addr);
#endif
parsing_printf("[%s] new function for target %lx\n",FILE__,addr);
ret = _parser->factory()._mkfunc(
addr,src,name,&_parser->obj(),cr,cr);
Expand Down
4 changes: 0 additions & 4 deletions symtabAPI/src/Object-nt.C
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@

#include "common/src/headers.h"

#if defined(_MSC_VER)
#define snprintf _snprintf
#endif

using namespace Dyninst;
using namespace Dyninst::SymtabAPI;

Expand Down
5 changes: 0 additions & 5 deletions symtabAPI/src/Type.C
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ using namespace std;
//#include "collections.h"
//#include "debug.h" TODO: We want such behaviour. LATER!

#if (defined(_MSC_VER) && _MSC_VER < 1900)
#define snprintf _snprintf
#endif


static int findIntrensicType(std::string &name);

// This is the ID that is decremented for each type a user defines. It is
Expand Down

0 comments on commit 89c7c45

Please sign in to comment.