|
From: openocd-gerrit <ope...@us...> - 2024-09-15 09:10:43
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via e5a2001a3331dfc669f9969fd9a5f661579ccad9 (commit)
from 760dd1f3a8720e5e58b96e4920fd17bd8a1a7bf6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e5a2001a3331dfc669f9969fd9a5f661579ccad9
Author: Parshintsev Anatoly <ana...@sy...>
Date: Sat Aug 3 22:10:57 2024 +0300
binarybuffer: add asserts for the number of requested bits for get/set functions
Change-Id: Ieca5b4e690c9713ad60dc9d8c223c2d64822e2f5
Signed-off-by: Parshintsev Anatoly <ana...@sy...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8427
Tested-by: jenkins
Reviewed-by: Tomas Vanek <va...@fb...>
Reviewed-by: Jan Matyas <jan...@co...>
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h
index 103a48c5c..df4199837 100644
--- a/src/helper/binarybuffer.h
+++ b/src/helper/binarybuffer.h
@@ -34,6 +34,7 @@
static inline void buf_set_u32(uint8_t *_buffer,
unsigned first, unsigned num, uint32_t value)
{
+ assert(num >= 1 && num <= 32);
uint8_t *buffer = _buffer;
if ((num == 32) && (first == 0)) {
@@ -64,6 +65,7 @@ static inline void buf_set_u32(uint8_t *_buffer,
static inline void buf_set_u64(uint8_t *_buffer,
unsigned first, unsigned num, uint64_t value)
{
+ assert(num >= 1 && num <= 64);
uint8_t *buffer = _buffer;
if ((num == 32) && (first == 0)) {
@@ -102,6 +104,7 @@ static inline void buf_set_u64(uint8_t *_buffer,
static inline uint32_t buf_get_u32(const uint8_t *_buffer,
unsigned first, unsigned num)
{
+ assert(num >= 1 && num <= 32);
const uint8_t *buffer = _buffer;
if ((num == 32) && (first == 0)) {
@@ -131,6 +134,7 @@ static inline uint32_t buf_get_u32(const uint8_t *_buffer,
static inline uint64_t buf_get_u64(const uint8_t *_buffer,
unsigned first, unsigned num)
{
+ assert(num >= 1 && num <= 64);
const uint8_t *buffer = _buffer;
if ((num == 32) && (first == 0)) {
-----------------------------------------------------------------------
Summary of changes:
src/helper/binarybuffer.h | 4 ++++
1 file changed, 4 insertions(+)
hooks/post-receive
--
Main OpenOCD repository
|