forked from auracaster/openocd
binarybuffer: Remove unnecessary cast and fix hidden "bug"
Because of the cast, the const decoration on the parameter provided no guarantee against modification since it was silently discarded. Change-Id: Ib83ade955e1a61ee2175c690620437b5e19cbb6a Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/1776 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
committed by
Spencer Oliver
parent
4935709484
commit
01298ca2c8
@@ -42,7 +42,7 @@
|
||||
static inline void buf_set_u32(void *_buffer,
|
||||
unsigned first, unsigned num, uint32_t value)
|
||||
{
|
||||
uint8_t *buffer = (uint8_t *)_buffer;
|
||||
uint8_t *buffer = _buffer;
|
||||
|
||||
if ((num == 32) && (first == 0)) {
|
||||
buffer[3] = (value >> 24) & 0xff;
|
||||
@@ -71,7 +71,7 @@ static inline void buf_set_u32(void *_buffer,
|
||||
static inline void buf_set_u64(void *_buffer,
|
||||
unsigned first, unsigned num, uint64_t value)
|
||||
{
|
||||
uint8_t *buffer = (uint8_t *)_buffer;
|
||||
uint8_t *buffer = _buffer;
|
||||
|
||||
if ((num == 32) && (first == 0)) {
|
||||
buffer[3] = (value >> 24) & 0xff;
|
||||
@@ -109,7 +109,7 @@ static inline void buf_set_u64(void *_buffer,
|
||||
static inline uint32_t buf_get_u32(const void *_buffer,
|
||||
unsigned first, unsigned num)
|
||||
{
|
||||
uint8_t *buffer = (uint8_t *)_buffer;
|
||||
const uint8_t *buffer = _buffer;
|
||||
|
||||
if ((num == 32) && (first == 0)) {
|
||||
return (((uint32_t)buffer[3]) << 24) |
|
||||
@@ -138,7 +138,7 @@ static inline uint32_t buf_get_u32(const void *_buffer,
|
||||
static inline uint64_t buf_get_u64(const void *_buffer,
|
||||
unsigned first, unsigned num)
|
||||
{
|
||||
uint8_t *buffer = (uint8_t *)_buffer;
|
||||
const uint8_t *buffer = _buffer;
|
||||
|
||||
if ((num == 32) && (first == 0)) {
|
||||
return 0 + ((((uint32_t)buffer[3]) << 24) | /* Note - zero plus is to avoid a checkpatch bug */
|
||||
|
||||
Reference in New Issue
Block a user