Fix a bunch of Clang static analysis issues

This commit is contained in:
Aaron Culliney 2016-09-10 11:32:33 -06:00
parent fc3df8c6b6
commit cb31ccaf9c
6 changed files with 6 additions and 13 deletions

View File

@ -181,6 +181,7 @@ static void _speaker_update(/*bool toggled*/) {
sample_mean += (int)remainder_buffer[i];
}
assert(remainder_buffer_size > 0);
sample_mean /= (int)remainder_buffer_size;
if (samples_buffer_idx < channelsSampleRateHz) {
@ -213,7 +214,6 @@ static void _speaker_update(/*bool toggled*/) {
if (cycles_remainder > 0) {
// populate remainder_buffer with fractional samples
assert(remainder_buffer_idx == 0 && "should have already dealt with remainder buffer");
//assert(cycles_remainder < remainder_buffer_size && "otherwise there should have been another whole sample");
if (UNLIKELY(cycles_remainder >= remainder_buffer_size)) {
LOG("OOPS, overflow in cycles_remainder:%lu", cycles_remainder);
} else {

View File

@ -308,11 +308,8 @@ static const char *log_end = "\n";
do { \
/* BOOM */ \
char *ptr = (char *)0xABADF000; \
*ptr = '\0';\
/* or if that worked, just deref NULL */ \
ptr = (char *)0x0; \
*ptr = '\0'; \
} while (0);
*ptr++ = '\0';\
} while (1);
// memory management
#include "memmngt.h"

View File

@ -20,8 +20,6 @@
int64_t (*interface_onTouchEvent)(interface_touch_event_t action, int pointer_count, int pointer_idx, float *x_coords, float *y_coords) = NULL;
#endif
static char disk_path[PATH_MAX] = { 0 };
// 2015/04/12 : This was legacy code for rendering the menu interfaces on desktop Linux. Portions here are resurrected
// to render HUD messages on desktop and mobile. Nothing special or pretty here, but has "just worked" for 20+ years ;-)
@ -98,7 +96,6 @@ static void _convert_screen_graphics(char *screen, const int x, const int y, con
break;
}
}
idx += xlen+1;
}
if (found_glyph) {

View File

@ -108,7 +108,9 @@ int _a2_asprintf(char **strp, const char *fmt, ...) {
if (ret > 0) {
assert(*strp0);
assert(strp);
*strp = _a2_malloc(ret+1);
assert(*strp);
memcpy(*strp, strp0, ret);
*((*strp)+ret) = '\0';
free(strp0);

View File

@ -263,7 +263,6 @@ static void *cpu_thread(void *dummyptr) {
bool negative = false;
long drift_adj_nsecs = 0; // generic drift adjustment between target and actual
int debugging_cycles0 = 0;
int debugging_cycles = 0;
unsigned long dbg_ticks = 0;
@ -343,7 +342,6 @@ static void *cpu_thread(void *dummyptr) {
MB_StartOfCpuExecute();
if (is_debugging) {
debugging_cycles0 = cpu65_cycles_to_execute;
debugging_cycles = cpu65_cycles_to_execute;
}

View File

@ -340,11 +340,10 @@ void glhud_quadModelToScreen(const GLModel *model, const int screenW, const int
float glhud_getTimedVisibility(struct timespec timingBegin, float minAlpha, float maxAlpha) {
struct timespec now = { 0 };
struct timespec deltat = { 0 };
clock_gettime(CLOCK_MONOTONIC, &now);
float alpha = minAlpha;
deltat = timespec_diff(timingBegin, now, NULL);
struct timespec deltat = timespec_diff(timingBegin, now, NULL);
if (deltat.tv_sec == 0) {
alpha = maxAlpha;
if (deltat.tv_nsec >= NANOSECONDS_PER_SECOND/2) {