fix warnings: expression result unused [-Wunused-value]
In the assert()s take advantage of the fact that string constants ("string") are effectively of type 'const char []', which when used in an expression yield a non-NULL pointer. An assertion that should always fail can thus be formulated as: assert(!"fail); An assertion where a text message should be added to the expression can be written as such: assert("message" && expression); Signed-off-by: Giel van Schijndel <me@mortis.eu>
This commit is contained in:
parent
df40181417
commit
ecf1c79aad
4 changed files with 6 additions and 6 deletions
4
src/db.h
4
src/db.h
|
@ -88,7 +88,7 @@ protected:
|
||||||
if (!pdb)
|
if (!pdb)
|
||||||
return false;
|
return false;
|
||||||
if (fReadOnly)
|
if (fReadOnly)
|
||||||
assert(("Write called on database in read-only mode", false));
|
assert(!"Write called on database in read-only mode");
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
CDataStream ssKey(SER_DISK);
|
CDataStream ssKey(SER_DISK);
|
||||||
|
@ -117,7 +117,7 @@ protected:
|
||||||
if (!pdb)
|
if (!pdb)
|
||||||
return false;
|
return false;
|
||||||
if (fReadOnly)
|
if (fReadOnly)
|
||||||
assert(("Erase called on database in read-only mode", false));
|
assert(!"Erase called on database in read-only mode");
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
CDataStream ssKey(SER_DISK);
|
CDataStream ssKey(SER_DISK);
|
||||||
|
|
|
@ -1688,7 +1688,7 @@ string GetWarnings(string strFor)
|
||||||
return strStatusBar;
|
return strStatusBar;
|
||||||
else if (strFor == "rpc")
|
else if (strFor == "rpc")
|
||||||
return strRPC;
|
return strRPC;
|
||||||
assert(("GetWarnings() : invalid parameter", false));
|
assert(!"GetWarnings() : invalid parameter");
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,7 @@ public:
|
||||||
{
|
{
|
||||||
// I'm not sure if this should push the script or concatenate scripts.
|
// I'm not sure if this should push the script or concatenate scripts.
|
||||||
// If there's ever a use for pushing a script onto a script, delete this member fn
|
// If there's ever a use for pushing a script onto a script, delete this member fn
|
||||||
assert(("warning: pushing a CScript onto a CScript with << is probably not intended, use + to concatenate", false));
|
assert(!"warning: pushing a CScript onto a CScript with << is probably not intended, use + to concatenate");
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ public:
|
||||||
// I'd rather be careful than suffer the other more error prone syntax.
|
// I'd rather be careful than suffer the other more error prone syntax.
|
||||||
// The compiler will optimise away all this loop junk.
|
// The compiler will optimise away all this loop junk.
|
||||||
#define CRITICAL_BLOCK(cs) \
|
#define CRITICAL_BLOCK(cs) \
|
||||||
for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by CRITICAL_BLOCK!", !fcriticalblockonce)), fcriticalblockonce=false) \
|
for (bool fcriticalblockonce=true; fcriticalblockonce; assert("break caught by CRITICAL_BLOCK!" && !fcriticalblockonce), fcriticalblockonce=false) \
|
||||||
for (CCriticalBlock criticalblock(cs); fcriticalblockonce && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0)
|
for (CCriticalBlock criticalblock(cs); fcriticalblockonce && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0)
|
||||||
|
|
||||||
class CTryCriticalBlock
|
class CTryCriticalBlock
|
||||||
|
@ -278,7 +278,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TRY_CRITICAL_BLOCK(cs) \
|
#define TRY_CRITICAL_BLOCK(cs) \
|
||||||
for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by TRY_CRITICAL_BLOCK!", !fcriticalblockonce)), fcriticalblockonce=false) \
|
for (bool fcriticalblockonce=true; fcriticalblockonce; assert("break caught by TRY_CRITICAL_BLOCK!" && !fcriticalblockonce), fcriticalblockonce=false) \
|
||||||
for (CTryCriticalBlock criticalblock(cs); fcriticalblockonce && (fcriticalblockonce = criticalblock.Entered()) && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0)
|
for (CTryCriticalBlock criticalblock(cs); fcriticalblockonce && (fcriticalblockonce = criticalblock.Entered()) && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue