[Asterisk-code-review] test crypto.c: Fix getcwd(…) build error. (asterisk[18])
Sean Bright
asteriskteam at digium.com
Mon Feb 27 15:38:22 CST 2023
Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19932 )
Change subject: test_crypto.c: Fix getcwd(…) build error.
......................................................................
test_crypto.c: Fix getcwd(…) build error.
`getcwd(…)` is decorated with the `warn_unused_result` attribute and
therefore needs its return value checked.
Change-Id: Idcccb20a0abf293202c28633d0e9ee0f6a9dbe93
---
M tests/test_crypto.c
1 file changed, 40 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/32/19932/1
diff --git a/tests/test_crypto.c b/tests/test_crypto.c
index 848a562..8b52c9d 100644
--- a/tests/test_crypto.c
+++ b/tests/test_crypto.c
@@ -110,10 +110,16 @@
if (!ast_check_command_in_path(command)) {
ast_test_status_update(test, "couldn't find %s\n", command);
+ ast_test_capture_free(&cap);
return res;
}
- getcwd(wd, sizeof(wd));
+ if (getcwd(wd, sizeof(wd)) == NULL) {
+ ast_test_status_update(test, "Could not determine current working directory\n");
+ ast_test_capture_free(&cap);
+ return res;
+ }
+
snprintf(key_dir, sizeof(key_dir), "%s/%s", wd, "tests/keys");
push_key_dir((const char *)key_dir);
snprintf(priv, sizeof(priv), "%s/%s.key", key_dir, keypair1);
@@ -200,10 +206,16 @@
if (!ast_check_command_in_path(command)) {
ast_test_status_update(test, "couldn't find %s\n", command);
+ ast_test_capture_free(&cap);
return res;
}
- getcwd(wd, sizeof(wd));
+ if (getcwd(wd, sizeof(wd)) == NULL) {
+ ast_test_status_update(test, "Could not determine current working directory\n");
+ ast_test_capture_free(&cap);
+ return res;
+ }
+
snprintf(key_dir, sizeof(key_dir), "%s/%s", wd, "tests/keys");
push_key_dir((const char *)key_dir);
snprintf(pub, sizeof(pub), "%s/%s.pub", key_dir, keypair1);
@@ -297,10 +309,16 @@
if (!ast_check_command_in_path(command)) {
ast_test_status_update(test, "couldn't find %s\n", command);
+ ast_test_capture_free(&cap);
return res;
}
- getcwd(wd, sizeof(wd));
+ if (getcwd(wd, sizeof(wd)) == NULL) {
+ ast_test_status_update(test, "Could not determine current working directory\n");
+ ast_test_capture_free(&cap);
+ return res;
+ }
+
snprintf(key_dir, sizeof(key_dir), "%s/%s", wd, "tests/keys");
push_key_dir((const char *)key_dir);
snprintf(pub, sizeof(pub), "%s/%s.pub", key_dir, keypair1);
@@ -410,10 +428,16 @@
if (!ast_check_command_in_path(command)) {
ast_test_status_update(test, "couldn't find %s\n", command);
+ ast_test_capture_free(&cap);
return res;
}
- getcwd(wd, sizeof(wd));
+ if (getcwd(wd, sizeof(wd)) == NULL) {
+ ast_test_status_update(test, "Could not determine current working directory\n");
+ ast_test_capture_free(&cap);
+ return res;
+ }
+
snprintf(key_dir, sizeof(key_dir), "%s/%s", wd, "tests/keys");
push_key_dir((const char *)key_dir);
snprintf(priv, sizeof(priv), "%s/%s.key", key_dir, keypair1);
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19932
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: Idcccb20a0abf293202c28633d0e9ee0f6a9dbe93
Gerrit-Change-Number: 19932
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean at seanbright.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230227/fcdb85d5/attachment-0001.html>
More information about the asterisk-code-review
mailing list