<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15105">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">main/say: Work around gcc 9 format-truncation false positive<br><br>Version: gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0<br>Warning:<br> say.c:2371:24: error: ā%dā directive output may be truncated writing<br> between 1 and 11 bytes into a region of size 10<br> [-Werror=format-truncation=]<br> 2371 | snprintf(buf, 10, "%d", num);<br> say.c:2371:23: note: directive argument in the range [-2147483648, 9]<br><br>That's not possible though, as the if() starts out checking for (num < 0),<br>making this Warning a false positive.<br><br>(Also replaced some else<TAB>if with else<SP>if while in the vicinity.)<br><br>Change-Id: Ic7a70120188c9aa525a6d70289385bfce878438a<br>---<br>M main/say.c<br>1 file changed, 10 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/say.c b/main/say.c</span><br><span>index 71d04f1..fcab7fd 100644</span><br><span>--- a/main/say.c</span><br><span>+++ b/main/say.c</span><br><span>@@ -557,10 +557,10 @@</span><br><span> } else if (playh) {</span><br><span> ast_copy_string(fn, "digits/hundred", sizeof(fn));</span><br><span> playh = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (num < 20) {</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (num < 20) {</span><br><span> snprintf(fn, sizeof(fn), "digits/%d", num);</span><br><span> num = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (num < 100) {</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (num < 100) {</span><br><span> snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);</span><br><span> num %= 10;</span><br><span> } else {</span><br><span>@@ -1224,7 +1224,7 @@</span><br><span> return res;</span><br><span> ast_copy_string(fn, "digits/thousand", sizeof(fn));</span><br><span> num = num % 1000;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (num < 1000000000) {</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (num < 1000000000) {</span><br><span> res = ast_say_number_full_fr(chan, num / 1000000, ints, language, options, audiofd, ctrlfd);</span><br><span> if (res)</span><br><span> return res;</span><br><span>@@ -1459,7 +1459,7 @@</span><br><span> } else if (num < 30) {</span><br><span> ast_copy_string(fn, "digits/20on", sizeof(fn));</span><br><span> num -= 20;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (num < 100) {</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (num < 100) {</span><br><span> snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);</span><br><span> num %= 10;</span><br><span> } else {</span><br><span>@@ -2471,8 +2471,8 @@</span><br><span> } else if (playt) {</span><br><span> snprintf(fn, sizeof(fn), "digits/thousand");</span><br><span> playt = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (num < 10) {</span><br><span style="color: hsl(0, 100%, 40%);">- snprintf(buf, 10, "%d", num);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (num < 10) {</span><br><span style="color: hsl(120, 100%, 40%);">+ snprintf(buf, 12, "%d", num);</span><br><span> if (last_length - strlen(buf) > 1 && last_length != 0) {</span><br><span> last_length = strlen(buf);</span><br><span> playz++;</span><br><span>@@ -2480,7 +2480,7 @@</span><br><span> }</span><br><span> snprintf(fn, sizeof(fn), "digits/%d", num);</span><br><span> num = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (num < 100) {</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (num < 100) {</span><br><span> snprintf(buf, 10, "%d", num);</span><br><span> if (last_length - strlen(buf) > 1 && last_length != 0) {</span><br><span> last_length = strlen(buf);</span><br><span>@@ -2656,7 +2656,7 @@</span><br><span> } else {</span><br><span> num = 0;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (num < 20) {</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (num < 20) {</span><br><span> if (options && strlen(options) == 1 && num < 3) {</span><br><span> snprintf(fn, sizeof(fn), "digits/%d%s", num, options);</span><br><span> } else {</span><br><span>@@ -2824,10 +2824,10 @@</span><br><span> } else if (playohz) {</span><br><span> ast_copy_string(fn, "digits/0-hundred-odd", sizeof(fn));</span><br><span> playohz = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (num < 20) {</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (num < 20) {</span><br><span> snprintf(fn, sizeof(fn), "digits/%d", num);</span><br><span> num = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (num < 100) {</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (num < 100) {</span><br><span> snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);</span><br><span> num %= 10;</span><br><span> if ((num == 5) || (num == 4) || (num == 1)) playl++;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15105">change 15105</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/+/15105"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ic7a70120188c9aa525a6d70289385bfce878438a </div>
<div style="display:none"> Gerrit-Change-Number: 15105 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Walter Doekes <walter+asterisk@wjd.nu> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>