8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 06:43:04 +01:00
This commit is contained in:
robocop 2008-03-05 08:39:26 +00:00
parent 528eefabbf
commit c6d8b0f46f
17 changed files with 140 additions and 191 deletions

View File

@ -809,7 +809,7 @@ USHORT METD_get_domain_default(dsql_req* request,
*ptr_in_buffer = 0;
break;
}
else if (blob_handle->blb_fragment_size)
if (blob_handle->blb_fragment_size)
Firebird::status_exception::raise(isc_segment, 0);
else
continue;

View File

@ -2275,7 +2275,7 @@ static processing_state add_row(TEXT* tabname)
if (ivar->sqlscale < 0)
{
SSHORT lscale = 0;
if (get_numeric((UCHAR*) lastInputLine, length, &lscale, &n) != true) {
if (!get_numeric((UCHAR*) lastInputLine, length, &lscale, &n)) {
STDERROUT("Input parsing problem");
done = true;
}
@ -3083,7 +3083,7 @@ static processing_state bulk_insert_hack(const char* command, XSQLDA** sqldap)
if (ivar->sqlscale < 0)
{
SSHORT lscale = 0;
if (get_numeric((UCHAR*) lastPos, length, &lscale, &n) != true)
if (!get_numeric((UCHAR*) lastPos, length, &lscale, &n))
{
STDERROUT("Input parsing problem in 'numeric' or 'decimal' value");
done = true;

View File

@ -1234,7 +1234,7 @@ static rem_port* alloc_port( rem_port* parent)
}
#endif
if (first_time == true)
if (first_time)
{
INET_remote_buffer = Config::getTcpRemoteBufferSize();
if (INET_remote_buffer < MAX_DATA_LW ||

View File

@ -565,13 +565,12 @@ BOOL ValidateUser(HWND hParentWnd)
PrintCfgStatus(NULL, IDS_CFGNOT_SYSDBA, hParentWnd);
return FALSE;
}
else {
szSysDbaPasswd[0] = '\0';
return (DialogBox
((HINSTANCE) GetWindowLongPtr(hParentWnd, GWLP_HINSTANCE),
MAKEINTRESOURCE(PASSWORD_DLG), hParentWnd,
(DLGPROC) PasswordDlgProc) > 0);
}
szSysDbaPasswd[0] = '\0';
return (DialogBox
((HINSTANCE) GetWindowLongPtr(hParentWnd, GWLP_HINSTANCE),
MAKEINTRESOURCE(PASSWORD_DLG), hParentWnd,
(DLGPROC) PasswordDlgProc) > 0);
}
BOOL CALLBACK PasswordDlgProc(HWND hDlg, UINT unMsg, WPARAM wParam,
@ -616,9 +615,7 @@ BOOL CALLBACK PasswordDlgProc(HWND hDlg, UINT unMsg, WPARAM wParam,
if (wParam == IDOK) {
char szPassword[PASSWORD_LEN];
ISC_STATUS_ARRAY pdwStatus;
isc_svc_handle hService = NULL;
char szSpb[SPB_BUFLEN];
HCURSOR hOldCursor = NULL;
szPassword[0] = '\0';
@ -628,7 +625,8 @@ BOOL CALLBACK PasswordDlgProc(HWND hDlg, UINT unMsg, WPARAM wParam,
FillSysdbaSPB(szSpb, szPassword);
// Attach service to check for password validity
hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
isc_svc_handle hService = NULL;
isc_service_attach(pdwStatus, 0, "query_server",
&hService, (USHORT) strlen(szSpb), szSpb);
SetCursor(hOldCursor);
@ -648,18 +646,14 @@ BOOL CALLBACK PasswordDlgProc(HWND hDlg, UINT unMsg, WPARAM wParam,
SetFocus(GetDlgItem(hDlg, IDC_DBAPASSWORD));
return TRUE;
}
else {
if (wParam == IDCANCEL) {
EndDialog(hDlg, 0);
return TRUE;
}
}
break;
case WM_CLOSE:
{
if (wParam == IDCANCEL) {
EndDialog(hDlg, 0);
return TRUE;
}
break;
case WM_CLOSE:
EndDialog(hDlg, 0);
return TRUE;
default:
return FALSE;
}

View File

@ -1115,24 +1115,23 @@ static bool_t wnet_getbytes( XDR * xdrs, SCHAR * buff, u_int count)
/* Use memcpy to optimize bulk transfers. */
while (bytecount > (SLONG) sizeof(ISC_QUAD)) {
while (bytecount > (SLONG) sizeof(ISC_QUAD))
{
if (xdrs->x_handy >= bytecount) {
memcpy(buff, xdrs->x_private, bytecount);
xdrs->x_private += bytecount;
xdrs->x_handy -= bytecount;
return TRUE;
}
else {
if (xdrs->x_handy > 0) {
memcpy(buff, xdrs->x_private, xdrs->x_handy);
xdrs->x_private += xdrs->x_handy;
buff += xdrs->x_handy;
bytecount -= xdrs->x_handy;
xdrs->x_handy = 0;
}
if (!wnet_read(xdrs))
return FALSE;
if (xdrs->x_handy > 0) {
memcpy(buff, xdrs->x_private, xdrs->x_handy);
xdrs->x_private += xdrs->x_handy;
buff += xdrs->x_handy;
bytecount -= xdrs->x_handy;
xdrs->x_handy = 0;
}
if (!wnet_read(xdrs))
return FALSE;
}
/* Scalar values and bulk transfer remainder fall thru
@ -1243,17 +1242,15 @@ static bool_t wnet_putbytes( XDR* xdrs, const SCHAR* buff, u_int count)
xdrs->x_handy -= bytecount;
return TRUE;
}
else {
if (xdrs->x_handy > 0) {
memcpy(xdrs->x_private, buff, xdrs->x_handy);
xdrs->x_private += xdrs->x_handy;
buff += xdrs->x_handy;
bytecount -= xdrs->x_handy;
xdrs->x_handy = 0;
}
if (!wnet_write(xdrs, 0))
return FALSE;
if (xdrs->x_handy > 0) {
memcpy(xdrs->x_private, buff, xdrs->x_handy);
xdrs->x_private += xdrs->x_handy;
buff += xdrs->x_handy;
bytecount -= xdrs->x_handy;
xdrs->x_handy = 0;
}
if (!wnet_write(xdrs, 0))
return FALSE;
}
/* Scalar values and bulk transfer remainder fall thru
@ -1499,8 +1496,7 @@ static int packet_send( rem_port* port, const SCHAR* buffer, SSHORT buffer_lengt
if (!status)
return wnet_error(port, "WriteFile", isc_net_write_err, ERRNO);
if (n != length)
return wnet_error(port, "WriteFile truncated", isc_net_write_err,
ERRNO);
return wnet_error(port, "WriteFile truncated", isc_net_write_err, ERRNO);
#if defined(DEBUG) && defined(WNET_trace)
packet_print("send", (UCHAR*)buffer, buffer_length);

View File

@ -746,7 +746,7 @@ int xdr_union( XDR* xdrs,
// can have any size.
int enum_value = *dscmp;
const bool_t bOK = xdr_int(xdrs, &enum_value);
*dscmp = static_cast < enum_t >(enum_value);
*dscmp = static_cast<enum_t>(enum_value);
if (!bOK)
{

View File

@ -1548,10 +1548,9 @@ static int send_full( rem_port* port, PACKET * packet)
if (xnet_write(&port->port_send))
return TRUE;
else {
xnet_error(port, isc_net_write_err, ERRNO);
return FALSE;
}
xnet_error(port, isc_net_write_err, ERRNO);
return FALSE;
}
@ -1768,10 +1767,7 @@ static bool_t xnet_getbytes(XDR * xdrs, SCHAR * buff, u_int count)
}
}
if (xnet_shutdown)
return FALSE;
else
return TRUE;
return xnet_shutdown ? FALSE : TRUE;
}
@ -1870,7 +1866,8 @@ static bool_t xnet_putbytes(XDR* xdrs, const SCHAR* buff, u_int count)
if ((ULONG) xdrs->x_handy == xch->xch_size) {
while (!xnet_shutdown) {
while (!xnet_shutdown)
{
#ifdef SUPERCLIENT
if (xpm->xpm_flags & XPMF_SERVER_SHUTDOWN) {
@ -1891,29 +1888,28 @@ static bool_t xnet_putbytes(XDR* xdrs, const SCHAR* buff, u_int count)
THREAD_ENTER();
break;
}
else if (wait_result == WAIT_TIMEOUT) {
if (wait_result == WAIT_TIMEOUT)
{
// Check whether another side is alive
if (WaitForSingleObject(xcc->xcc_proc_h, 1) == WAIT_TIMEOUT) {
THREAD_ENTER();
continue; // another side is alive
}
else {
THREAD_ENTER();
// Another side is dead or something bad has happened
#ifdef SUPERCLIENT
server_shutdown(port);
xnet_error(port, isc_lost_db_connection, 0);
#else
xnet_error(port, isc_conn_lost, 0);
#endif
return FALSE;
}
}
else {
THREAD_ENTER();
xnet_error(port, isc_net_write_err, ERRNO);
return FALSE; // a non-timeout result is an error
// Another side is dead or something bad has happened
#ifdef SUPERCLIENT
server_shutdown(port);
xnet_error(port, isc_lost_db_connection, 0);
#else
xnet_error(port, isc_conn_lost, 0);
#endif
return FALSE;
}
THREAD_ENTER();
xnet_error(port, isc_net_write_err, ERRNO);
return FALSE; // a non-timeout result is an error
}
}
@ -1938,10 +1934,7 @@ static bool_t xnet_putbytes(XDR* xdrs, const SCHAR* buff, u_int count)
}
}
if (xnet_shutdown)
return FALSE;
else
return TRUE;
return xnet_shutdown ? FALSE : TRUE;
}
@ -2005,36 +1998,35 @@ static bool_t xnet_read(XDR * xdrs)
WaitForSingleObject(xcc->xcc_event_recv_channel_filled,
XNET_RECV_WAIT_TIMEOUT);
if (wait_result == WAIT_OBJECT_0) {
if (wait_result == WAIT_OBJECT_0)
{
THREAD_ENTER();
// Client has written some data for us (server) to read
xdrs->x_handy = xch->xch_length;
xdrs->x_private = xdrs->x_base;
return TRUE;
}
else if (wait_result == WAIT_TIMEOUT) {
if (wait_result == WAIT_TIMEOUT)
{
// Check if another side is alive
if (WaitForSingleObject(xcc->xcc_proc_h, 1) == WAIT_TIMEOUT) {
THREAD_ENTER();
continue; // another side is alive
}
else {
THREAD_ENTER();
// Another side is dead or something bad has happened
#ifdef SUPERCLIENT
server_shutdown(port);
xnet_error(port, isc_lost_db_connection, 0);
#else
xnet_error(port, isc_conn_lost, 0);
#endif
return FALSE;
}
}
else {
THREAD_ENTER();
xnet_error(port, isc_net_read_err, ERRNO);
return FALSE; // a non-timeout result is an error
// Another side is dead or something bad has happened
#ifdef SUPERCLIENT
server_shutdown(port);
xnet_error(port, isc_lost_db_connection, 0);
#else
xnet_error(port, isc_conn_lost, 0);
#endif
return FALSE;
}
THREAD_ENTER();
xnet_error(port, isc_net_read_err, ERRNO);
return FALSE; // a non-timeout result is an error
}
return FALSE;
@ -2062,12 +2054,10 @@ static bool_t xnet_write(XDR * xdrs)
if (SetEvent(xcc->xcc_event_send_channel_filled)) {
xdrs->x_private = xdrs->x_base;
xdrs->x_handy = xch->xch_size;
return TRUE;
}
else
return FALSE;
return FALSE;
}
@ -2196,27 +2186,27 @@ static XPM make_xpm(ULONG map_number, ULONG timestamp)
try {
XPM xpm = (XPM) ALLR_alloc(sizeof(struct xpm));
XPM xpm = (XPM) ALLR_alloc(sizeof(struct xpm));
xpm->xpm_handle = map_handle;
xpm->xpm_address = map_address;
xpm->xpm_number = map_number;
xpm->xpm_count = 0;
xpm->xpm_timestamp = timestamp;
xpm->xpm_handle = map_handle;
xpm->xpm_address = map_address;
xpm->xpm_number = map_number;
xpm->xpm_count = 0;
xpm->xpm_timestamp = timestamp;
for (USHORT i = 0; i < global_slots_per_map; i++) {
xpm->xpm_ids[i] = XPM_FREE;
}
xpm->xpm_flags = 0;
for (USHORT i = 0; i < global_slots_per_map; i++) {
xpm->xpm_ids[i] = XPM_FREE;
}
xpm->xpm_flags = 0;
XNET_LOCK();
XNET_LOCK();
xpm->xpm_next = global_client_maps;
global_client_maps = xpm;
xpm->xpm_next = global_client_maps;
global_client_maps = xpm;
XNET_UNLOCK();
XNET_UNLOCK();
return xpm;
return xpm;
}
catch (const Firebird::Exception&) {

View File

@ -289,8 +289,7 @@ static int shm_exclusive( SLONG key, SLONG length)
struct shmid_ds buf;
const int id = shmget(key, (int) length, IPC_ALLOC);
if (id == -1 ||
shmctl(id, IPC_STAT, &buf) == -1 || buf.shm_nattch != 1)
if (id == -1 || shmctl(id, IPC_STAT, &buf) == -1 || buf.shm_nattch != 1)
{
return -1;
}

View File

@ -137,7 +137,7 @@ BOOL CFBDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_Reset_Display_To_Existing_Values = TRUE;
m_Reset_Display_To_Existing_Values = true;
fb_status.ServicesAvailable = ServiceSupportAvailable();
if ( fb_status.ServicesAvailable )
@ -278,10 +278,7 @@ bool CFBDialog::ValidateInstalledServices()
fb_status.UseGuardian =
CheckServiceInstalled(GetServiceName(ISCGUARD_SERVICE));
if (!fb_status.UseService && fb_status.UseGuardian)
return false;
else
return true;
return (!fb_status.UseService && fb_status.UseGuardian) ? false : true;
}
CString CFBDialog::GetServiceName(const char* name) const
@ -641,7 +638,7 @@ void CFBDialog::ApplyChanges()
}
// If we haven't had a failure then we disable the apply button
if ( m_Reset_Display_To_Existing_Values == false )
if (!m_Reset_Display_To_Existing_Values)
DisableApplyButton();
// Update fb_status if we are running as an application
@ -961,8 +958,8 @@ bool CFBDialog::ServiceInstall( CFBDialog::STATUS status )
CloseServiceManager();
return true;
}
else
return false;
return false;
}
@ -994,8 +991,8 @@ bool CFBDialog::ServiceRemove()
CloseServiceManager();
return true;
}
else
return false;
return false;
}
@ -1044,30 +1041,22 @@ bool CFBDialog::ConfigureRegistryForApp(CFBDialog::STATUS status)
0, KEY_QUERY_VALUE | KEY_WRITE, &hkey) == ERROR_SUCCESS)
{
if (RegQueryValueEx(hkey, "Firebird", NULL, NULL, NULL, NULL)
== ERROR_SUCCESS)
if (RegQueryValueEx(hkey, "Firebird", NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{
if (RegDeleteValue(hkey, "Firebird") == ERROR_SUCCESS)
return true;
else
{
HandleError(false, "Removing registry entry to stop autorun failed.");
return false;
}
}
else
{
// If an error is thrown it must be because there is no
// entry in the registry so we shouldn't need to show an error.
return true;
HandleError(false, "Removing registry entry to stop autorun failed.");
return false;
}
// If an error is thrown it must be because there is no
// entry in the registry so we shouldn't need to show an error.
return true;
}
else
{
//Things are really bad - perhaps user has screwed up their registry?
HandleError(false, "Could not find HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run in the registry.");
return false;
}
//Things are really bad - perhaps user has screwed up their registry?
HandleError(false, "Could not find HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run in the registry.");
return false;
}
return true;
@ -1583,10 +1572,7 @@ bool CFBDialog::OpenServiceManager( DWORD DesiredAccess )
if (hScManager == NULL)
hScManager = OpenSCManager (NULL, SERVICES_ACTIVE_DATABASE, DesiredAccess );
if (hScManager)
return true;
else
return false;
return hScManager ? true : false;
}

View File

@ -434,7 +434,7 @@ void callRemoteServiceManager(ISC_STATUS* status,
{
if (*p == isc_info_data_not_ready)
continue;
else if (*p == isc_info_end)
if (*p == isc_info_end)
break;
}
p[len] = 0;

View File

@ -467,8 +467,7 @@ static bool get_line(Firebird::UtilSvc::ArgvType& argv, TEXT* stuff, size_t maxs
errno = 0;
continue;
}
else
return true;
return true;
}
}

View File

@ -151,11 +151,9 @@ int UTIL_wait_for_child(pid_t child_pid, const volatile sig_atomic_t& shutting_d
{
if (shutting_down)
return -2;
else
continue;
continue;
}
else
return (errno);
return (errno);
}
/* Check for very specific conditions before we assume the child

View File

@ -281,8 +281,7 @@ if (sw_service_gsec)
errno = 0;
continue;
}
else
return true;
return true;
}
}

View File

@ -118,14 +118,14 @@ USHORT SRVRMGR_exec_line(ibmgr_data_t* data)
/* Attached flag should be NULL after detach_service
*/
detach_service(data);
if (attach_service(data) == false)
if (!attach_service(data))
return MSG_ATTFAIL;
data->reattach = 0;
}
switch (data->operation) {
case OP_START:
if (start_server(data) == false)
if (!start_server(data))
return MSG_STARTFAIL;
break;
@ -134,7 +134,7 @@ USHORT SRVRMGR_exec_line(ibmgr_data_t* data)
case SOP_NONE:
case SOP_SHUT_NOW:
data->shutdown = true;
if (start_shutdown(data) == false) {
if (!start_shutdown(data)) {
data->shutdown = false;
return MSG_SSHUTFAIL;
}
@ -163,7 +163,7 @@ USHORT SRVRMGR_exec_line(ibmgr_data_t* data)
case OP_PRINT:
switch (data->suboperation) {
case SOP_PRINT_POOL:
if (print_pool(data) == false)
if (!print_pool(data))
return MSG_PRPOOLFAIL;
return MSG_PRPOOLOK;
}
@ -466,7 +466,7 @@ static bool start_server( ibmgr_data_t* data)
/* Let's see if server is already running, try to attach to it
*/
if (server_is_up(data) == true) {
if (server_is_up(data)) {
SRVRMGR_msg_get(MSG_SRVUP, msg);
fprintf(OUTFILE, "%s\n", msg);
return true;
@ -582,7 +582,7 @@ static bool start_server( ibmgr_data_t* data)
#ifdef DEBUG
printf("Attach retries left: %d\n", retry);
#endif
if (server_is_up(data) == true) {
if (server_is_up(data)) {
SRVRMGR_msg_get(MSG_SRVUPOK, msg);
fprintf(OUTFILE, "%s\n", msg);
return true;
@ -635,10 +635,7 @@ static bool server_is_up( ibmgr_data_t* data)
other reasons. For example, attach could return
not enough memory error. Let's take care of it.
*/
if (status[1] == isc_virmemexh)
up = true;
else
up = false;
up = (status[1] == isc_virmemexh);
}
isc_service_detach(status, &svc_handle);
return up;

View File

@ -187,8 +187,7 @@ USHORT CLIENT_install(const TEXT * rootdir, USHORT client, bool sw_force,
if (werr != ERROR_ALREADY_EXISTS)
{
DeleteFile(workfile);
return (*err_handler) (werr,
"MoveFile(_FBCLIENT.DLL, 'target')");
return (*err_handler) (werr, "MoveFile(_FBCLIENT.DLL, 'target')");
}
// Failed moving because a destination target file already exists
@ -264,8 +263,7 @@ USHORT CLIENT_install(const TEXT * rootdir, USHORT client, bool sw_force,
{
ULONG werr = GetLastError();
DeleteFile(workfile);
return (*err_handler) (werr,
"WritePrivateProfileString(delete 'target')");
return (*err_handler) (werr, "WritePrivateProfileString(delete 'target')");
}
if (WritePrivateProfileString("rename", starget, sworkfile,
@ -273,19 +271,16 @@ USHORT CLIENT_install(const TEXT * rootdir, USHORT client, bool sw_force,
{
ULONG werr = GetLastError();
DeleteFile(workfile);
return (*err_handler) (werr,
"WritePrivateProfileString(replace 'target')");
return (*err_handler) (werr, "WritePrivateProfileString(replace 'target')");
}
IncrementSharedCount(target, err_handler);
return FB_INSTALL_COPY_REQUIRES_REBOOT;
}
else
{
// Straight plain MoveFile succeeded immediately.
IncrementSharedCount(target, err_handler);
return FB_SUCCESS;
}
// Straight plain MoveFile succeeded immediately.
IncrementSharedCount(target, err_handler);
return FB_SUCCESS;
}
USHORT CLIENT_remove(const TEXT * rootdir, USHORT client, bool sw_force,
@ -754,17 +749,16 @@ USHORT DecrementSharedCount(const TEXT* filename, bool sw_force,
RegCloseKey(hkey);
return FB_SUCCESS;
}
else
status = RegDeleteValue(hkey, filename);
if (status != ERROR_SUCCESS)
{
status = RegDeleteValue(hkey, filename);
if (status != ERROR_SUCCESS)
{
RegCloseKey(hkey);
return (*err_handler) (status, "RegDeleteValue");
}
RegCloseKey(hkey);
return FB_INSTALL_SHARED_COUNT_ZERO;
return (*err_handler) (status, "RegDeleteValue");
}
RegCloseKey(hkey);
return FB_INSTALL_SHARED_COUNT_ZERO;
}
} // namespace { }

View File

@ -170,7 +170,6 @@ static void cleanup_key(HKEY hkey_rootnode, const char* key)
else
RegCloseKey(hkey);
}
return;
}
#ifdef THIS_CODE_IS_TEMPORARILY_NOT_USED_ANYMORE

View File

@ -891,13 +891,11 @@ void nbackup::restore_database(int filecount, const char* const* files)
delete[] page_buffer;
return;
}
else {
bakname = files[curLevel];
bakname = files[curLevel];
#ifdef WIN_NT
if (curLevel)
if (curLevel)
#endif
open_backup_scan();
}
open_backup_scan();
}
if (curLevel) {