mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-26 00:29:27 +00:00
Fixes for various clang static analyzer issues
This commit is contained in:
parent
29e8502f23
commit
a2a55d53ed
|
@ -1029,7 +1029,7 @@ static void MB_Update()
|
|||
|
||||
// Commit sound buffer
|
||||
#ifdef APPLE2IX
|
||||
hr = MockingboardVoice.lpDSBvoice->Unlock(MockingboardVoice.lpDSBvoice->_this, (void*)pDSLockedBuffer0, dwDSLockedBufferSize0,
|
||||
MockingboardVoice.lpDSBvoice->Unlock(MockingboardVoice.lpDSBvoice->_this, (void*)pDSLockedBuffer0, dwDSLockedBufferSize0,
|
||||
#else
|
||||
hr = MockingboardVoice.lpDSBvoice->Unlock((void*)pDSLockedBuffer0, dwDSLockedBufferSize0,
|
||||
#endif
|
||||
|
|
|
@ -233,27 +233,25 @@ static void DeleteVoice(ALVoice *voice)
|
|||
}
|
||||
|
||||
ALPlayBuf *node = NULL;
|
||||
ALPlayBuf *tmp = NULL;
|
||||
HASH_ITER(hh, voice->queued_buffers, node, tmp) {
|
||||
PlaylistDequeue(voice, node);
|
||||
}
|
||||
|
||||
while (voice->avail_buffers)
|
||||
{
|
||||
node = voice->avail_buffers;
|
||||
alDeleteBuffers(1, &node->bufid);
|
||||
voice->avail_buffers = node->_avail_next;
|
||||
free(node);
|
||||
}
|
||||
|
||||
ALPlayBuf *tmp = NULL;
|
||||
HASH_ITER(hh, voice->queued_buffers, node, tmp) {
|
||||
HASH_DEL(voice->queued_buffers, node);
|
||||
alDeleteBuffers(1, &node->bufid);
|
||||
if (alGetError() != AL_NO_ERROR)
|
||||
{
|
||||
ERRLOG("OOPS, Failed to delete object IDs");
|
||||
}
|
||||
free(node);
|
||||
voice->avail_buffers = node->_avail_next;
|
||||
FREE(node);
|
||||
}
|
||||
|
||||
memset(voice, 0, sizeof(*voice));
|
||||
free(voice);
|
||||
FREE(voice);
|
||||
}
|
||||
|
||||
/* Creates a new voice object, and allocates the needed OpenAL source and
|
||||
|
@ -758,8 +756,10 @@ static long OpenALDestroySoundBuffer(ALSoundBufferStruct **soundbuf_struct)
|
|||
|
||||
ALVoices *vnode = NULL;
|
||||
HASH_FIND_INT(voices, &source, vnode);
|
||||
HASH_DEL(voices, vnode);
|
||||
FREE(vnode);
|
||||
if (vnode) {
|
||||
HASH_DEL(voices, vnode);
|
||||
FREE(vnode);
|
||||
}
|
||||
|
||||
FREE(*soundbuf_struct);
|
||||
return 0;
|
||||
|
|
|
@ -531,6 +531,12 @@ static void UpdateRemainderBuffer(ULONG* pnCycleDiff)
|
|||
signed long nSampleMean = 0;
|
||||
for(UINT i=0; i<g_nRemainderBufferSize; i++)
|
||||
nSampleMean += (signed long) g_pRemainderBuffer[i];
|
||||
#ifdef APPLE2IX
|
||||
if (!g_nRemainderBufferSize) {
|
||||
RELEASE_ERRLOG("OOPS preventing div-by-zero in UpdateRemainderBuffer ...");
|
||||
g_nRemainderBufferSize = 1;
|
||||
}
|
||||
#endif
|
||||
nSampleMean /= (signed long) g_nRemainderBufferSize;
|
||||
|
||||
if(g_nBufferIdx < SPKR_SAMPLE_RATE-1)
|
||||
|
|
31
src/common.h
31
src/common.h
|
@ -105,7 +105,7 @@ extern FILE *error_log;
|
|||
errno = 0; \
|
||||
GLenum _glerr = 0; \
|
||||
_LOG(__VA_ARGS__); \
|
||||
}
|
||||
} //
|
||||
|
||||
#define ERRLOG(...) \
|
||||
if (do_logging) { \
|
||||
|
@ -114,7 +114,7 @@ extern FILE *error_log;
|
|||
while ( (_glerr = glGetError()) ) { \
|
||||
_LOG(__VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
} //
|
||||
|
||||
#define GL_ERRLOG(...) \
|
||||
if (do_logging) { \
|
||||
|
@ -122,7 +122,7 @@ extern FILE *error_log;
|
|||
while ( (_glerr = glGetError()) ) { \
|
||||
_LOG(__VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
} //
|
||||
|
||||
#define ERRQUIT(...) \
|
||||
do { \
|
||||
|
@ -132,7 +132,7 @@ extern FILE *error_log;
|
|||
_LOG(__VA_ARGS__); \
|
||||
} \
|
||||
QUIT_FUNCTION(1); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#define GL_ERRQUIT(...) \
|
||||
do { \
|
||||
|
@ -141,45 +141,52 @@ extern FILE *error_log;
|
|||
_LOG(__VA_ARGS__); \
|
||||
QUIT_FUNCTION(_glerr); \
|
||||
} \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
#else // NDEBUG
|
||||
|
||||
#define ERRLOG(...) \
|
||||
do { } while(0);
|
||||
do { } while (0)
|
||||
|
||||
#define ERRQUIT(...) \
|
||||
do { } while(0);
|
||||
do { } while (0)
|
||||
|
||||
#define LOG(...) \
|
||||
do { } while(0);
|
||||
do { } while (0)
|
||||
|
||||
#define GL_ERRLOG(...) \
|
||||
do { } while (0)
|
||||
|
||||
#define GL_ERRQUIT(...) \
|
||||
do { } while (0)
|
||||
|
||||
#endif // NDEBUG
|
||||
|
||||
#define RELEASE_ERRLOG(...) \
|
||||
do { \
|
||||
GLenum _glerr = 0; \
|
||||
_LOG(__VA_ARGS__); \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define RELEASE_LOG(...) \
|
||||
do { \
|
||||
GLenum _glerr = glGetError(); \
|
||||
errno = 0; \
|
||||
_LOG(__VA_ARGS__); \
|
||||
} while(0);
|
||||
} while (0)
|
||||
|
||||
#define FREE(x) \
|
||||
do { \
|
||||
free((x)); \
|
||||
(x) = NULL; \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define CFRELEASE(x) \
|
||||
do { \
|
||||
CFRelease((x)); \
|
||||
(x) = NULL; \
|
||||
} while (0);
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif // whole file
|
||||
|
|
|
@ -904,7 +904,7 @@ static inline void _plot_hires_pixels(uint8_t *dst, const uint8_t *src) {
|
|||
|
||||
// PlotByte
|
||||
static inline void _plot_hires(uint16_t ea, uint8_t b, bool is_even, uint8_t *fb_ptr) {
|
||||
uint8_t _buf[DYNAMIC_SZ];
|
||||
uint8_t _buf[DYNAMIC_SZ] = { 0 };
|
||||
uint8_t *color_buf = (uint8_t *)_buf; // <--- work around for -Wstrict-aliasing
|
||||
uint8_t *apple2_vmem = (uint8_t *)apple_ii_64k[0];
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ void dump_mem(int addrs, int len, int lc, int do_ascii, int rambank) {
|
|||
}
|
||||
}
|
||||
|
||||
memset(second_buf[i], ' ', BUF_X); mod = 0;
|
||||
memset(second_buf[i], ' ', BUF_X);
|
||||
sprintf(second_buf[i], "%04X:%02X", orig_addrs+j, op);
|
||||
if (do_ascii)
|
||||
{
|
||||
|
|
|
@ -228,7 +228,7 @@ static GLuint _create_VAO(demoModel *model) {
|
|||
// Allocate and load vertex array element data into VBO
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, model->elementArraySize, model->elements, GL_STATIC_DRAW);
|
||||
|
||||
GL_ERRLOG("finished creating VAO/VBOs")
|
||||
GL_ERRLOG("finished creating VAO/VBOs");
|
||||
|
||||
return vaoName;
|
||||
}
|
||||
|
|
|
@ -612,7 +612,7 @@ void mtxRotateZApply(float *mtx, float deg) {
|
|||
}
|
||||
|
||||
void mtxRotateApply(float *mtx, float deg, float xAxis, float yAxis, float zAxis) {
|
||||
if(yAxis == 0.0f && zAxis == 0.0f) {
|
||||
if (yAxis == 0.0f && zAxis == 0.0f) {
|
||||
mtxRotateXApply(mtx, deg);
|
||||
} else if(xAxis == 0.0f && zAxis == 0.0f) {
|
||||
mtxRotateYApply(mtx, deg);
|
||||
|
@ -792,11 +792,21 @@ void mtxRotateZMatrix(float *mtx, float rad) {
|
|||
}
|
||||
|
||||
void mtxRotateMatrix(float *mtx, float rad, float xAxis, float yAxis, float zAxis) {
|
||||
float rotMtx[16];
|
||||
|
||||
mtxLoadRotate(rotMtx, rad, xAxis, yAxis, zAxis);
|
||||
|
||||
mtxMultiply(mtx, rotMtx, mtx);
|
||||
if (yAxis == 0.0f && zAxis == 0.0f) {
|
||||
mtxRotateXMatrix(mtx, rad);
|
||||
} else if(xAxis == 0.0f && zAxis == 0.0f) {
|
||||
mtxRotateYMatrix(mtx, rad);
|
||||
} else if(xAxis == 0.0f && yAxis == 0.0f) {
|
||||
mtxRotateZMatrix(mtx, rad);
|
||||
} else {
|
||||
float rotMtx[16];
|
||||
#if !defined(USE_ORIGINAL_BUGGY_IMPLEMENTATION)
|
||||
#warning fixed a use of garbage stack memory, but unsure of algorithm ... need testing =)
|
||||
mtxLoadIdentity(rotMtx);
|
||||
#endif
|
||||
mtxLoadRotate(rotMtx, rad, xAxis, yAxis, zAxis);
|
||||
mtxMultiply(mtx, rotMtx, mtx);
|
||||
}
|
||||
}
|
||||
|
||||
void mtx3x3LoadIdentity(float *mtx) {
|
||||
|
|
|
@ -72,13 +72,13 @@ void mtxScaleApply(float *mtx, float xScale, float yScale, float zScale);
|
|||
void mtxRotateApply(float *mtx, float deg, float xAxis, float yAxis, float zAxis);
|
||||
|
||||
// MTX = MTX * RotateXMatrix
|
||||
void mtxRotateXApply(float *mtx, float rad);
|
||||
void mtxRotateXApply(float *mtx, float deg);
|
||||
|
||||
// MTX = MTX * RotateYMatrix
|
||||
void mtxRotateYApply(float *mtx, float rad);
|
||||
void mtxRotateYApply(float *mtx, float deg);
|
||||
|
||||
// MTX = MTX * RotateZMatrix
|
||||
void mtxRotateZApply(float *mtx, float rad);
|
||||
void mtxRotateZApply(float *mtx, float deg);
|
||||
|
||||
// MTX = TranslationMatrix * MTX
|
||||
void mtxTranslateMatrix(float *mtx, float xTrans, float yTrans, float zTrans);
|
||||
|
|
|
@ -19,22 +19,22 @@
|
|||
typedef struct demoModelRec {
|
||||
GLuint numVertices;
|
||||
|
||||
GLubyte *positions;
|
||||
GLvoid *positions;
|
||||
GLenum positionType;
|
||||
GLuint positionSize;
|
||||
GLsizei positionArraySize;
|
||||
|
||||
GLubyte *texcoords;
|
||||
GLvoid *texcoords;
|
||||
GLenum texcoordType;
|
||||
GLuint texcoordSize;
|
||||
GLsizei texcoordArraySize;
|
||||
|
||||
GLubyte *normals;
|
||||
GLvoid *normals;
|
||||
GLenum normalType;
|
||||
GLuint normalSize;
|
||||
GLsizei normalArraySize;
|
||||
|
||||
GLubyte *elements;
|
||||
GLvoid *elements;
|
||||
GLenum elementType;
|
||||
GLuint numElements;
|
||||
GLsizei elementArraySize;
|
||||
|
|
Loading…
Reference in New Issue
Block a user