[libc-commits] [libc] b1372fe - [libc] Fix -Wimplicit-int-conversion warnings

Alex Brachet via libc-commits libc-commits at lists.llvm.org
Tue Jan 10 08:42:02 PST 2023


Author: Alex Brachet
Date: 2023-01-10T16:41:28Z
New Revision: b1372fe7b088ba2d2fd564c5f85de4dc4d5bb090

URL: https://github.com/llvm/llvm-project/commit/b1372fe7b088ba2d2fd564c5f85de4dc4d5bb090
DIFF: https://github.com/llvm/llvm-project/commit/b1372fe7b088ba2d2fd564c5f85de4dc4d5bb090.diff

LOG: [libc] Fix -Wimplicit-int-conversion warnings

Differential Revision: https://reviews.llvm.org/D140492

Added: 
    

Modified: 
    libc/src/__support/StringUtil/message_mapper.h
    libc/src/__support/integer_to_string.h

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/StringUtil/message_mapper.h b/libc/src/__support/StringUtil/message_mapper.h
index ae8e7593edd2d..1e0df4f056a7d 100644
--- a/libc/src/__support/StringUtil/message_mapper.h
+++ b/libc/src/__support/StringUtil/message_mapper.h
@@ -45,7 +45,7 @@ template <size_t ARR_SIZE, size_t TOTAL_STR_LEN> class MessageMapper {
     for (size_t i = 0; i < raw_array_len; ++i)
       string_mappings[raw_array[i].num] = raw_array[i].msg;
 
-    size_t string_array_index = 0;
+    int string_array_index = 0;
     for (size_t cur_num = 0; cur_num < ARR_SIZE; ++cur_num) {
       if (string_mappings[cur_num].size() != 0) {
         msg_offsets[cur_num] = string_array_index;

diff  --git a/libc/src/__support/integer_to_string.h b/libc/src/__support/integer_to_string.h
index 2888ab3dd12a7..9d8cddabd59f2 100644
--- a/libc/src/__support/integer_to_string.h
+++ b/libc/src/__support/integer_to_string.h
@@ -59,7 +59,7 @@ class IntegerToString {
     } else {
       for (; uval > 0; --buffptr, uval /= conv_base) {
         uintmax_t digit = (uval % conv_base);
-        buffer[buffptr - 1] = digit < 10 ? digit + '0' : digit + a - 10;
+        buffer[buffptr - 1] = static_cast<char>(digit < 10 ? digit + '0' : digit + a - 10);
       }
     }
     len = buffer.size() - buffptr;


        


More information about the libc-commits mailing list