Skip to content

Commit a45e359

Browse files
committed
Clang fixes
1 parent a0e52aa commit a45e359

File tree

7 files changed

+22
-11
lines changed

7 files changed

+22
-11
lines changed

dosbox_pure_libretro.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,7 @@ static bool check_variables()
22922292
// Emulation options
22932293
const char* forcefps = DBP_Option::Get(DBP_Option::forcefps);
22942294
dbp_forcefps = (Bit16s)(forcefps[0] == 'f' ? 0 : forcefps[0] == 't' ? 60 : atoi(forcefps));
2295+
if (dbp_forcefps < 0) dbp_forcefps = 0;
22952296

22962297
switch (DBP_Option::Get(DBP_Option::perfstats)[0])
22972298
{
@@ -2314,14 +2315,14 @@ static bool check_variables()
23142315
bool cycles_numeric = (cycles[0] >= '0' && cycles[0] <= '9');
23152316
int cycles_max = (cycles_numeric ? 0 : atoi(DBP_Option::Get(DBP_Option::cycles_max, &cycles_changed)));
23162317
DBP_Option::SetDisplay(DBP_Option::cycles_max, !cycles_numeric);
2317-
DBP_Option::SetDisplay(DBP_Option::cycles_scale, cycles_numeric || cycles_max);
2318+
DBP_Option::SetDisplay(DBP_Option::cycles_scale, cycles_numeric || cycles_max > 0);
23182319
DBP_Option::SetDisplay(DBP_Option::cycle_limit, !cycles_numeric);
23192320
if (cycles_numeric)
23202321
{
23212322
snprintf(buf, sizeof(buf), "%d", (int)(atoi(cycles) * (float)atof(DBP_Option::Get(DBP_Option::cycles_scale, &cycles_changed)) + .499));
23222323
cycles = buf;
23232324
}
2324-
else if (cycles_max)
2325+
else if (cycles_max > 0)
23252326
{
23262327
snprintf(buf, sizeof(buf), "%s limit %d", cycles, (int)(cycles_max * (float)atof(DBP_Option::Get(DBP_Option::cycles_scale, &cycles_changed)) + .499));
23272328
cycles = buf;

dosbox_pure_pad.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ struct DBP_PadMapping
832832

833833
struct BindDecoder
834834
{
835-
INLINE BindDecoder(const Bit8u *ptr) : P(ptr), OutPtr(NULL), Remain(P ? *(P++)+1 : 1), KeyCount(0) { ++*this; }
836-
INLINE BindDecoder(const Bit8u **ptr) : P(*ptr), OutPtr(ptr), Remain(P ? *(P++)+1 : 1), KeyCount(0) { ++*this; }
835+
INLINE BindDecoder(const Bit8u *ptr) : P(ptr), OutPtr(NULL), Remain(P ? *(P++)+1 : 1), KeyCount(0), IsAnalog(false) { ++*this; }
836+
INLINE BindDecoder(const Bit8u **ptr) : P(*ptr), OutPtr(ptr), Remain(P ? *(P++)+1 : 1), KeyCount(0), IsAnalog(false) { ++*this; }
837837
INLINE const BindDecoder& begin() const { return *this; }
838838
INLINE const BindDecoder& end() const { return *this; }
839839
INLINE const BindDecoder& operator*() const { return *this; }

src/dos/drives.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ void DriveFileIterator(DOS_Drive* drv, void(*func)(const char* path, bool is_dir
507507

508508
template <typename TVal> struct BaseHashMap
509509
{
510-
INLINE BaseHashMap() { memset(this, 0, sizeof(*this)); }
510+
INLINE BaseHashMap() : len(0), maxlen(0), keys(NULL), vals(NULL) { }
511511
INLINE ~BaseHashMap() { free(keys); free(vals); }
512512

513-
INLINE void Free() { this->~BaseHashMap(); memset(this, 0, sizeof(*this)); }
513+
INLINE void Free() { this->~BaseHashMap(); len = maxlen = 0; keys = NULL; vals = NULL; }
514514
INLINE void Clear() { if (maxlen) memset(keys, len = 0, (maxlen + 1) * sizeof(Bit32u)); }
515515

516516
INLINE Bit32u Len() const { return len; }

src/gui/midi_oss.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include <fcntl.h>
2020
#define SEQ_MIDIPUTC 5
2121

22+
#if defined(__GNUC__)
23+
#pragma GCC diagnostic ignored "-Wunused-variable"
24+
#endif
25+
2226
class MidiHandler_oss: public MidiHandler {
2327
private:
2428
int device;

src/gui/midi_win32.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ class MidiHandler_win32: public MidiHandler {
8989
midiOutUnprepareHeader (m_out, &m_hdr, sizeof (m_hdr));
9090

9191
m_hdr.lpData = (char *) sysex;
92-
m_hdr.dwBufferLength = len ;
93-
m_hdr.dwBytesRecorded = len ;
92+
m_hdr.dwBufferLength = (DWORD) len ;
93+
m_hdr.dwBytesRecorded = (DWORD) len ;
9494
m_hdr.dwUser = 0;
9595

9696
MMRESULT result = midiOutPrepareHeader (m_out, &m_hdr, sizeof (m_hdr));

src/hardware/voodoo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ static INLINE INT64 fast_reciplog(INT64 value, INT32 *log2)
11191119
if (value & LONGTYPE(0xffff00000000))
11201120
{
11211121
temp = (UINT32)(value >> 16);
1122-
exp -= 16;
1122+
exp = -16;
11231123
}
11241124
else
11251125
temp = (UINT32)value;
@@ -2973,12 +2973,12 @@ template <typename TVal> struct GrowArray
29732973
{
29742974
Bit32u num, cap;
29752975
TVal* data;
2976-
INLINE GrowArray() { memset(this, 0, sizeof(*this)); }
2976+
INLINE GrowArray() : num(0), cap(0), data(NULL) { }
29772977
INLINE ~GrowArray() { free(data); }
29782978
INLINE TVal& AddOne() { if ((++num) > cap) data = (TVal*)realloc(data, (cap = (cap < 16 ? 16 : cap * 2)) * sizeof(TVal)); return data[num - 1]; }
29792979
INLINE TVal* Add(UINT32 n) { num += n; while (num > cap) data = (TVal*)realloc(data, (cap = (cap < 16 ? 16 : cap * 2)) * sizeof(TVal)); return data + num - n; }
29802980
INLINE void Reset() { num = 0; }
2981-
INLINE void Free() { free(data); memset(this, 0, sizeof(*this)); }
2981+
INLINE void Free() { free(data); num = cap = 0; data = NULL; }
29822982
INLINE TVal* begin() { return data; }
29832983
INLINE TVal* end() { return data + num; }
29842984
};

src/misc/setup.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,15 @@ bool Value::set_int(string const &in) {
207207
}
208208
bool Value::set_double(string const &in) {
209209
istringstream input(in);
210+
#ifdef C_DBP_LIBRETRO // fix infinity compile warning with Clang
211+
double result = 0;
212+
input >> result;
213+
if(input.fail()) return false;
214+
#else
210215
double result = std::numeric_limits<double>::infinity();
211216
input >> result;
212217
if(result == std::numeric_limits<double>::infinity()) return false;
218+
#endif
213219
_double = result;
214220
return true;
215221
}

0 commit comments

Comments
 (0)