mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 16:43:03 +01:00
Fixed problems reported by PVS-Studio - http://www.viva64.com/en/b/0396/
This commit is contained in:
parent
986c37303b
commit
c31769c46a
2
extern/btyacc/reader.c
vendored
2
extern/btyacc/reader.c
vendored
@ -1200,7 +1200,7 @@ void advance_to_start()
|
||||
syntax_error(lineno, line, s_cptr); } }
|
||||
|
||||
c = nextc();
|
||||
if (!isalpha(c) && c != '_' && c != '.' && c != '_')
|
||||
if (!isalpha(c) && c != '_' && c != '.' && c != '$')
|
||||
syntax_error(lineno, line, cptr);
|
||||
bp = get_name();
|
||||
if (goal == 0) {
|
||||
|
@ -1945,14 +1945,14 @@ int put_message( att_type attribute, att_type attribute2, const TEXT* text, cons
|
||||
else if (newlen <= MAX_USHORT)
|
||||
{
|
||||
if (!attribute2) // In theory, this never happens, because the caller knows what it's doing.
|
||||
BURP_error(314, "");
|
||||
BURP_error(314, true);
|
||||
put(tdgbl, attribute2);
|
||||
USHORT vax_value = (USHORT) newlen;
|
||||
vax_value = (USHORT) gds__vax_integer((const UCHAR*) &vax_value, sizeof(vax_value));
|
||||
put_block(tdgbl, (const UCHAR*) &vax_value, sizeof(vax_value));
|
||||
}
|
||||
else
|
||||
BURP_error(315, "");
|
||||
BURP_error(315, true);
|
||||
|
||||
if (newlen)
|
||||
put_block(tdgbl, reinterpret_cast<const UCHAR*>(text), newlen);
|
||||
@ -3978,7 +3978,7 @@ void write_shadow_files()
|
||||
* Write out files to use as shadows.
|
||||
*
|
||||
**************************************/
|
||||
TEXT temp[GDS_NAME_LEN];
|
||||
BASED ON RDB$FILES.RDB$FILE_NAME temp;
|
||||
isc_req_handle req_handle1 = 0;
|
||||
|
||||
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
|
||||
|
@ -65,7 +65,7 @@ static inline void BURP_free(void* block)
|
||||
MISC_free_burp(block);
|
||||
}
|
||||
|
||||
const int GDS_NAME_LEN = 32;
|
||||
const int GDS_NAME_LEN = METADATA_IDENTIFIER_CHAR_LEN * 4 /* max bytes per char */ + 1;
|
||||
typedef TEXT GDS_NAME[GDS_NAME_LEN];
|
||||
|
||||
enum redirect_vals {
|
||||
|
@ -335,12 +335,14 @@ SSHORT TextType::compare(ULONG len1, const UCHAR* str1, ULONG len2, const UCHAR*
|
||||
len2, Firebird::Aligner<USHORT>(str2, len2), &error_flag);
|
||||
}
|
||||
|
||||
SSHORT cmp = memcmp(str1, str2, MIN(len1, len2));
|
||||
int cmp = memcmp(str1, str2, MIN(len1, len2));
|
||||
|
||||
if (cmp == 0)
|
||||
cmp = (len1 < len2 ? -1 : (len1 > len2 ? 1 : 0));
|
||||
else
|
||||
cmp = (cmp < 0 ? -1 : 1);
|
||||
|
||||
return cmp;
|
||||
return (SSHORT) cmp;
|
||||
}
|
||||
|
||||
|
||||
|
@ -615,7 +615,7 @@ static void string_to_datetime(const dsc* desc,
|
||||
|
||||
while (++p < end)
|
||||
{
|
||||
if (*p != ' ' && *p != '\t' && *p != 0)
|
||||
if (*p != ' ' && *p != '\t' && *p != '\0')
|
||||
CVT_conversion_error(desc, err);
|
||||
}
|
||||
|
||||
@ -699,7 +699,7 @@ static void string_to_datetime(const dsc* desc,
|
||||
// We won't allow random trash after the recognized string
|
||||
while (p < end)
|
||||
{
|
||||
if (*p != ' ' && *p != '\t' && p != 0)
|
||||
if (*p != ' ' && *p != '\t' && *p != '\0')
|
||||
{
|
||||
CVT_conversion_error(desc, err);
|
||||
return;
|
||||
|
@ -2811,7 +2811,7 @@ static bool initializeFastMutex(FAST_MUTEX* lpMutex, LPSECURITY_ATTRIBUTES lpAtt
|
||||
|
||||
LPCSTR name = lpName;
|
||||
|
||||
if (strlen(lpName) + strlen(FAST_MUTEX_EVT_NAME) - 2 >= MAXPATHLEN)
|
||||
if (lpName && strlen(lpName) + strlen(FAST_MUTEX_EVT_NAME) - 2 >= MAXPATHLEN)
|
||||
{
|
||||
// this is the same error which CreateEvent will return for long name
|
||||
SetLastError(ERROR_FILENAME_EXCED_RANGE);
|
||||
@ -2896,7 +2896,7 @@ static bool openFastMutex(FAST_MUTEX* lpMutex, DWORD DesiredAccess, LPCSTR lpNam
|
||||
{
|
||||
LPCSTR name = lpName;
|
||||
|
||||
if (strlen(lpName) + strlen(FAST_MUTEX_EVT_NAME) - 2 >= MAXPATHLEN)
|
||||
if (lpName && strlen(lpName) + strlen(FAST_MUTEX_EVT_NAME) - 2 >= MAXPATHLEN)
|
||||
{
|
||||
SetLastError(ERROR_FILENAME_EXCED_RANGE);
|
||||
return false;
|
||||
|
@ -214,9 +214,8 @@ static void asgn_from( ref* reference, int column)
|
||||
if (!field || field->fld_dtype == dtype_text)
|
||||
fprintf(gpreGlob.out_file, VTO_CALL, JRD_VTOF, value, variable,
|
||||
field ? field->fld_length : 0);
|
||||
else if (!field || field->fld_dtype == dtype_cstring)
|
||||
fprintf(gpreGlob.out_file, VTO_CALL, GDS_VTOV, value, variable,
|
||||
field ? field->fld_length : 0);
|
||||
else if (field->fld_dtype == dtype_cstring)
|
||||
fprintf(gpreGlob.out_file, VTO_CALL, GDS_VTOV, value, variable, field->fld_length);
|
||||
else
|
||||
fprintf(gpreGlob.out_file, "%s = %s;", variable, value);
|
||||
}
|
||||
@ -243,7 +242,7 @@ static void asgn_to( ref* reference)
|
||||
if (!field || field->fld_dtype == dtype_text)
|
||||
fprintf(gpreGlob.out_file, "gds__ftov (%s, %d, %s, sizeof(%s));",
|
||||
s, field ? field->fld_length : 0, reference->ref_value, reference->ref_value);
|
||||
else if (!field || field->fld_dtype == dtype_cstring)
|
||||
else if (field->fld_dtype == dtype_cstring)
|
||||
fprintf(gpreGlob.out_file, "gds__vtov((const char*) %s, (char*) %s, sizeof(%s));",
|
||||
s, reference->ref_value, reference->ref_value);
|
||||
else
|
||||
|
@ -4824,7 +4824,7 @@ static bool write_page(thread_db* tdbb, BufferDesc* bdb, FbStatusVector* const s
|
||||
BackupManager* bm = dbb->dbb_backup_manager;
|
||||
const int backup_state = bm->getState();
|
||||
|
||||
if (bdb->bdb_page.getPageNum() >= 0)
|
||||
/// ASF: Always true: if (bdb->bdb_page.getPageNum() >= 0)
|
||||
{
|
||||
fb_assert(backup_state != Ods::hdr_nbak_unknown);
|
||||
page->pag_pageno = bdb->bdb_page.getPageNum();
|
||||
|
@ -506,6 +506,8 @@ void IDX_create_index(thread_db* tdbb,
|
||||
if (!ifl_data.ifl_duplicates)
|
||||
scb->sort(tdbb);
|
||||
|
||||
// ASF: We have a callback accessing ifl_data, so don't join above and below if's.
|
||||
|
||||
if (!ifl_data.ifl_duplicates)
|
||||
BTR_create(tdbb, creation, selectivity);
|
||||
|
||||
|
@ -777,9 +777,6 @@ void Trigger::compile(thread_db* tdbb)
|
||||
|
||||
if (!statement /*&& !compile_in_progress*/)
|
||||
{
|
||||
if (statement)
|
||||
return;
|
||||
|
||||
compile_in_progress = true;
|
||||
// Allocate statement memory pool
|
||||
MemoryPool* new_pool = att->createPool();
|
||||
|
@ -1895,7 +1895,7 @@ THREAD_ENTRY_DECLARE Service::run(THREAD_ENTRY_PARAM arg)
|
||||
{
|
||||
Service* svc = (Service*)arg;
|
||||
RefPtr<SvcMutex> ref(svc->svc_existence);
|
||||
int exit_code = svc->svc_service_run->serv_thd(svc);
|
||||
exit_code = svc->svc_service_run->serv_thd(svc);
|
||||
|
||||
svc->started();
|
||||
svc->svc_sem_full.release();
|
||||
|
@ -2228,7 +2228,7 @@ bool XnetServerEndPoint::server_init(USHORT flag)
|
||||
|
||||
make_obj_name(name_buffer, sizeof(name_buffer), XNET_CONNECT_MUTEX);
|
||||
xnet_connect_mutex = CreateMutex(ISC_get_security_desc(), FALSE, name_buffer);
|
||||
if (!xnet_connect_mutex || (xnet_connect_mutex && ERRNO == ERROR_ALREADY_EXISTS))
|
||||
if (!xnet_connect_mutex || ERRNO == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
system_error::raise(ERR_STR("CreateMutex"));
|
||||
}
|
||||
@ -2530,7 +2530,7 @@ rem_port* XnetServerEndPoint::get_server_port(ULONG client_pid,
|
||||
{
|
||||
if (port)
|
||||
cleanup_port(port);
|
||||
else if (xcc)
|
||||
else
|
||||
cleanup_comm(xcc);
|
||||
|
||||
throw;
|
||||
|
Loading…
Reference in New Issue
Block a user