Skip to content

Commit 49ffcbe

Browse files
committed
fix some compiler warnings
1 parent 18a4dad commit 49ffcbe

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

M4_Eyes/file.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static int32_t dwim(JsonVariant v, int32_t def = 0) { // "Do What I Mean"
6464
}
6565
}
6666

67+
/*
6768
static void getFilename(JsonVariant v, char **ptr) {
6869
if(*ptr) { // If string already allocated,
6970
free(*ptr); // delete old value...
@@ -73,6 +74,7 @@ static void getFilename(JsonVariant v, char **ptr) {
7374
*ptr = strdup(v); // Make a copy of string, save that
7475
}
7576
}
77+
*/
7678

7779
void loadConfig(char *filename) {
7880
File file;
@@ -135,7 +137,7 @@ void loadConfig(char *filename) {
135137
if(pMin > pMax) {
136138
float temp = pMin;
137139
pMin = pMax;
138-
pMax = pMin;
140+
pMax = temp;
139141
}
140142
irisMin = (1.0 - pMax);
141143
irisRange = (pMax - pMin);
@@ -337,7 +339,7 @@ ImageReturnCode loadEyelid(char *filename,
337339
if(reader->bmpDimensions(filename, &w, &h) == IMAGE_SUCCESS) {
338340
tempBytes = ((w + 7) / 8) * h; // Bitmap size in bytes
339341
if (maxRam > tempBytes) {
340-
if(tempPtr = (uint8_t *)malloc(maxRam - tempBytes)) {
342+
if((tempPtr = (uint8_t *)malloc(maxRam - tempBytes)) != NULL) {
341343
// Make SOME tempPtr reference, or optimizer removes the alloc!
342344
tempPtr[0] = 0;
343345
}
@@ -420,7 +422,7 @@ ImageReturnCode loadTexture(char *filename, uint16_t **data,
420422
if(reader->bmpDimensions(filename, &w, &h) == IMAGE_SUCCESS) {
421423
tempBytes = w * h * 2; // Image size in bytes (converted to 16bpp)
422424
if (maxRam > tempBytes) {
423-
if(tempPtr = (uint8_t *)malloc(maxRam - tempBytes)) {
425+
if((tempPtr = (uint8_t *)malloc(maxRam - tempBytes)) != NULL) {
424426
// Make SOME tempPtr reference, or optimizer removes the alloc!
425427
tempPtr[0] = 0;
426428
}

M4_Eyes/pdmvoice.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void voiceGain(float g) {
191191
void voiceMod(uint32_t freq, uint8_t waveform) {
192192
if(modBuf) { // Ignore if no modulation buffer allocated
193193
if(freq < MOD_MIN) freq = MOD_MIN;
194-
modLen = (int)(actualPlaybackRate / freq + 0.5);
194+
modLen = (uint32_t)(actualPlaybackRate / freq + 0.5);
195195
if(modLen < 2) modLen = 2;
196196
if(waveform > 4) waveform = 4;
197197
modWave = waveform;
@@ -204,17 +204,17 @@ void voiceMod(uint32_t freq, uint8_t waveform) {
204204
memset(&modBuf[modLen / 2], 0, modLen - modLen / 2);
205205
break;
206206
case 2: // Sine
207-
for(int i=0; i<modLen; i++) {
207+
for(uint32_t i=0; i<modLen; i++) {
208208
modBuf[i] = (int)((sin(M_PI * 2.0 * (float)i / (float)modLen) + 1.0) * 0.5 * 255.0 + 0.5);
209209
}
210210
break;
211211
case 3: // Triangle
212-
for(int i=0; i<modLen; i++) {
212+
for(uint32_t i=0; i<modLen; i++) {
213213
modBuf[i] = (int)(fabs(0.5 - (float)i / (float)modLen) * 2.0 * 255.0 + 0.5);
214214
}
215215
break;
216216
case 4: // Sawtooth (increasing)
217-
for(int i=0; i<modLen; i++) {
217+
for(uint32_t i=0; i<modLen; i++) {
218218
modBuf[i] = (int)((float)i / (float)(modLen - 1) * 255.0 + 0.5);
219219
}
220220
break;

0 commit comments

Comments
 (0)