diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 4aefcd99f..9e730dc08 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -123,7 +123,7 @@ void DbpStringEx(char *str, uint32_t cmd) { data.flag = cmd; uint16_t len = MIN(strlen(str), sizeof(data.buf)); memcpy(data.buf, str, len); - reply_ng(CMD_DEBUG_PRINT_STRING, PM3_SUCCESS, (uint8_t*)&data, sizeof(data.flag) + len); + reply_ng(CMD_DEBUG_PRINT_STRING, PM3_SUCCESS, (uint8_t *)&data, sizeof(data.flag) + len); #endif } diff --git a/client/comms.c b/client/comms.c index 881806c84..f7c84c7c4 100644 --- a/client/comms.c +++ b/client/comms.c @@ -261,7 +261,7 @@ static void PacketResponseReceived(PacketResponseNG *packet) { uint16_t flag; uint8_t buf[USB_CMD_DATA_SIZE - sizeof(uint16_t)]; } PACKED; - struct d* data = (struct d*)&packet->data.asBytes; + struct d *data = (struct d *)&packet->data.asBytes; len = packet->length - sizeof(data->flag); memcpy(s, data->buf, len); flag = data->flag; @@ -617,7 +617,7 @@ bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms response = &resp; // Add delay depending on the communication channel & speed - if (ms_timeout != (size_t)-1) + if (ms_timeout != (size_t) -1) ms_timeout += communication_delay(); timeout_start_time = msclock(); @@ -707,7 +707,7 @@ static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketRes timeout_start_time = msclock(); // Add delay depending on the communication channel & speed - if (ms_timeout != (size_t)-1) + if (ms_timeout != (size_t) -1) ms_timeout += communication_delay(); while (true) { diff --git a/client/jansson/pack_unpack.c b/client/jansson/pack_unpack.c index af7aab0fd..651e1c56b 100644 --- a/client/jansson/pack_unpack.c +++ b/client/jansson/pack_unpack.c @@ -480,9 +480,14 @@ static int unpack_object(scanner_t *s, json_t *root, va_list *ap) { return -1; } + if (root && !json_is_object(root)) { - set_error(s, "", json_error_wrong_type, "Expected object, got %s", - type_name(root)); + set_error(s, + "", + json_error_wrong_type, + "Expected object, got %s", + (root) ? type_name(root) : "NULL" + ); goto out; } next_token(s);