aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Berndt <lukekb@gmail.com>2023-02-07 21:06:27 -0500
committerLuke Berndt <lukekb@gmail.com>2023-02-07 21:08:24 -0500
commit6fcc7f67cf16ca1af949d2b8326fa99299ad24e5 (patch)
tree09a7d09b17960d080c00d4dd1f7b8565188365d8
parentef639fe9084aa12bc1244fcb9cf684e220982103 (diff)
cleaning up sprintf warnings
-rw-r--r--lib/lfsr/bit_utils.h2
-rw-r--r--plugins/unit_script/unit_script.cc16
-rw-r--r--trunk-recorder/talkgroup.cc2
3 files changed, 10 insertions, 10 deletions
diff --git a/lib/lfsr/bit_utils.h b/lib/lfsr/bit_utils.h
index 02572c28..391b3bdc 100644
--- a/lib/lfsr/bit_utils.h
+++ b/lib/lfsr/bit_utils.h
@@ -76,7 +76,7 @@ std::string mk_str(Eigen::VectorXi a) {
std::string res = "";
char buffer[10];
for (unsigned i=0; i<a.size(); i++) {
- sprintf(buffer, "%d", (a(i) & 1));
+ snprintf(buffer, 10, "%d", (a(i) & 1));
res.append(buffer);
}
return res;
diff --git a/plugins/unit_script/unit_script.cc b/plugins/unit_script/unit_script.cc
index 1abca58a..5b1773ac 100644
--- a/plugins/unit_script/unit_script.cc
+++ b/plugins/unit_script/unit_script.cc
@@ -27,7 +27,7 @@ int unit_registration(System *sys, long source_id) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
- sprintf(shell_command, "%s %s %li on &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
+ snprintf(shell_command, 200, "%s %s %li on &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
int rc __attribute__((unused)) = system(shell_command);
return 0;
}
@@ -39,7 +39,7 @@ int unit_deregistration(System *sys, long source_id) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
- sprintf(shell_command, "%s %s %li off &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
+ snprintf(shell_command, 200, "%s %s %li off &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
int rc __attribute__((unused)) = system(shell_command);
return 0;
}
@@ -49,7 +49,7 @@ int unit_acknowledge_response(System *sys, long source_id) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
- sprintf(shell_command, "%s %s %li ackresp &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
+ snprintf(shell_command,200, "%s %s %li ackresp &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
int rc __attribute__((unused)) = system(shell_command);
return 0;
}
@@ -69,7 +69,7 @@ int unit_group_affiliation(System *sys, long source_id, long talkgroup_num) {
first = false;
patch_string += std::to_string(TGID);
}
- sprintf(shell_command, "%s %s %li join %li %s &", system_script.c_str(), sys->get_short_name().c_str(), source_id, talkgroup_num, patch_string.c_str());
+ snprintf(shell_command, 200, "%s %s %li join %li %s &", system_script.c_str(), sys->get_short_name().c_str(), source_id, talkgroup_num, patch_string.c_str());
int rc __attribute__((unused)) = system(shell_command);
return 0;
}
@@ -80,7 +80,7 @@ int unit_data_grant(System *sys, long source_id) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
- sprintf(shell_command, "%s %s %li data &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
+ snprintf(shell_command, 200, "%s %s %li data &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
int rc __attribute__((unused)) = system(shell_command);
return 0;
}
@@ -91,7 +91,7 @@ int unit_answer_request(System *sys, long source_id, long talkgroup) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
- sprintf(shell_command, "%s %s %li ans_req %li &", system_script.c_str(), sys->get_short_name().c_str(), source_id, talkgroup);
+ snprintf(shell_command, 200, "%s %s %li ans_req %li &", system_script.c_str(), sys->get_short_name().c_str(), source_id, talkgroup);
int rc __attribute__((unused)) = system(shell_command);
return 0;
}
@@ -111,7 +111,7 @@ int unit_location(System *sys, long source_id, long talkgroup_num) {
first = false;
patch_string += std::to_string(TGID);
}
- sprintf(shell_command, "%s %s %li location %li %s &", system_script.c_str(), sys->get_short_name().c_str(), source_id, talkgroup_num, patch_string.c_str());
+ snprintf(shell_command, 200, "%s %s %li location %li %s &", system_script.c_str(), sys->get_short_name().c_str(), source_id, talkgroup_num, patch_string.c_str());
int rc __attribute__((unused)) = system(shell_command);
return 0;
}
@@ -133,7 +133,7 @@ int call_start(Call *call) {
first = false;
patch_string += std::to_string(TGID);
}
- sprintf(shell_command, "%s %s %li call %li %s &", system_script.c_str(), short_name.c_str(), source_id, talkgroup_num, patch_string.c_str());
+ snprintf(shell_command, 200, "%s %s %li call %li %s &", system_script.c_str(), short_name.c_str(), source_id, talkgroup_num, patch_string.c_str());
int rc __attribute__((unused)) = system(shell_command);
return 0;
}
diff --git a/trunk-recorder/talkgroup.cc b/trunk-recorder/talkgroup.cc
index b57f7ca8..afee663e 100644
--- a/trunk-recorder/talkgroup.cc
+++ b/trunk-recorder/talkgroup.cc
@@ -35,7 +35,7 @@ std::string Talkgroup::menu_string() {
// std::ostringstream oss;
- sprintf(buff, "%5lu - %-15s %-20s %-15s %-40s", number, alpha_tag.c_str(), tag.c_str(), group.c_str(), description.c_str());
+ snprintf(buff, 150, "%5lu - %-15s %-20s %-15s %-40s", number, alpha_tag.c_str(), tag.c_str(), group.c_str(), description.c_str());
// sprintf(buff, "%5lu - %s", number, alpha_tag.c_str());