coverity: fix uninit variable issue in driver

Related CID:
389832, 389838, 389880, 286743, 286752, 395156, 291011, 396001, 396002
This commit is contained in:
morris
2022-07-28 11:15:36 +08:00
parent f332790af5
commit 45524408df
5 changed files with 17 additions and 10 deletions

View File

@@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <assert.h>
#include "esp_gdbstub_common.h"
// GDB command input buffer
@@ -45,6 +46,8 @@ void esp_gdbstub_send_str(const char *c)
// 'bits'/4 dictates the number of hex chars sent.
void esp_gdbstub_send_hex(int val, int bits)
{
// sanity check, in case the following (i - 4) is a negative value
assert(bits >= 4);
const char *hex_chars = "0123456789abcdef";
for (int i = bits; i > 0; i -= 4) {
esp_gdbstub_send_char(hex_chars[(val >> (i - 4)) & 0xf]);