entry->pid = entry_raw->pid;
entry->tid = entry_raw->tid;
- entry->priority = entry_raw->msg[0];
- if (entry->priority < 0 || entry->priority > DLOG_SILENT) {
- fprintf(stderr, "Wrong priority message, %d but should be <%d\n", entry->priority, DLOG_SILENT);
+ const unsigned char pri = entry_raw->msg[0]; // cannot cast to log_priority directly because then the compiler is allowed to optimize the below check out
+ if (pri > DLOG_SILENT) {
+ fprintf(stderr, "Wrong priority message, %u but should be <%u\n", pri, DLOG_SILENT);
return -1;
}
+ entry->priority = (log_priority)pri;
entry->tag = entry_raw->msg + 1;
if (!strlen(entry->tag)) {