fix debug_name handling in buffer_pool

- possible bug discovered by coverity
master
Andre Puschmann 8 years ago
parent 4a1b67a671
commit 2b8b36c371

@ -76,7 +76,7 @@ public:
{ {
printf("%d buffers in queue\n", (int) used.size()); printf("%d buffers in queue\n", (int) used.size());
for (uint32_t i=0;i<used.size();i++) { for (uint32_t i=0;i<used.size();i++) {
printf("%s\n", used[i]->debug_name?used[i]->debug_name:"Undefined"); printf("%s\n", strlen(used[i]->debug_name)?used[i]->debug_name:"Undefined");
} }
} }
@ -97,7 +97,8 @@ public:
} }
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED #ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
if (debug_name) { if (debug_name) {
strncpy(b->debug_name, debug_name, 128); strncpy(b->debug_name, debug_name, SRSLTE_BUFFER_POOL_LOG_NAME_LEN);
b->debug_name[SRSLTE_BUFFER_POOL_LOG_NAME_LEN-1] = 0;
} }
#endif #endif

@ -54,6 +54,7 @@
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED #ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
#define pool_allocate (pool->allocate(__FUNCTION__)) #define pool_allocate (pool->allocate(__FUNCTION__))
#define SRSLTE_BUFFER_POOL_LOG_NAME_LEN 128
#else #else
#define pool_allocate (pool->allocate()) #define pool_allocate (pool->allocate())
#endif #endif
@ -121,7 +122,7 @@ public:
uint8_t buffer[SRSLTE_MAX_BUFFER_SIZE_BYTES]; uint8_t buffer[SRSLTE_MAX_BUFFER_SIZE_BYTES];
uint8_t *msg; uint8_t *msg;
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED #ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
char debug_name[128]; char debug_name[SRSLTE_BUFFER_POOL_LOG_NAME_LEN];
#endif #endif
byte_buffer_t():N_bytes(0) byte_buffer_t():N_bytes(0)
@ -129,6 +130,9 @@ public:
timestamp_is_set = false; timestamp_is_set = false;
msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET]; msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET];
next = NULL; next = NULL;
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
debug_name[0] = 0;
#endif
} }
byte_buffer_t(const byte_buffer_t& buf) byte_buffer_t(const byte_buffer_t& buf)
{ {

Loading…
Cancel
Save