Skip to content

Commit

Permalink
resolving c++ linter
Browse files Browse the repository at this point in the history
Never use sprintf. Use snprintf instead.  [runtime/printf]
  • Loading branch information
ruck314 committed Jul 7, 2024
1 parent 92cedbe commit d9abfa6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions axi/simlink/src/RogueSideBand.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ void RogueSideBandRestart(RogueSideBandData *data, portDataT *portData) {

vhpi_printf("RogueSideBand: Listening on ports %i & %i\n", data->port, data->port+1);

sprintf(buffer, "tcp://127.0.0.1:%i", data->port+1);
snprintf(buffer, sizeof(buffer), "tcp://127.0.0.1:%i", data->port+1);
if ( zmq_bind(data->zmqPull, buffer) ) {
vhpi_assert("RogueSideBand: Failed to bind sideband port", vhpiFatal);
return;
}

sprintf(buffer, "tcp://127.0.0.1:%i", data->port);
snprintf(buffer, sizeof(buffer), "tcp://127.0.0.1:%i", data->port);
if ( zmq_bind(data->zmqPush, buffer) ) {
vhpi_assert("RogueSideBand: Failed to bind push port", vhpiFatal);
return;
Expand All @@ -74,7 +74,7 @@ void RogueSideBandSend(RogueSideBandData *data, portDataT *portData) {

// Send data
if ( zmq_msg_send(&msg, data->zmqPush, 0) < 0 ) {
sprintf(buffer, "RogueSideBand: Failed to send opcode: %x, remData: %x, on port %i\n", data->txOpCode, data->txRemData, data->port);
snprintf(buffer, sizeof(buffer), "RogueSideBand: Failed to send opcode: %x, remData: %x, on port %i\n", data->txOpCode, data->txRemData, data->port);
vhpi_assert(buffer, vhpiFatal);
}
if (data->txOpCodeEn) {
Expand Down
4 changes: 2 additions & 2 deletions axi/simlink/src/RogueTcpMemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ void RogueTcpMemoryRestart(RogueTcpMemoryData *data, portDataT *portData) {

vhpi_printf("RogueTcpMemory: Listening on ports %i & %i\n", data->port, data->port+1);

sprintf(buffer, "tcp://127.0.0.1:%i", data->port);
snprintf(buffer, sizeof(buffer), "tcp://127.0.0.1:%i", data->port);
if ( zmq_bind(data->zmqPull, buffer) ) {
vhpi_assert("RogueTcpMemory: Failed to bind pull port", vhpiFatal);
return;
}

sprintf(buffer, "tcp://127.0.0.1:%i", data->port+1);
snprintf(buffer, sizeof(buffer), "tcp://127.0.0.1:%i", data->port+1);
if ( zmq_bind(data->zmqPush, buffer) ) {
vhpi_assert("RogueTcpMemory: Failed to bind push port", vhpiFatal);
return;
Expand Down
4 changes: 2 additions & 2 deletions axi/simlink/src/RogueTcpStream.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ void RogueTcpStreamRestart(RogueTcpStreamData *data, portDataT *portData) {

vhpi_printf("RogueTcpStream: Listening on ports %i & %i\n", data->port, data->port+1);

sprintf(buffer, "tcp://127.0.0.1:%i", data->port);
snprintf(buffer, sizeof(buffer), "tcp://127.0.0.1:%i", data->port);
if ( zmq_bind(data->zmqPull, buffer) ) {
vhpi_assert("RogueTcpStream: Failed to bind pull port", vhpiFatal);
return;
}

sprintf(buffer, "tcp://127.0.0.1:%i", data->port+1);
snprintf(buffer, sizeof(buffer), "tcp://127.0.0.1:%i", data->port+1);
if ( zmq_bind(data->zmqPush, buffer) ) {
vhpi_assert("RogueTcpStream: Failed to bind push port", vhpiFatal);
return;
Expand Down

0 comments on commit d9abfa6

Please sign in to comment.