mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 15:14:44 +00:00
proc.cpp, fish_tests.cpp: use snprintf()
Resolves this warning: > warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
This commit is contained in:
parent
c588bd5c5c
commit
b73091b27b
2 changed files with 3 additions and 3 deletions
|
@ -478,7 +478,7 @@ static void test_format() {
|
|||
for (int j = -129; j <= 129; j++) {
|
||||
char buff1[128], buff2[128];
|
||||
format_long_safe(buff1, j);
|
||||
sprintf(buff2, "%d", j);
|
||||
snprintf(buff2, 128, "%d", j);
|
||||
do_test(!std::strcmp(buff1, buff2));
|
||||
|
||||
wchar_t wbuf1[128], wbuf2[128];
|
||||
|
@ -490,7 +490,7 @@ static void test_format() {
|
|||
long q = LONG_MIN;
|
||||
char buff1[128], buff2[128];
|
||||
format_long_safe(buff1, q);
|
||||
sprintf(buff2, "%ld", q);
|
||||
snprintf(buff2, 128, "%ld", q);
|
||||
do_test(!std::strcmp(buff1, buff2));
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ bool job_t::signal(int signal) {
|
|||
if (auto pgid = group->get_pgid()) {
|
||||
if (killpg(*pgid, signal) == -1) {
|
||||
char buffer[512];
|
||||
sprintf(buffer, "killpg(%d, %s)", *pgid, strsignal(signal));
|
||||
snprintf(buffer, 512, "killpg(%d, %s)", *pgid, strsignal(signal));
|
||||
wperror(str2wcstring(buffer).c_str());
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue