1
0
Fork 0

fix/work around some gcc Wall warnings

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3192
This commit is contained in:
Sebastian Strohhäcker 2008-08-06 18:34:21 +00:00
parent 3d40069e4a
commit c78a9f6c03
41 changed files with 280 additions and 219 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2002-2007 The DOSBox Team
* Copyright (C) 2002-2008 The DOSBox Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: cdrom_aspi_win32.cpp,v 1.18 2007-06-12 20:22:07 c2woody Exp $ */
/* $Id: cdrom_aspi_win32.cpp,v 1.19 2008-08-06 18:32:34 c2woody Exp $ */
#if defined (WIN32)
@ -158,19 +158,23 @@ bool CDROM_Interface_Aspi::ScanRegistryFindKey(HKEY& hKeyBase)
// Open Key...
newKeyResult = RegOpenKeyEx (hKeyBase,subKey,0,KEY_READ,&hNewKey);
if (newKeyResult==ERROR_SUCCESS) {
if (GetRegistryValue(hNewKey,"CurrentDriveLetterAssignment",buffer,256)) {
static const char drive_letter_assignment[] = "CurrentDriveLetterAssignment";
if (GetRegistryValue(hNewKey,(char*)&drive_letter_assignment,buffer,256)) {
LOG(LOG_MISC,LOG_NORMAL)("SCSI: Drive Letter found: %s",buffer);
// aha, something suspicious...
if (buffer[0]==letter) {
char hardwareID[256];
// found it... lets see if we can get the scsi values
bool v1 = GetRegistryValue(hNewKey,"SCSILUN",buffer,256);
static const char SCSI_LUN[] = "SCSILUN";
bool v1 = GetRegistryValue(hNewKey,(char*)SCSI_LUN,buffer,256);
LOG(LOG_MISC,LOG_NORMAL)("SCSI: SCSILUN found: %s",buffer);
lun = buffer[0]-'0';
bool v2 = GetRegistryValue(hNewKey,"SCSITargetID",buffer,256);
static const char SCSI_TargetID[] = "SCSITargetID";
bool v2 = GetRegistryValue(hNewKey,(char*)SCSI_TargetID,buffer,256);
LOG(LOG_MISC,LOG_NORMAL)("SCSI: SCSITargetID found: %s",buffer);
target = buffer[0]-'0';
bool v3 = GetRegistryValue(hNewKey,"HardwareID",hardwareID,256);
static const char Hardware_ID[] = "HardwareID";
bool v3 = GetRegistryValue(hNewKey,(char*)Hardware_ID,hardwareID,256);
RegCloseKey(hNewKey);
if (v1 && v2 && v3) {
haId = GetHostAdapter(hardwareID);

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_files.cpp,v 1.97 2008-05-28 09:53:31 qbix79 Exp $ */
/* $Id: dos_files.cpp,v 1.98 2008-08-06 18:32:34 c2woody Exp $ */
#include <string.h>
#include <stdlib.h>
@ -123,7 +123,7 @@ bool DOS_MakeName(char const * const name,char * const fullname,Bit8u * drive) {
continue;
}
Bit32s iDown, cDots;
Bit32s iDown;
bool dots = true;
Bit32s templen=(Bit32s)strlen(tempdir);
for(iDown=0;(iDown < templen) && dots;iDown++)
@ -131,13 +131,10 @@ bool DOS_MakeName(char const * const name,char * const fullname,Bit8u * drive) {
dots = false;
// only dots?
cDots = templen - 1;
if(dots && (cDots > 0))
{
for(iDown=(Bit32s)strlen(fullname)-1;iDown>=0;iDown--)
{
if(fullname[iDown]=='\\' || iDown==0)
{
if (dots && (templen > 1)) {
Bit32s cDots = templen - 1;
for(iDown=(Bit32s)strlen(fullname)-1;iDown>=0;iDown--) {
if(fullname[iDown]=='\\' || iDown==0) {
lastdir = iDown;
cDots--;
if(cDots==0)

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_keyboard_layout.cpp,v 1.12 2008-06-30 20:32:37 c2woody Exp $ */
/* $Id: dos_keyboard_layout.cpp,v 1.13 2008-08-06 18:32:34 c2woody Exp $ */
#include "dosbox.h"
#include "bios.h"
@ -249,38 +249,39 @@ Bitu keyboard_layout::read_keyboard_file(const char* keyboard_file_name, Bit32s
Bit32u start_pos=5;
char nbuf[512];
read_buf_size = 0;
sprintf(nbuf, "%s.kl", keyboard_file_name);
FILE* tempfile = OpenDosboxFile(nbuf);
if (tempfile==NULL) {
// try keyboard layout libraries next
if (start_pos=read_kcl_file("keyboard.sys",keyboard_file_name,true)) {
if ((start_pos=read_kcl_file("keyboard.sys",keyboard_file_name,true))) {
tempfile = OpenDosboxFile("keyboard.sys");
} else if (start_pos=read_kcl_file("keybrd2.sys",keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_file("keybrd2.sys",keyboard_file_name,true))) {
tempfile = OpenDosboxFile("keybrd2.sys");
} else if (start_pos=read_kcl_file("keybrd3.sys",keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_file("keybrd3.sys",keyboard_file_name,true))) {
tempfile = OpenDosboxFile("keybrd3.sys");
} else if (start_pos=read_kcl_file("keyboard.sys",keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_file("keyboard.sys",keyboard_file_name,false))) {
tempfile = OpenDosboxFile("keyboard.sys");
} else if (start_pos=read_kcl_file("keybrd2.sys",keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_file("keybrd2.sys",keyboard_file_name,false))) {
tempfile = OpenDosboxFile("keybrd2.sys");
} else if (start_pos=read_kcl_file("keybrd3.sys",keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_file("keybrd3.sys",keyboard_file_name,false))) {
tempfile = OpenDosboxFile("keybrd3.sys");
} else if (start_pos=read_kcl_data(layout_keyboardsys,33196,keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_data(layout_keyboardsys,33196,keyboard_file_name,true))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<33196; ct++) read_buf[read_buf_size++]=layout_keyboardsys[ct];
} else if (start_pos=read_kcl_data(layout_keybrd2sys,25431,keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_data(layout_keybrd2sys,25431,keyboard_file_name,true))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<25431; ct++) read_buf[read_buf_size++]=layout_keybrd2sys[ct];
} else if (start_pos=read_kcl_data(layout_keybrd3sys,27122,keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_data(layout_keybrd3sys,27122,keyboard_file_name,true))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<27122; ct++) read_buf[read_buf_size++]=layout_keybrd3sys[ct];
} else if (start_pos=read_kcl_data(layout_keyboardsys,33196,keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_data(layout_keyboardsys,33196,keyboard_file_name,false))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<33196; ct++) read_buf[read_buf_size++]=layout_keyboardsys[ct];
} else if (start_pos=read_kcl_data(layout_keybrd2sys,25431,keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_data(layout_keybrd2sys,25431,keyboard_file_name,false))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<25431; ct++) read_buf[read_buf_size++]=layout_keybrd2sys[ct];
} else if (start_pos=read_kcl_data(layout_keybrd3sys,27122,keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_data(layout_keybrd3sys,27122,keyboard_file_name,false))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<27122; ct++) read_buf[read_buf_size++]=layout_keybrd3sys[ct];
} else {
@ -598,34 +599,34 @@ Bit16u keyboard_layout::extract_codepage(const char* keyboard_file_name) {
FILE* tempfile = OpenDosboxFile(nbuf);
if (tempfile==NULL) {
// try keyboard layout libraries next
if (start_pos=read_kcl_file("keyboard.sys",keyboard_file_name,true)) {
if ((start_pos=read_kcl_file("keyboard.sys",keyboard_file_name,true))) {
tempfile = OpenDosboxFile("keyboard.sys");
} else if (start_pos=read_kcl_file("keybrd2.sys",keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_file("keybrd2.sys",keyboard_file_name,true))) {
tempfile = OpenDosboxFile("keybrd2.sys");
} else if (start_pos=read_kcl_file("keybrd3.sys",keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_file("keybrd3.sys",keyboard_file_name,true))) {
tempfile = OpenDosboxFile("keybrd3.sys");
} else if (start_pos=read_kcl_file("keyboard.sys",keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_file("keyboard.sys",keyboard_file_name,false))) {
tempfile = OpenDosboxFile("keyboard.sys");
} else if (start_pos=read_kcl_file("keybrd2.sys",keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_file("keybrd2.sys",keyboard_file_name,false))) {
tempfile = OpenDosboxFile("keybrd2.sys");
} else if (start_pos=read_kcl_file("keybrd3.sys",keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_file("keybrd3.sys",keyboard_file_name,false))) {
tempfile = OpenDosboxFile("keybrd3.sys");
} else if (start_pos=read_kcl_data(layout_keyboardsys,33196,keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_data(layout_keyboardsys,33196,keyboard_file_name,true))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<33196; ct++) read_buf[read_buf_size++]=layout_keyboardsys[ct];
} else if (start_pos=read_kcl_data(layout_keybrd2sys,25431,keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_data(layout_keybrd2sys,25431,keyboard_file_name,true))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<25431; ct++) read_buf[read_buf_size++]=layout_keybrd2sys[ct];
} else if (start_pos=read_kcl_data(layout_keybrd3sys,27122,keyboard_file_name,true)) {
} else if ((start_pos=read_kcl_data(layout_keybrd3sys,27122,keyboard_file_name,true))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<27122; ct++) read_buf[read_buf_size++]=layout_keybrd3sys[ct];
} else if (start_pos=read_kcl_data(layout_keyboardsys,33196,keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_data(layout_keyboardsys,33196,keyboard_file_name,false))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<33196; ct++) read_buf[read_buf_size++]=layout_keyboardsys[ct];
} else if (start_pos=read_kcl_data(layout_keybrd2sys,25431,keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_data(layout_keybrd2sys,25431,keyboard_file_name,false))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<25431; ct++) read_buf[read_buf_size++]=layout_keybrd2sys[ct];
} else if (start_pos=read_kcl_data(layout_keybrd3sys,27122,keyboard_file_name,false)) {
} else if ((start_pos=read_kcl_data(layout_keybrd3sys,27122,keyboard_file_name,false))) {
read_buf_size=0;
for (Bitu ct=start_pos+2; ct<27122; ct++) read_buf[read_buf_size++]=layout_keybrd3sys[ct];
} else {
@ -992,11 +993,11 @@ void keyboard_layout::switch_foreign_layout() {
static keyboard_layout* loaded_layout=NULL;
// CTRL-ALT-F2 switches between foreign and US-layout using this function
static void switch_keyboard_layout(bool pressed) {
/* static void switch_keyboard_layout(bool pressed) {
if (!pressed)
return;
if (loaded_layout) loaded_layout->switch_foreign_layout();
}
} */
// called by int9-handler
bool DOS_LayoutKey(Bitu key, Bit8u flags1, Bit8u flags2, Bit8u flags3) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2002-2007 The DOSBox Team
* Copyright (C) 2002-2008 The DOSBox Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_misc.cpp,v 1.18 2007-11-07 22:08:03 c2woody Exp $ */
/* $Id: dos_misc.cpp,v 1.19 2008-08-06 18:32:34 c2woody Exp $ */
#include "dosbox.h"
#include "callback.h"
@ -116,8 +116,7 @@ static bool DOS_MultiplexFunctions(void) {
size_t nlen=strlen(filename);
size_t extlen=strlen(dotpos);
Bits nmelen=(Bits)nlen-(Bits)extlen;
nmelen--;
if (nmelen<0) return true;
if (nmelen<1) return true;
nlen-=(extlen+1);
if (nlen>8) nlen=8;

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_mscdex.cpp,v 1.53 2008-02-19 17:45:33 c2woody Exp $ */
/* $Id: dos_mscdex.cpp,v 1.54 2008-08-06 18:32:34 c2woody Exp $ */
#include <string.h>
#include <ctype.h>
@ -247,7 +247,7 @@ int CMscdex::RemoveDrive(Bit16u _drive)
int CMscdex::AddDrive(Bit16u _drive, char* physicalPath, Bit8u& subUnit)
{
subUnit = 0;
if (GetNumDrives()+1>=MSCDEX_MAX_DRIVES) return 4;
if ((Bitu)GetNumDrives()+1>=MSCDEX_MAX_DRIVES) return 4;
if (GetNumDrives()) {
// Error check, driveletter have to be in a row
if (dinfo[0].drive-1!=_drive && dinfo[numDrives-1].drive+1!=_drive)
@ -902,7 +902,7 @@ static Bit16u MSCDEX_IOCTL_Input(PhysPt buffer,Bit8u drive_unit) {
break;
case 0x0A : /* Get Audio Disk info */
Bit8u tr1,tr2; TMSF leadOut;
mscdex->GetCDInfo(drive_unit,tr1,tr2,leadOut);
if (!mscdex->GetCDInfo(drive_unit,tr1,tr2,leadOut)) return 0x05;
mem_writeb(buffer+1,tr1);
mem_writeb(buffer+2,tr2);
mem_writeb(buffer+3,leadOut.fr);

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_programs.cpp,v 1.85 2008-03-11 18:16:34 c2woody Exp $ */
/* $Id: dos_programs.cpp,v 1.86 2008-08-06 18:32:34 c2woody Exp $ */
#include "dosbox.h"
#include <stdlib.h>
@ -976,8 +976,8 @@ public:
WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
return;
}
DOS_Drive * newdrive;
imageDisk * newImage;
DOS_Drive * newdrive = NULL;
imageDisk * newImage = NULL;
Bit32u imagesize;
char drive;
std::string label;
@ -1050,27 +1050,27 @@ public:
if(fstype=="fat" || fstype=="iso") {
// get the drive letter
if (!cmd->FindCommand(1,temp_line) || (temp_line.size() > 2) || ((temp_line.size()>1) && (temp_line[1]!=':'))) {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY_DRIVE"));
WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY_DRIVE"));
return;
}
drive=toupper(temp_line[0]);
if (!isalpha(drive)) {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY_DRIVE"));
WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY_DRIVE"));
return;
}
} else if (fstype=="none") {
cmd->FindCommand(1,temp_line);
if ((temp_line.size() > 1) || (!isdigit(temp_line[0]))) {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY2"));
WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY2"));
return;
}
drive=temp_line[0];
if((drive-'0')>3) {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY2"));
if ((drive<'0') || (drive>3+'0')) {
WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY2"));
return;
}
} else {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_FORMAT_UNSUPPORTED"));
WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_FORMAT_UNSUPPORTED"));
return;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2002-2007 The DOSBox Team
* Copyright (C) 2002-2008 The DOSBox Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_tables.cpp,v 1.29 2007-07-20 18:53:52 qbix79 Exp $ */
/* $Id: dos_tables.cpp,v 1.30 2008-08-06 18:32:34 c2woody Exp $ */
#include "dosbox.h"
#include "mem.h"
@ -43,7 +43,7 @@ static Bitu call_casemap;
static Bit16u dos_memseg=DOS_PRIVATE_SEGMENT;
Bit16u DOS_GetMemory(Bit16u pages) {
if (pages+dos_memseg>=DOS_PRIVATE_SEGMENT_END) {
if ((Bitu)pages+(Bitu)dos_memseg>=DOS_PRIVATE_SEGMENT_END) {
E_Exit("DOS:Not enough memory for internal tables");
}
Bit16u page=dos_memseg;

View file

@ -1,6 +1,5 @@
/*
* Copyright (C) 2002-2007 The DOSBox Team
* Copyright (C) 2002-2008 The DOSBox Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: drive_cache.cpp,v 1.52 2007-11-02 07:50:27 qbix79 Exp $ */
/* $Id: drive_cache.cpp,v 1.53 2008-08-06 18:32:34 c2woody Exp $ */
#include "drives.h"
#include "dos_inc.h"
@ -193,7 +192,7 @@ char* DOS_Drive_Cache::GetExpandName(const char* path)
strcat(work,dir);
}
if(work && *work) {
if (*work) {
size_t len = strlen(work);
#if defined (WIN32)
if((work[len-1] == CROSS_FILESPLIT ) && (len >= 2) && (work[len-2] != ':')) {

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: drive_fat.cpp,v 1.25 2008-02-24 17:38:03 c2woody Exp $ */
/* $Id: drive_fat.cpp,v 1.26 2008-08-06 18:32:34 c2woody Exp $ */
#include <stdio.h>
#include <stdlib.h>
@ -866,25 +866,22 @@ bool fatDrive::FindFirst(char *_dir, DOS_DTA &dta,bool /*fcb_findfirst*/) {
return FindNextInternal(cwdDirCluster, dta, &dummyClust);
}
char* removeTrailingSpaces(char* str)
{
char* end = str + strlen(str);
while(*--end == ' ' && end > str);
*++end = '\0';
return str;
char* removeTrailingSpaces(char* str) {
char* end = str + strlen(str);
while((*--end == ' ') && (end > str)) {};
*++end = '\0';
return str;
}
char* removeLeadingSpaces(char* str)
{
size_t len = strlen(str);
size_t pos = strspn(str," ");
memmove(str,str + pos,len - pos + 1);
return str;
char* removeLeadingSpaces(char* str) {
size_t len = strlen(str);
size_t pos = strspn(str," ");
memmove(str,str + pos,len - pos + 1);
return str;
}
char* trimString(char* str)
{
return removeTrailingSpaces(removeLeadingSpaces(str));
char* trimString(char* str) {
return removeTrailingSpaces(removeLeadingSpaces(str));
}
bool fatDrive::FindNextInternal(Bit32u dirClustNumber, DOS_DTA &dta, direntry *foundEntry) {