<p>Alexander Traud has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7815">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">translate: Avoid absolute value on unsigned substraction.<br><br>ast_format_get_sample_rate(.) returns an unsigned type. The difference of a<br>substraction between two unsigned types does not get implicitly converted to a<br>signed type. Therefore, using abs(.) did not make sense.<br><br>ASTERISK-27549<br><br>Change-Id: Ib904d9ee0d46b6fdd1476fbc464fbbf813304017<br>---<br>M main/translate.c<br>1 file changed, 10 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/15/7815/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/translate.c b/main/translate.c<br>index 02717c5..6da60ad 100644<br>--- a/main/translate.c<br>+++ b/main/translate.c<br>@@ -32,7 +32,6 @@<br> #include <sys/time.h><br> #include <sys/resource.h><br> #include <math.h><br>-#include <stdlib.h><br> <br> #include "asterisk/lock.h"<br> #include "asterisk/channel.h"<br>@@ -1415,10 +1414,16 @@<br>                             beststeps = matrix_get(x, y)->multistep;<br>                   } else if (matrix_get(x, y)->table_cost == besttablecost<br>                                   && matrix_get(x, y)->multistep == beststeps) {<br>-                            int gap_selected = abs(ast_format_get_sample_rate(best)<br>-                                      - ast_format_get_sample_rate(bestdst));<br>-                              int gap_current = abs(ast_format_get_sample_rate(src)<br>-                                        - ast_format_get_sample_rate(dst));<br>+                          unsigned int gap_selected_src = ast_format_get_sample_rate(best);<br>+                            unsigned int gap_selected_dst = ast_format_get_sample_rate(bestdst);<br>+                         unsigned int gap_selected = (gap_selected_src > gap_selected_dst)<br>+                                 ? gap_selected_src - gap_selected_dst<br>+                                        : gap_selected_dst - gap_selected_src;<br>+                               unsigned int gap_current_src = ast_format_get_sample_rate(src);<br>+                              unsigned int gap_current_dst = ast_format_get_sample_rate(dst);<br>+                              unsigned int gap_current = (gap_current_src > gap_current_dst)<br>+                                    ? gap_current_src - gap_current_dst<br>+                                  : gap_current_dst - gap_current_src;<br> <br>                               if (gap_current < gap_selected) {<br>                                  /* better than what we have so far */<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7815">change 7815</a>. To unsubscribe, 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/7815"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib904d9ee0d46b6fdd1476fbc464fbbf813304017 </div>
<div style="display:none"> Gerrit-Change-Number: 7815 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexander Traud <pabstraud@compuserve.com> </div>