Skip to content

Commit

Permalink
Fix c_str() in printf for string (sonic-net#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Sep 17, 2019
1 parent 11b44b5 commit 83d86ed
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions vslib/src/sai_vs_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ sai_status_t vs_set_port_attribute(
if (system(cmd.c_str()) == -1)
{
SWSS_LOG_ERROR("unable to delete the sampling session \
for the interface %s",if_name);
SWSS_LOG_ERROR("failed to apply the command: %s",cmd);
for the interface %s",if_name.c_str());
SWSS_LOG_ERROR("failed to apply the command: %s",cmd.c_str());
return SAI_STATUS_FAILURE;
}
SWSS_LOG_INFO("successfully applied the command: %s", cmd);
SWSS_LOG_INFO("successfully applied the command: %s", cmd.c_str());
} else {
//Get the sample rate from the sample object
sai_attribute_t samplepacket_attr;
Expand Down Expand Up @@ -130,36 +130,36 @@ sai_status_t vs_set_port_attribute(
cmd.assign("tc qdisc delete dev " + if_name + " handle ffff: ingress");
if (system(cmd.c_str()) == -1){
SWSS_LOG_ERROR("unable to delete the sampling session \
for the interface %s",if_name);
SWSS_LOG_ERROR("failed to apply the command: %s",cmd);
for the interface %s",if_name.c_str());
SWSS_LOG_ERROR("failed to apply the command: %s",cmd.c_str());
return SAI_STATUS_FAILURE;
}
SWSS_LOG_INFO("successfully applied the command: %s", cmd);
SWSS_LOG_INFO("successfully applied the command: %s", cmd.c_str());
}

//Create a new sampling session
cmd.assign("tc qdisc add dev " + if_name + " handle ffff: ingress");
if (system(cmd.c_str()) == -1)
{
SWSS_LOG_ERROR("unable to create a sampling session for the interface %s", if_name);
SWSS_LOG_ERROR("failed to apply the command: %s",cmd);
SWSS_LOG_ERROR("unable to create a sampling session for the interface %s", if_name.c_str());
SWSS_LOG_ERROR("failed to apply the command: %s",cmd.c_str());
return SAI_STATUS_FAILURE;
}
SWSS_LOG_INFO("successfully applied the command: %s", cmd);
SWSS_LOG_INFO("successfully applied the command: %s", cmd.c_str());

//Set the sampling rate of the port
cmd.assign("tc filter add dev " + if_name + \
" parent ffff: matchall action sample rate " + std::to_string(rate) + \
" group " + group);
if (system(cmd.c_str()) == -1)
{
SWSS_LOG_ERROR("unable to update the sampling rate of the interface %s",if_name);
SWSS_LOG_ERROR("failed to apply the command: %s",cmd);
SWSS_LOG_ERROR("unable to update the sampling rate of the interface %s",if_name.c_str());
SWSS_LOG_ERROR("failed to apply the command: %s",cmd.c_str());
return SAI_STATUS_FAILURE;
}
SWSS_LOG_INFO("successfully applied the command: %s", cmd);
SWSS_LOG_INFO("successfully applied the command: %s", cmd.c_str());
} else {
SWSS_LOG_ERROR("failed to update the port %s, unable to read the sample attr", if_name);
SWSS_LOG_ERROR("failed to update the port %s, unable to read the sample attr", if_name.c_str());
return SAI_STATUS_FAILURE;
}
}
Expand Down

0 comments on commit 83d86ed

Please sign in to comment.