Fix compilation error on GCC 8.x due to usage of strncpy in zmq_imp_rx/tx.

Fixed also order in which zmq object is zero'ed out.
master
Pedro Alvarez 5 years ago committed by Andre Puschmann
parent 6d62e15d2a
commit 40e688ce9b

@ -100,12 +100,13 @@ int rf_zmq_rx_open(rf_zmq_rx_t* q, char* id, void* zmq_ctx, char* sock_args)
int ret = SRSLTE_ERROR;
if (q) {
// Copy id
strncpy(q->id, id, 16);
// Zero object
bzero(q, sizeof(rf_zmq_tx_t));
// Copy id
strncpy(q->id, id, ZMQ_ID_STRLEN - 1);
q->id[ZMQ_ID_STRLEN - 1] = '\0';
// Create socket
q->sock = zmq_socket(zmq_ctx, ZMQ_REQ);
if (!q->sock) {

@ -38,9 +38,10 @@
#define ZMQ_MAX_BUFFER_SIZE (NSAMPLES2NBYTES(3072000)) // 10 subframes at 20 MHz
#define ZMQ_TIMEOUT_MS (1000)
#define ZMQ_BASERATE_DEFAULT_HZ (23040000)
#define ZMQ_ID_STRLEN 16
typedef struct {
char id[16];
char id[ZMQ_ID_STRLEN];
void* sock;
uint64_t nsamples;
bool running;
@ -49,7 +50,7 @@ typedef struct {
} rf_zmq_tx_t;
typedef struct {
char id[16];
char id[ZMQ_ID_STRLEN];
void* sock;
uint64_t nsamples;
bool running;

@ -36,12 +36,13 @@ int rf_zmq_tx_open(rf_zmq_tx_t* q, const char* id, void* zmq_ctx, char* sock_arg
int ret = SRSLTE_ERROR;
if (q) {
// Copy id
strncpy(q->id, id, 16);
// Zero object
bzero(q, sizeof(rf_zmq_tx_t));
// Copy id
strncpy(q->id, id, ZMQ_ID_STRLEN - 1);
q->id[ZMQ_ID_STRLEN - 1] = '\0';
// Create socket
q->sock = zmq_socket(zmq_ctx, ZMQ_REP);
if (!q->sock) {

Loading…
Cancel
Save