diff options
author | Tomas Vanek <vanekt@fbl.cz> | 2019-12-20 23:56:08 +0100 |
---|---|---|
committer | Tomas Vanek <vanekt@fbl.cz> | 2020-03-07 15:30:05 +0000 |
commit | a2e822834df52efef5e1bbcb91a6eb1afbf102db (patch) | |
tree | 0e5caf3d1daa7dfeb6cabc7f3163d6dd5bbc73f9 /src/helper/binarybuffer.h | |
parent | 4e981bc27c36e696dc8ace3ab4bab534564770c1 (diff) | |
download | riscv-openocd-a2e822834df52efef5e1bbcb91a6eb1afbf102db.zip riscv-openocd-a2e822834df52efef5e1bbcb91a6eb1afbf102db.tar.gz riscv-openocd-a2e822834df52efef5e1bbcb91a6eb1afbf102db.tar.bz2 |
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>
Diffstat (limited to 'src/helper/binarybuffer.h')
-rw-r--r-- | src/helper/binarybuffer.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 7ac221e..3f2481d 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -33,6 +33,7 @@ * using the bits in @c value. This routine fast-paths writes * of little-endian, byte-aligned, 32-bit words. * @param _buffer The buffer whose bits will be set. + * Do not use uninitialized buffer or clang static analyzer emits a warning. * @param first The bit offset in @c _buffer to start writing (0-31). * @param num The number of bits from @c value to copy (1-32). * @param value Up to 32 bits that will be copied to _buffer. @@ -62,6 +63,7 @@ static inline void buf_set_u32(uint8_t *_buffer, * using the bits in @c value. This routine fast-paths writes * of little-endian, byte-aligned, 64-bit words. * @param _buffer The buffer whose bits will be set. + * Do not use uninitialized buffer or clang static analyzer emits a warning. * @param first The bit offset in @c _buffer to start writing (0-63). * @param num The number of bits from @c value to copy (1-64). * @param value Up to 64 bits that will be copied to _buffer. |