cppchecker fix - might be called with UID == NULL

This commit is contained in:
iceman1001 2021-01-28 12:46:26 +01:00
parent 31df889f97
commit 84bc138841

View file

@ -15,14 +15,15 @@
// uid[] the UID in transmission order // uid[] the UID in transmission order
// return: ptr to string // return: ptr to string
char *iso15693_sprintUID(char *dest, uint8_t *uid) { char *iso15693_sprintUID(char *dest, uint8_t *uid) {
static char tempbuf[3 * 8 + 1] = {0}; static char tempbuf[3 * 8 + 1] = {0};
if (dest == NULL) if (dest == NULL)
dest = tempbuf; dest = tempbuf;
sprintf(dest, "%02X %02X %02X %02X %02X %02X %02X %02X", if (uid) {
uid[7], uid[6], uid[5], uid[4], sprintf(dest, "%02X %02X %02X %02X %02X %02X %02X %02X",
uid[3], uid[2], uid[1], uid[0] uid[7], uid[6], uid[5], uid[4],
); uid[3], uid[2], uid[1], uid[0]
);
}
return dest; return dest;
} }