Cosmetics

This commit is contained in:
Bertrand Songis
2020-01-09 22:50:56 +01:00
parent 40e994dca3
commit fc7fa5fe94
107 changed files with 124 additions and 113 deletions
+14 -14
View File
@@ -28,28 +28,28 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
uint8_t * buf = &bmpBuf[0];
if (width > LCD_W) {
return NULL;
return nullptr;
}
FRESULT result = f_open(&bmpFile, filename, FA_OPEN_EXISTING | FA_READ);
if (result != FR_OK) {
return NULL;
return nullptr;
}
if (f_size(&bmpFile) < 14) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
result = f_read(&bmpFile, buf, 14, &read);
if (result != FR_OK || read != 14) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
if (buf[0] != 'B' || buf[1] != 'M') {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint32_t fsize = *((uint32_t *)&buf[2]);
@@ -59,7 +59,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
result = f_read(&bmpFile, buf, len, &read);
if (result != FR_OK || read != len) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint32_t ihsize = *((uint32_t *)&buf[0]); /* more header size */
@@ -67,7 +67,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
/* invalid header size */
if (ihsize + 14 > hsize) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
/* sometimes file size is set to some headers size, set a real size in that case */
@@ -78,7 +78,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
/* declared file size less than header size */
if (fsize <= hsize) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint32_t w, h;
@@ -100,17 +100,17 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
break;
default:
f_close(&bmpFile);
return NULL;
return nullptr;
}
if (*((uint16_t *)&buf[0]) != 1) { /* planes */
f_close(&bmpFile);
return NULL;
return nullptr;
}
if (w > width || h > height) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint16_t depth = *((uint16_t *)&buf[2]);
@@ -119,7 +119,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
if (f_lseek(&bmpFile, hsize) != FR_OK) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint8_t * dest = bmp;
@@ -138,7 +138,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
result = f_read(&bmpFile, buf, rowSize, &read);
if (result != FR_OK || read != rowSize) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
for (uint8_t j=0; j<w; j++) {
@@ -152,7 +152,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
default:
f_close(&bmpFile);
return NULL;
return nullptr;
}
f_close(&bmpFile);