Skip to content

Commit

Permalink
Fixed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Nov 22, 2023
1 parent e4ef246 commit 9f8a649
Show file tree
Hide file tree
Showing 30 changed files with 222 additions and 215 deletions.
36 changes: 18 additions & 18 deletions Emulator/JIT/Generic/TJITGeneric_DataProcessingPSRTransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,59 +175,59 @@ static const JITFuncPtr DataProcessingPSRTransfer_MSR_Imm_Funcs[] = {

def_array_mode_s_rn_rd(AND);
#define AND_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_AND_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_AND_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_mode_s_rn_rd(EOR);
#define EOR_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_EOR_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_EOR_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_mode_s_rn_rd(SUB);
#define SUB_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_SUB_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_SUB_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_mode_s_rn_rd(RSB);
#define RSB_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_RSB_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_RSB_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_mode_s_rn_rd(ADD);
#define ADD_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_ADD_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_ADD_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_mode_s_rn_rd(ADC);
#define ADC_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_ADC_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_ADC_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_mode_s_rn_rd(SBC);
#define SBC_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_SBC_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_SBC_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_mode_s_rn_rd(RSC);
#define RSC_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_RSC_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_RSC_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_testop_mode_rn(TST);
#define TST_Func(mode, rn) \
DataProcessingPSRTransfer_TST_Funcs[((mode) *16) + (rn)]
DataProcessingPSRTransfer_TST_Funcs[((mode) * 16) + (rn)]
def_array_testop_mode_rn(TEQ);
#define TEQ_Func(mode, rn) \
DataProcessingPSRTransfer_TEQ_Funcs[((mode) *16) + (rn)]
DataProcessingPSRTransfer_TEQ_Funcs[((mode) * 16) + (rn)]
def_array_testop_mode_rn(CMP);
#define CMP_Func(mode, rn) \
DataProcessingPSRTransfer_CMP_Funcs[((mode) *16) + (rn)]
DataProcessingPSRTransfer_CMP_Funcs[((mode) * 16) + (rn)]
def_array_testop_mode_rn(CMN);
#define CMN_Func(mode, rn) \
DataProcessingPSRTransfer_CMN_Funcs[((mode) *16) + (rn)]
DataProcessingPSRTransfer_CMN_Funcs[((mode) * 16) + (rn)]
def_array_mode_s_rn_rd(ORR);
#define ORR_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_ORR_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_ORR_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_mode_s_rd(MOV);
#define MOV_Func(mode, flag_s, rd) \
DataProcessingPSRTransfer_MOV_Funcs[((mode) *32) + ((flag_s) *16) + (rd)]
DataProcessingPSRTransfer_MOV_Funcs[((mode) * 32) + ((flag_s) * 16) + (rd)]
def_array_mode_s_rn_rd(BIC);
#define BIC_Func(mode, flag_s, rnrd) \
DataProcessingPSRTransfer_BIC_Funcs[((mode) *512) + ((flag_s) *256) + (rnrd)]
DataProcessingPSRTransfer_BIC_Funcs[((mode) * 512) + ((flag_s) * 256) + (rnrd)]
def_array_mode_s_rd(MVN);
#define MVN_Func(mode, flag_s, rd) \
DataProcessingPSRTransfer_MVN_Funcs[((mode) *32) + ((flag_s) *16) + (rd)]
DataProcessingPSRTransfer_MVN_Funcs[((mode) * 32) + ((flag_s) * 16) + (rd)]

#define MRS_Func(flag_r, rd) \
DataProcessingPSRTransfer_MRS_Funcs[(flag_r * 16) + (rd)]
#define MSR_NoShift_Func(flag_r, fields_mask_ix, rm) \
DataProcessingPSRTransfer_MSR_NoShift_Funcs[((flag_r) *256) + ((fields_mask_ix) *16) + (rm)]
DataProcessingPSRTransfer_MSR_NoShift_Funcs[((flag_r) * 256) + ((fields_mask_ix) * 16) + (rm)]
#define MSR_Imm_Func(flag_r, fields_mask_ix) \
DataProcessingPSRTransfer_MSR_Imm_Funcs[((flag_r) *16) + (fields_mask_ix)]
DataProcessingPSRTransfer_MSR_Imm_Funcs[((flag_r) * 16) + (fields_mask_ix)]

#define __Rn (inInstruction & 0x000F0000) >> 16
#define __Rd (inInstruction & 0x0000F000) >> 12
Expand Down
2 changes: 1 addition & 1 deletion Emulator/JIT/TJITCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace std;
// -------------------------------------------------------------------------- //
// Constantes & globales.
// -------------------------------------------------------------------------- //
//#define kTJITCacheStats 1
// #define kTJITCacheStats 1
#undef kTJITCacheStats

#if kTJITCacheStats
Expand Down
4 changes: 2 additions & 2 deletions Emulator/Network/TNetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ TNetworkManager::LogBuffer(KUInt8* data, ssize_t size)
{
memset(t, ' ', 71);
t[71] = 0;
sprintf(t, "0x%04x: ", i);
snprintf(t, 71, "0x%04x: ", i);
t[9] = ' ';
}
unsigned char v = data[i];
int p = 9 + (i & 15) * 5 / 2;
sprintf(t + p, "%02x", v);
snprintf(t + p, 71 - p, "%02x", v);
t[p + 2] = ' ';
p = 50 + (i & 15);
t[p] = ((v >= 32) && (v < 127)) ? v : '.';
Expand Down
1 change: 1 addition & 0 deletions Emulator/Network/TTapNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#endif
#include "Emulator/TMemory.h"
#include "Emulator/PCMCIA/TPCMCIAController.h"
#include <cassert>

TTapNetwork::TTapNetwork(TLog* inLog) :
TNetworkManager(inLog)
Expand Down
28 changes: 14 additions & 14 deletions Emulator/Network/TUsermodeNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1807,9 +1807,9 @@ class DNSPacketHandler : public UDPPacketHandler
}
*d++ = 0;
ssize_t ix = s - packet.Data();
KUInt16 qType = packet.Get16(ix);
KUInt16 qType = packet.Get16((KUInt32) ix);
ix += 2;
KUInt16 qClass = packet.Get16(ix);
KUInt16 qClass = packet.Get16((KUInt32) ix);
ix += 2;
if (qType != 1 && qClass != 1)
{
Expand All @@ -1832,7 +1832,7 @@ class DNSPacketHandler : public UDPPacketHandler
err = 1;
}

KUInt32 replySize = packet.Size();
KUInt32 replySize = (KUInt32) packet.Size();
if (!err)
replySize += 16;
Packet* reply = new Packet(nullptr, replySize);
Expand Down Expand Up @@ -1885,17 +1885,17 @@ class DNSPacketHandler : public UDPPacketHandler
reply->Set16(0x002c, 0x8180);
reply->Set16(0x0030, 0x0001); // one reply
// ix was calculated when we read the incomming package
reply->Set16(ix, 0xc00c);
reply->Set16((KUInt32) ix, 0xc00c);
ix += 2; // Name
reply->Set16(ix, 0x0001);
reply->Set16((KUInt32) ix, 0x0001);
ix += 2; // Type
reply->Set16(ix, 0x0001);
reply->Set16((KUInt32) ix, 0x0001);
ix += 2; // Class
reply->Set32(ix, 0x00000e10);
reply->Set32((KUInt32) ix, 0x00000e10);
ix += 4; // TTL
reply->Set16(ix, 0x0004);
reply->Set16((KUInt32) ix, 0x0004);
ix += 2; // Record Length
reply->Set32(ix, ip);
reply->Set32((KUInt32) ix, ip);
ix += 4; // IP
}
net->SetIPv4Checksum(reply->Data(), reply->Size());
Expand Down Expand Up @@ -2367,7 +2367,7 @@ TUsermodeNetwork::Log(Packet* p, const char* label, int line, int adjSeq, int ad
ssize_t o = strlen(buf);
char as = adjSeq ? '*' : 'q';
char aa = adjAck ? '*' : 'k';
sprintf(buf + o, "TCP:p:%d %c%c%c%c%c%c %4u bytes payload (Se%c:%4u, Ac%c:%4u) [",
snprintf(buf + o, 2047 - o, "TCP:p:%d %c%c%c%c%c%c %4u bytes payload (Se%c:%4u, Ac%c:%4u) [",
p->Index(),
(unsigned int) (p->GetTCPFlags() & Packet::kTCPFlagURG ? 'U' : '.'),
(unsigned int) (p->GetTCPFlags() & Packet::kTCPFlagACK ? 'A' : '.'),
Expand Down Expand Up @@ -2402,12 +2402,12 @@ TUsermodeNetwork::Log(Packet* p, const char* label, int line, int adjSeq, int ad
&& p->Get32(0x0116) == 0x63825363)
{
ssize_t o = strlen(buf);
sprintf(buf + o, "DHCP:p:%d:%u bytes", p->Index(), (unsigned int) p->Size());
snprintf(buf + o, 2047 - o, "DHCP:p:%d:%u bytes", p->Index(), (unsigned int) p->Size());
} else if (p->GetType() == Packet::kNetTypeIP
&& p->GetIPProtocol() == Packet::kIPProtocolUDP)
{
ssize_t o = strlen(buf);
sprintf(buf + o, "UDP:p:%d %4u bytes [", p->Index(), (unsigned int) (p->GetUDPPayloadSize()));
snprintf(buf + o, 2047 - o, "UDP:p:%d %4u bytes [", p->Index(), (unsigned int) (p->GetUDPPayloadSize()));
ssize_t i = 0, s = p->GetUDPPayloadStart() - p->Data();
o = strlen(buf);
while (s < p->Size() && i < 128)
Expand All @@ -2427,11 +2427,11 @@ TUsermodeNetwork::Log(Packet* p, const char* label, int line, int adjSeq, int ad
} else if (p->GetType() == Packet::kNetTypeARP)
{
ssize_t o = strlen(buf);
sprintf(buf + o, "ARP:p:%d:%u bytes", p->Index(), (unsigned int) p->GetARPHLen());
snprintf(buf + o, 2047 - o, "ARP:p:%d:%u bytes", p->Index(), (unsigned int) p->GetARPHLen());
} else
{
ssize_t o = strlen(buf);
sprintf(buf + o, "????:p:%d:%u bytes", p->Index(), (unsigned int) p->Size());
snprintf(buf + o, 2047 - o, "????:p:%d:%u bytes", p->Index(), (unsigned int) p->Size());
}
mLog->FLogLine("Net: %4d: %s", line, buf);
}
Expand Down
2 changes: 1 addition & 1 deletion Emulator/PCMCIA/TLinearCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
using namespace std::chrono_literals;

#define AsyncTrace(...)
//#define AsyncTrace KPrintf
// #define AsyncTrace KPrintf

// -------------------------------------------------------------------------- //
// Constantes
Expand Down
4 changes: 2 additions & 2 deletions Emulator/PCMCIA/TPCMCIAController.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class TPCMCIAController
///
/// Accessor to the log interface.
///
/// \return a pointer to the log object or nil.
///  \return a pointer to the log object or nil.
///
inline TLog*
GetLog(void)
Expand All @@ -168,7 +168,7 @@ class TPCMCIAController
///
/// Accessor to the emulator.
///
/// \return a pointer to the emulator object.
///  \return a pointer to the emulator object.
///
inline TEmulator*
GetEmulator(void)
Expand Down
6 changes: 3 additions & 3 deletions Emulator/Platform/TPlatformManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ TPlatformManager::InstallNewPackages(const char* inPackageDir)

// -- find the last installation date
char buf[2048];
sprintf(buf, "%s/.lastInstall", inPackageDir);
snprintf(buf, 2047, "%s/.lastInstall", inPackageDir);
struct stat lastInstall;
int statErr = ::stat(buf, &lastInstall);
if (mLog)
Expand All @@ -772,7 +772,7 @@ TPlatformManager::InstallNewPackages(const char* inPackageDir)
if (mLog)
mLog->FLogLine("TPlatformManager: Checking '%s'", de->d_name);
struct stat pkgStat;
sprintf(buf, "%s/%s", inPackageDir, de->d_name);
snprintf(buf, 2047, "%s/%s", inPackageDir, de->d_name);
if (::stat(buf, &pkgStat) < 0)
continue;
if (statErr >= 0
Expand All @@ -790,7 +790,7 @@ TPlatformManager::InstallNewPackages(const char* inPackageDir)
// -- update the modification data
if (mLog)
mLog->FLogLine("TPlatformManager: updating last package installation date");
sprintf(buf, "%s/.lastInstall", inPackageDir);
snprintf(buf, 2047, "%s/.lastInstall", inPackageDir);
FILE* f = fopen(buf, "wb");
if (f)
fclose(f);
Expand Down
6 changes: 3 additions & 3 deletions Emulator/Printer/TFLPrinterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ TFLPrinterManager::ImageBand(KUInt32 inDrvr, KUInt32 inBand, KUInt32 inRect)
mMemory->FastReadBuffer(mBand.baseAddr, bytes, bits);

int nBlack = 0;
int nWhite = 0;
// int nWhite = 0;
mBandPixels = (KUInt8*) malloc(w * h);
KUInt8* dst = mBandPixels;
for (int y = 0; y < h; y++)
Expand All @@ -344,8 +344,8 @@ TFLPrinterManager::ImageBand(KUInt32 inDrvr, KUInt32 inBand, KUInt32 inRect)
*dst++ = (b & 128) ? 0 : 255;
if (b & 128)
nBlack++;
else
nWhite++;
// else
// nWhite++;
b = b << 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Screen/TFLScreenManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class Fl_Newton_Screen_Widget : public Fl_Box
{
fl_draw_image(rgbData_, x(), y(), rgbWidth_, rgbHeight_, 4); // 32 bit: RGB
}
//#elif TARGET_OS_LINUX
// #elif TARGET_OS_LINUX
#if 0
// TODO: Nothing implemented yet for X11/Xlib. XRender extension seems to be the way to go.
double xscale= 1.0;
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Screen/TScreenManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ TScreenManager::OverlayPrintProgress(KSInt32 y, KUInt32 percent)
{
if (percent > 100)
percent = 100;
sprintf(mOverlay[y], "%3d%%", (unsigned int) percent);
snprintf(mOverlay[y], 39, "%3d%%", (unsigned int) percent);
int i, n = percent * 34 / 100;
char* d = mOverlay[y] + 4;
*d++ = 1;
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Serial/TSerialHostPortPTY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ TSerialHostPortPTY::Run()
KUInt8 data[128];
int n;
mReadMutex->Lock();
while ((n = read(mMain, data, sizeof(data))) > 0)
while ((n = (int) read(mMain, data, sizeof(data))) > 0)
{
mReadBuffer->Produce(data, n);
}
Expand Down
4 changes: 3 additions & 1 deletion Emulator/Serial/TSerialPorts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ TSerialPorts::NSGetDriverList(TNewt::RefArg arg)
EDriverID* validDrivers = ValidDriversByPort[portIndex];
// Count valid drivers
unsigned nDriver;
for (nDriver = 0; (int) validDrivers[nDriver] != -1; nDriver++) { }
for (nDriver = 0; (int) validDrivers[nDriver] != -1; nDriver++)
{
}
// Create the arrays
RefVar array(AllocateArray(nDriver));
for (unsigned i = 0; i < nDriver; i++)
Expand Down
6 changes: 3 additions & 3 deletions Emulator/TEmulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
// -------------------------------------------------------------------------- //
// Constantes
// -------------------------------------------------------------------------- //
//#define kMyNewtonIDHigh 0x00000000
//#define kMyNewtonIDLow 0x020207A5
// #define kMyNewtonIDHigh 0x00000000
// #define kMyNewtonIDLow 0x020207A5
#define kMyNewtonIDHigh 0x00004E65
#define kMyNewtonIDLow 0x77746F6E

Expand Down Expand Up @@ -285,7 +285,7 @@ TEmulator::DebuggerUND(KUInt32 inPAddr)
{
// Extract the string.
KUInt8 theString[512];
(void) ::sprintf((char*) theString, "DebuggerUND: ");
(void) ::snprintf((char*) theString, 511, "DebuggerUND: ");
ssize_t index = ::strlen((const char*) theString);
KUInt32 theAddress = inPAddr + 4;
do
Expand Down
4 changes: 3 additions & 1 deletion Emulator/TInterruptManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ TInterruptManager::~TInterruptManager(void)
mMutex->Unlock();

// Wait for the thread to finish.
while (mExiting) { };
while (mExiting)
{
};

if (mThread)
{
Expand Down
2 changes: 1 addition & 1 deletion Emulator/TNativePrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ TNativePrimitives::ExecutePlatformDriverNative(KUInt32 inInstruction)
// if the Toolkit is available, send the text to the monitor
if (gToolkit)
{
unsigned srcLen = strlen(theLine);
unsigned srcLen = (unsigned) strlen(theLine);
unsigned dstLen = fl_utf8froma(nullptr, 0, theLine, srcLen);

char* dstText = (char*) ::malloc(dstLen + 1);
Expand Down
2 changes: 1 addition & 1 deletion K/Defines/UByteSex.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class UByteSex
#define UByteSex_ToBigEndian(inWord) (UByteSex::Swap(inWord))
#define UByteSex_ToLittleEndian(inWord) (inWord)
#else
// Macros pour une plateforme en grand indien
// Macros pour une plateforme en grand indien
#define UByteSex_FromBigEndian(inWord) (inWord)
#define UByteSex_FromLittleEndian(inWord) (UByteSex::Swap(inWord))
#define UByteSex_ToBigEndian(inWord) (inWord)
Expand Down
4 changes: 2 additions & 2 deletions K/Misc/RelocHack.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef void (*funcPtr)(void);
extern "C" void RelocVTableHack(void* inObject, funcPtr inRelocVTableHackPtr, VTableFuncPtr inVTablePtr);

// You can use this template for your convenience (this way you're sure that the parameters will be passed in the correct order)
#define RelocVTable(inVTablePtr) RelocVTableHack((void*) this, (funcPtr) &RelocVTableHack, inVTablePtr)
#define RelocVTable(inVTablePtr) RelocVTableHack((void*) this, (funcPtr) & RelocVTableHack, inVTablePtr)

#else

Expand All @@ -77,7 +77,7 @@ extern "C" void RelocVTableHack(void* inObject, funcPtr inRelocVTableHackPtr, VT
extern "C" funcPtr RelocFuncPtrHack(funcPtr inRelocFuncPtrHack, funcPtr inFuncPtr);

// You can use a template in this case, too (beware, you'll have to cast the result to a func pointer)
#define RelocFuncPtr(inFuncPtr) RelocFuncPtrHack((funcPtr) &RelocFuncPtrHack, (funcPtr) inFuncPtr)
#define RelocFuncPtr(inFuncPtr) RelocFuncPtrHack((funcPtr) & RelocFuncPtrHack, (funcPtr) inFuncPtr)

#endif
// __RELOCHACK__
Expand Down
4 changes: 2 additions & 2 deletions Monitor/TFLMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ TFLMonitor::DrawScreenHalted()

if (skip)
{
(void) ::sprintf(status, " (will skip)");
(void) ::snprintf(status, 31, " (will skip)");
} else
{
(void) ::sprintf(status, " (will do it)");
(void) ::snprintf(status, 31, " (will do it)");
}
}
}
Expand Down
Loading

0 comments on commit 9f8a649

Please sign in to comment.