<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19265">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">geolocation & test: Fix issues exposed by compiling with -O2<br><br>Fixed "may be used uninitialized" errors in geoloc_config.c,<br>test.c and test_crypto.c.  Also changed a few direct calls to<br>alloca and free to use the ast_ variants.<br><br>ASTERISK-30234<br><br>Change-Id: I1ea336bf7abbc16fa59b75720f0db8f1d960b3d4<br>---<br>M main/test.c<br>M res/res_geolocation/geoloc_config.c<br>M tests/test_crypto.c<br>3 files changed, 22 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/65/19265/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/test.c b/main/test.c</span><br><span>index 747262c..d01392e 100644</span><br><span>--- a/main/test.c</span><br><span>+++ b/main/test.c</span><br><span>@@ -316,9 +316,9 @@</span><br><span> void ast_test_capture_free(struct ast_test_capture *capture)</span><br><span> {</span><br><span>   if (capture) {</span><br><span style="color: hsl(0, 100%, 40%);">-          free(capture->outbuf);</span><br><span style="color: hsl(120, 100%, 40%);">+             ast_free(capture->outbuf);</span><br><span>                capture->outbuf = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-              free(capture->errbuf);</span><br><span style="color: hsl(120, 100%, 40%);">+             ast_free(capture->errbuf);</span><br><span>                capture->errbuf = NULL;</span><br><span>   }</span><br><span>    capture->pid = -1;</span><br><span>@@ -330,6 +330,7 @@</span><br><span>  int fd0[2] = { -1, -1 }, fd1[2] = { -1, -1 }, fd2[2] = { -1, -1 };</span><br><span>   pid_t pid = -1;</span><br><span>      int status = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+       FILE *cmd = NULL, *out = NULL, *err = NULL;</span><br><span> </span><br><span>      memset(capture, 0, sizeof(*capture));</span><br><span>        capture->pid = capture->exitcode = -1;</span><br><span>@@ -379,8 +380,6 @@</span><br><span>           exit(1);</span><br><span> </span><br><span>         } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                FILE *cmd = NULL, *out = NULL, *err = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>          char buf[BUFSIZ];</span><br><span>            int wstatus, n, nfds;</span><br><span>                fd_set readfds, writefds;</span><br><span>diff --git a/res/res_geolocation/geoloc_config.c b/res/res_geolocation/geoloc_config.c</span><br><span>index dea7a22..26dd2d9 100644</span><br><span>--- a/res/res_geolocation/geoloc_config.c</span><br><span>+++ b/res/res_geolocation/geoloc_config.c</span><br><span>@@ -187,7 +187,7 @@</span><br><span>     struct ast_geoloc_location *location;</span><br><span>        const char *id = ast_sorcery_object_get_id(profile);</span><br><span>         enum ast_geoloc_validate_result result;</span><br><span style="color: hsl(0, 100%, 40%);">- enum ast_geoloc_format format;</span><br><span style="color: hsl(120, 100%, 40%);">+        enum ast_geoloc_format format = AST_GEOLOC_FORMAT_NONE;</span><br><span>      int rc = 0;</span><br><span> </span><br><span>      if (!ast_strlen_zero(profile->location_reference)) {</span><br><span>diff --git a/tests/test_crypto.c b/tests/test_crypto.c</span><br><span>index 141781b..a3a0004 100644</span><br><span>--- a/tests/test_crypto.c</span><br><span>+++ b/tests/test_crypto.c</span><br><span>@@ -49,7 +49,7 @@</span><br><span> </span><br><span> static char *hexstring(const unsigned char *data, unsigned datalen)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-    char *buf = alloca(datalen * 2 + 1);</span><br><span style="color: hsl(120, 100%, 40%);">+  char *buf = ast_malloc(datalen * 2 + 1);</span><br><span>     unsigned n;</span><br><span> </span><br><span>      for (n = 0; n < datalen; ++n) {</span><br><span>@@ -532,6 +532,7 @@</span><br><span>     res = AST_TEST_PASS;</span><br><span> </span><br><span> cleanup:</span><br><span style="color: hsl(120, 100%, 40%);">+  ast_free(args[KEY]);</span><br><span>         ast_test_capture_free(&cap);</span><br><span>     return res;</span><br><span> }</span><br><span>@@ -610,6 +611,7 @@</span><br><span>       res = AST_TEST_PASS;</span><br><span> </span><br><span> cleanup:</span><br><span style="color: hsl(120, 100%, 40%);">+  ast_free(args[KEY]);</span><br><span>         ast_test_capture_free(&cap);</span><br><span>     return res;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19265">change 19265</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19265"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I1ea336bf7abbc16fa59b75720f0db8f1d960b3d4 </div>
<div style="display:none"> Gerrit-Change-Number: 19265 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>