8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 22:43:03 +01:00

Make comparisons return plain int (PVS-Studio).

This commit is contained in:
robocop 2014-02-25 06:20:09 +00:00
parent caaf525d3c
commit 10a253d613
5 changed files with 14 additions and 15 deletions

View File

@ -1147,7 +1147,7 @@ void MaxMinAggNode::aggPass(thread_db* tdbb, jrd_req* request, dsc* desc) const
return;
}
const SLONG result = MOV_compare(desc, &impure->vlu_desc);
const int result = MOV_compare(desc, &impure->vlu_desc);
if ((type == TYPE_MAX && result > 0) || (type == TYPE_MIN && result < 0))
EVL_make_value(tdbb, desc, impure);

View File

@ -698,11 +698,9 @@ void ComparativeBoolNode::pass2Boolean2(thread_db* tdbb, CompilerScratch* csb)
bool ComparativeBoolNode::execute(thread_db* tdbb, jrd_req* request) const
{
dsc* desc[2] = {NULL, NULL};
SSHORT comparison;
bool computed_invariant = false;
request->req_flags &= ~req_same_tx_upd;
SSHORT force_equal = 0;
// Evaluate arguments. If either is null, result is null, but in
// any case, evaluate both, since some expressions may later depend
@ -712,7 +710,7 @@ bool ComparativeBoolNode::execute(thread_db* tdbb, jrd_req* request) const
const ULONG flags = request->req_flags;
request->req_flags &= ~req_null;
force_equal |= request->req_flags & req_same_tx_upd;
bool force_equal = (request->req_flags & req_same_tx_upd) != 0;
// Currently only nod_like, nod_contains, nod_starts and nod_similar may be marked invariant
if (nodFlags & FLAG_INVARIANT)
@ -803,7 +801,8 @@ bool ComparativeBoolNode::execute(thread_db* tdbb, jrd_req* request) const
if (request->req_flags & req_null)
return false;
force_equal |= request->req_flags & req_same_tx_upd;
force_equal |= (request->req_flags & req_same_tx_upd) != 0;
int comparison; // while the two switch() below are in sync, no need to initialize
switch (blrOp)
{

View File

@ -45,7 +45,7 @@ using namespace Jrd;
static RecordSourceNode* dsqlPassRelProc(DsqlCompilerScratch* dsqlScratch, RecordSourceNode* source);
static MapNode* parseMap(thread_db* tdbb, CompilerScratch* csb, StreamType stream);
static SSHORT strcmpSpace(const char* p, const char* q);
static int strcmpSpace(const char* p, const char* q);
static void processSource(thread_db* tdbb, CompilerScratch* csb, RseNode* rse,
RecordSourceNode* source, BoolExprNode** boolean, RecordSourceNodeStack& stack);
static void processMap(thread_db* tdbb, CompilerScratch* csb, MapNode* map, Format** inputFormat);
@ -3283,7 +3283,7 @@ static MapNode* parseMap(thread_db* tdbb, CompilerScratch* csb, StreamType strea
}
// Compare two strings, which could be either space-terminated or null-terminated.
static SSHORT strcmpSpace(const char* p, const char* q)
static int strcmpSpace(const char* p, const char* q)
{
for (; *p && *p != ' ' && *q && *q != ' '; p++, q++)
{

View File

@ -95,7 +95,7 @@ static const BYTE compare_priority[] =
dtype_boolean // compares with nothing except itself
};
static inline SSHORT QUAD_COMPARE(const SQUAD* arg1, const SQUAD* arg2)
static inline int QUAD_COMPARE(const SQUAD* arg1, const SQUAD* arg2)
{
/**************************************
*
@ -188,7 +188,7 @@ bool CVT2_get_binary_comparable_desc(dsc* result, const dsc* arg1, const dsc* ar
}
SSHORT CVT2_compare(const dsc* arg1, const dsc* arg2)
int CVT2_compare(const dsc* arg1, const dsc* arg2)
{
/**************************************
*
@ -253,7 +253,7 @@ SSHORT CVT2_compare(const dsc* arg1, const dsc* arg2)
{
// keep old ttype_binary compare rules
USHORT l = MIN(arg1->dsc_length, arg2->dsc_length);
SSHORT rc = memcmp(p1, p2, l);
int rc = memcmp(p1, p2, l);
if (rc)
{
return rc;
@ -519,7 +519,7 @@ SSHORT CVT2_compare(const dsc* arg1, const dsc* arg2)
USHORT length = CVT_get_string_ptr(arg2, &t, &p, NULL, 0);
USHORT l = MIN(arg1->dsc_length, length);
SSHORT rc = memcmp(arg1->dsc_address, p, l);
int rc = memcmp(arg1->dsc_address, p, l);
if (rc)
{
return rc;
@ -541,7 +541,7 @@ SSHORT CVT2_compare(const dsc* arg1, const dsc* arg2)
}
SSHORT CVT2_blob_compare(const dsc* arg1, const dsc* arg2)
int CVT2_blob_compare(const dsc* arg1, const dsc* arg2)
{
/**************************************
*
@ -560,7 +560,7 @@ SSHORT CVT2_blob_compare(const dsc* arg1, const dsc* arg2)
SLONG l1, l2;
USHORT ttype2;
SSHORT ret_val = 0;
int ret_val = 0;
thread_db* tdbb = NULL;
SET_TDBB(tdbb);

View File

@ -27,8 +27,8 @@
#include "../jrd/jrd.h"
bool CVT2_get_binary_comparable_desc(dsc*, const dsc*, const dsc*);
SSHORT CVT2_compare(const dsc*, const dsc*);
SSHORT CVT2_blob_compare(const dsc*, const dsc*);
int CVT2_compare(const dsc*, const dsc*);
int CVT2_blob_compare(const dsc*, const dsc*);
USHORT CVT2_make_string2(const dsc*, USHORT, UCHAR**, Jrd::MoveBuffer&);
#endif // JRD_CVT2_PROTO_H