helper/binarybuffer: fix clang static analyzer warnings
Writing bits to an uninitialized buffer generated false warnings. Zero buffers before setting them by buf_set_u32|64() (do it only if bit-by-bit copy loop is used, zeroed buffer is not necessary if a fast path write is used) Change-Id: I2f7f8ddb45b0cbd08d3e249534fc51f4b5cc6694 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5383 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
This commit is contained in:
@@ -1233,7 +1233,7 @@ static int jtag_examine_chain(void)
|
||||
/* Add room for end-of-chain marker. */
|
||||
max_taps++;
|
||||
|
||||
uint8_t *idcode_buffer = malloc(max_taps * 4);
|
||||
uint8_t *idcode_buffer = calloc(4, max_taps);
|
||||
if (idcode_buffer == NULL)
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
|
||||
|
||||
@@ -1131,7 +1131,7 @@ COMMAND_HANDLER(handle_irscan_command)
|
||||
}
|
||||
int field_size = tap->ir_length;
|
||||
fields[i].num_bits = field_size;
|
||||
uint8_t *v = malloc(DIV_ROUND_UP(field_size, 8));
|
||||
uint8_t *v = calloc(1, DIV_ROUND_UP(field_size, 8));
|
||||
|
||||
uint64_t value;
|
||||
retval = parse_u64(CMD_ARGV[i * 2 + 1], &value);
|
||||
|
||||
Reference in New Issue
Block a user