Created a proper DEBUG build (specified using DEBUG=1). Set warnings to fatal for release builds and fixed the warnings throughout the code

This commit is contained in:
akuker 2020-07-10 17:49:02 -05:00
parent 853d37ea81
commit 32af6cf169
5 changed files with 43 additions and 34 deletions

View File

@ -3,16 +3,18 @@
CC = gcc
CXX = g++
# Debug CFLAGS
#CFLAGS = -DDISK_LOG -O0 -g -Wall
#CXXFLAGS = -DDISK_LOG -O0 -g -Wall
#CFLAGS = -O0 -g -Wall
#CXXFLAGS = -O0 -g -Wall
# Release CFLAGS
CFLAGS = -O3 -Wall
CXXFLAGS = -O3 -Wall
DEBUG ?= 0
ifeq ($(DEBUG), 1)
# Debug CFLAGS
CFLAGS = -DDISK_LOG -O0 -g -Wall -DDEBUG
CXXFLAGS = -DDISK_LOG -O0 -g -Wall -DDEBUG
BUILD_TYPE = Debug
else
# Release CFLAGS
CFLAGS ?= -O3 -Wall -Werror
CXXFLAGS ?= -O3 -Wall -Werror
BUILD_TYPE = Release
endif
# If its not specified, build for STANDARD configuration
CONNECT_TYPE ?= STANDARD
@ -76,10 +78,14 @@ OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP)
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
docs: $(DOC_DIR)/rascsi_man_page.txt $(DOC_DIR)/rasctl_man_page.txt
ALL: $(BIN_ALL) docs
.DEFAULT_GOAL := all
.PHONY: all ALL docs
all: $(BIN_ALL) docs
ALL: all
docs: $(DOC_DIR)/rascsi_man_page.txt $(DOC_DIR)/rasctl_man_page.txt
$(RASCSI): $(OBJ_RASCSI)
$(CXX) -o $@ $(OBJ_RASCSI) -lpthread

View File

@ -1894,7 +1894,7 @@ void CHostPath::Refresh()
if (stat(S2U(szPath), &sb))
#else
if (f_stat(S2U(szPath), NULL) != FR_OK)
#endif // BAREMETAL
#endif // BAREMETAL
break; // 利用可能パターンを発見
}
}
@ -1957,7 +1957,7 @@ void CHostPath::Refresh()
// 日付時刻
pFilename->SetEntryDate(fno.fdate);
pFilename->SetEntryTime(fno.ftime);
#endif // BAREMETAL
#endif // BAREMETAL
// クラスタ番号設定
pFilename->SetEntryCluster(0);
@ -2045,7 +2045,7 @@ void CHostPath::Backup()
m_tBackupT = fno.ftime;
}
}
#endif // BAREMETAL
#endif // BAREMETAL
}
//---------------------------------------------------------------------------
@ -2613,9 +2613,8 @@ void CHostFiles::AddFilename()
{
ASSERT(this);
ASSERT(strlen(m_szHostResult) + strlen((const char*)m_szHumanFilename) < FILEPATH_MAX);
/// @warning Unicode未対応。いずれUnicodeの世界に飮まれた時はここで変換を行なう → 済
strcat(m_szHostResult, (const char*)m_szHumanFilename);
strncat(m_szHostResult, (const char*)m_szHumanFilename, ARRAY_SIZE(m_szHumanFilename));
}
//===========================================================================
@ -2896,7 +2895,7 @@ BOOL CHostFcb::Open()
{
#ifndef BAREMETAL
struct stat st;
ASSERT(this);
ASSERT(strlen(m_szFilename) > 0);

View File

@ -1648,7 +1648,7 @@ int FASTCALL Disk::AddFormat(BOOL change, BYTE *buf)
buf[0] = 0x80 | 0x03;
buf[1] = 0x16;
// Show the number of bytes in the physical sector as changeable \
// Show the number of bytes in the physical sector as changeable
// (though it cannot be changed in practice)
if (change) {
buf[0xc] = 0xff;
@ -2709,7 +2709,7 @@ BOOL FASTCALL SCSIHD::ModeSelect(const DWORD *cdb, const BYTE *buf, int length)
case 0x08:
// Debug code for Issue #2:
// https://github.com/akuker/RASCSI/issues/2
printf("\[Unhandled page code\] Received mode page code 8 with total length %d\n ", length);
printf("[Unhandled page code] Received mode page code 8 with total length %d\n ", length);
for (int i = 0; i<length; i++)
{
printf("%02X ", buf[i]);
@ -7878,9 +7878,9 @@ void FASTCALL SASIDEV::FlushUnit()
// Debug code related to Issue #2 on github, where we get an unhandled Model select when
// the mac is rebooted
// https://github.com/akuker/RASCSI/issues/2
Log(Log::Warning, "Received \'Mode Select\' \[%02X\]\n");
Log(Log::Warning, " Operation Code: \[%02X\]\n", ctrl.cmd[0]);
Log(Log::Warning, " Logical Unit %01X, PF %01X, SP %01X \[%02X\]\n", ctrl.cmd[1] >> 5, 1 & (ctrl.cmd[1] >> 4), ctrl.cmd[1] & 1, ctrl.cmd[1]);
Log(Log::Warning, "Received \'Mode Select\'\n");
Log(Log::Warning, " Operation Code: [%02X]\n", ctrl.cmd[0]);
Log(Log::Warning, " Logical Unit %01X, PF %01X, SP %01X [%02X]\n", ctrl.cmd[1] >> 5, 1 & (ctrl.cmd[1] >> 4), ctrl.cmd[1] & 1, ctrl.cmd[1]);
Log(Log::Warning, " Reserved: %02X\n", ctrl.cmd[2]);
Log(Log::Warning, " Reserved: %02X\n", ctrl.cmd[3]);
Log(Log::Warning, " Parameter List Len %02X\n", ctrl.cmd[4]);
@ -7890,13 +7890,13 @@ void FASTCALL SASIDEV::FlushUnit()
if (!ctrl.unit[lun]->ModeSelect(
ctrl.cmd, ctrl.buffer, ctrl.offset)) {
// MODE SELECT failed
Log(Log::Warning, "Error occured while processing Mode Select command %02X\n", ctrl.cmd[0]);
Log(Log::Warning, "Error occured while processing Mode Select command %02X\n", (unsigned char)ctrl.cmd[0]);
return;
}
break;
default:
printf("Received an invalid flush command %08X!!!!!\n",ctrl.cmd[0]);
Log(Log::Warning, "Received an invalid flush command %02X!!!!!\n",ctrl.cmd[0]);
ASSERT(FALSE);
break;
}
@ -7961,10 +7961,12 @@ void SASIDEV::GetPhaseStr(char *str)
void FASTCALL SASIDEV::Log(Log::loglevel level, const char *format, ...)
{
#if !defined(BAREMETAL)
#ifdef DISK_LOG
char buffer[0x200];
char buffer2[0x250];
char buffer3[0x250];
char phase_str[20];
#endif
va_list args;
va_start(args, format);

View File

@ -101,14 +101,14 @@ char* dirname(char *path)
dirtmp[1] = '\0';
return dirtmp;
}
p = path + strlen(path) - 1;
while( *p == '/' ) {
if( p == path )
return path;
*p-- = '\0';
}
while( p >= path && *p != '/' ) {
p--;
}
@ -143,7 +143,7 @@ char* basename(char *path)
basetmp[1] = '\0';
return basetmp;
}
p = path + strlen(path) - 1;
while( *p == '/' ) {
if( p == path ) {
@ -151,11 +151,11 @@ char* basename(char *path)
}
*p-- = '\0';
}
while( p >= path && *p != '/' ) {
p--;
}
return p + 1;
}
#endif // BAREMETAL
@ -219,9 +219,9 @@ void FASTCALL Filepath::Make()
m_szPath[0] = _T('\0');
// 合成
strcat(m_szPath, m_szDir);
strcat(m_szPath, m_szFile);
strcat(m_szPath, m_szExt);
strncat(m_szPath, m_szDir, ARRAY_SIZE(m_szPath) - strlen(m_szPath));
strncat(m_szPath, m_szFile, ARRAY_SIZE(m_szPath) - strlen(m_szPath));
strncat(m_szPath, m_szExt, ARRAY_SIZE(m_szPath) - strlen(m_szPath));
}
//---------------------------------------------------------------------------
@ -343,4 +343,4 @@ char Filepath::ShortName[_MAX_FNAME + _MAX_DIR];
// ファイル名+拡張子
//
//---------------------------------------------------------------------------
TCHAR Filepath::FileExt[_MAX_FNAME + _MAX_DIR];
TCHAR Filepath::FileExt[_MAX_FNAME + _MAX_DIR];

View File

@ -114,6 +114,8 @@
#endif // NDEBUG
#endif // ASSERT_DIAG
#define ARRAY_SIZE(x) (sizeof(x)/(sizeof(x[0])))
//---------------------------------------------------------------------------
//
// 基本型定義