Skip to content

Commit

Permalink
util: Remove zero-argument versions of LogPrint and error
Browse files Browse the repository at this point in the history
Changes in tinyformat, recently imported from upstream have made the
zero-argument versions of formatting functions unnecessary. Remove them.

This is a slight semantic change: `%` characters in the zero-argument
call are now regarded and need to be escaped. As for as I know, the only
use of this is in `main.cpp`.
  • Loading branch information
laanwj committed Jun 27, 2016
1 parent 695041e commit a5072a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Expand Up @@ -4159,7 +4159,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
int nGoodTransactions = 0;
CValidationState state;
int reportDone = 0;
LogPrintf("[0%]...");
LogPrintf("[0%%]...");
for (CBlockIndex* pindex = chainActive.Tip(); pindex && pindex->pprev; pindex = pindex->pprev)
{
boost::this_thread::interruption_point();
Expand Down
28 changes: 6 additions & 22 deletions src/util.h
Expand Up @@ -77,33 +77,17 @@ int LogPrintStr(const std::string &str);

#define LogPrintf(...) LogPrint(NULL, __VA_ARGS__)

template<typename T1, typename... Args>
static inline int LogPrint(const char* category, const char* fmt, const T1& v1, const Args&... args)
template<typename... Args>
static inline int LogPrint(const char* category, const char* fmt, const Args&... args)
{
if(!LogAcceptCategory(category)) return 0; \
return LogPrintStr(tfm::format(fmt, v1, args...));
return LogPrintStr(tfm::format(fmt, args...));
}

template<typename T1, typename... Args>
bool error(const char* fmt, const T1& v1, const Args&... args)
template<typename... Args>
bool error(const char* fmt, const Args&... args)
{
LogPrintStr("ERROR: " + tfm::format(fmt, v1, args...) + "\n");
return false;
}

/**
* Zero-arg versions of logging and error, these are not covered by
* the variadic templates above (and don't take format arguments but
* bare strings).
*/
static inline int LogPrint(const char* category, const char* s)
{
if(!LogAcceptCategory(category)) return 0;
return LogPrintStr(s);
}
static inline bool error(const char* s)
{
LogPrintStr(std::string("ERROR: ") + s + "\n");
LogPrintStr("ERROR: " + tfm::format(fmt, args...) + "\n");
return false;
}

Expand Down

0 comments on commit a5072a7

Please sign in to comment.