mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
add debug check that all modes and rawmodes are defined
This commit is contained in:
parent
0d3c59e277
commit
c3c968e025
|
@ -1,6 +1,10 @@
|
|||
#include "Mode.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef NDEBUG
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
const ModeData MODES[] = {
|
||||
[IMAGING_MODE_UNKNOWN] = {""},
|
||||
|
@ -39,6 +43,11 @@ const ModeID findModeID(const char * const name) {
|
|||
return IMAGING_MODE_UNKNOWN;
|
||||
}
|
||||
for (size_t i = 0; i < sizeof(MODES) / sizeof(*MODES); i++) {
|
||||
#ifdef NDEBUG
|
||||
if (MODES[i].name == NULL) {
|
||||
fprintf(stderr, "Mode ID %zu is not defined.\n", (size_t)i);
|
||||
} else
|
||||
#endif
|
||||
if (strcmp(MODES[i].name, name) == 0) {
|
||||
return (ModeID)i;
|
||||
}
|
||||
|
@ -238,6 +247,11 @@ const RawModeID findRawModeID(const char * const name) {
|
|||
return IMAGING_RAWMODE_UNKNOWN;
|
||||
}
|
||||
for (size_t i = 0; i < sizeof(RAWMODES) / sizeof(*RAWMODES); i++) {
|
||||
#ifdef NDEBUG
|
||||
if (RAWMODES[i].name == NULL) {
|
||||
fprintf(stderr, "Rawmode ID %zu is not defined.\n", (size_t)i);
|
||||
} else
|
||||
#endif
|
||||
if (strcmp(RAWMODES[i].name, name) == 0) {
|
||||
return (RawModeID)i;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user