This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 2faea203a3 prefetch: make char explicitly signed (#10048)
2faea203a3 is described below

commit 2faea203a3f67631cc7e8b0b93a836df9afedcb2
Author: Brian Neradt <[email protected]>
AuthorDate: Mon Jul 17 11:06:11 2023 -0500

    prefetch: make char explicitly signed (#10048)
    
    The plugins/prefetch/evaluate.cc sub() function assumed that char would
    be signed. char is signed for most x86 systems but not for all systems,
    such as arm64. This makes the variable explicitly signed.
    
    Fixes #10047
---
 plugins/prefetch/evaluate.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/plugins/prefetch/evaluate.cc b/plugins/prefetch/evaluate.cc
index 271cd287b8..2ef1120723 100644
--- a/plugins/prefetch/evaluate.cc
+++ b/plugins/prefetch/evaluate.cc
@@ -32,14 +32,14 @@
 namespace
 {
 
-inline char
+inline int8_t
 tonum(char ch)
 {
   return ch - '0';
 }
 
 inline char
-tochar(char ch)
+tochar(int8_t ch)
 {
   return ch + '0';
 }
@@ -74,7 +74,7 @@ add(StringView const lhs, StringView const rhs)
   auto ito = other.crbegin();
 
   while (ito != other.crend()) {
-    char val = tonum(*itr) + tonum(*ito);
+    int8_t val = tonum(*itr) + tonum(*ito);
     if (carry) {
       ++val;
     }
@@ -92,7 +92,7 @@ add(StringView const lhs, StringView const rhs)
   }
 
   while (result.rend() != itr && carry) {
-    char val = tonum(*itr) + 1;
+    int8_t val = tonum(*itr) + 1;
     if (val < 10) {
       carry = false;
     } else {
@@ -129,7 +129,7 @@ sub(StringView const lhs, StringView const rhs)
   auto itb = rhs.crbegin();
 
   while (result.rend() != itr && rhs.crend() != itb) {
-    char val = tonum(*itr) - tonum(*itb);
+    int8_t val = tonum(*itr) - tonum(*itb);
     if (borrow) {
       --val;
     }
@@ -148,7 +148,7 @@ sub(StringView const lhs, StringView const rhs)
 
   // keep pushing borrow
   while (result.rend() != itr && borrow) {
-    char val = tonum(*itr) - 1;
+    int8_t val = tonum(*itr) - 1;
     if (val < 0) {
       borrow  = true;
       val    += 10;

Reply via email to