[libc-commits] [libc] 1a781e9 - [libc] Add missing casts in StrtolTest (#119054)

via libc-commits libc-commits at lists.llvm.org
Mon Dec 9 11:17:28 PST 2024


Author: Roland McGrath
Date: 2024-12-09T11:17:24-08:00
New Revision: 1a781e9ea6f7ed37ba89071f3ec402f68176a18e

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

LOG: [libc] Add missing casts in StrtolTest (#119054)

The a0c4f854cad2b97e44a1b58dc1fd982e1c4d60f3 change replaced the
local int_to_b36_char function returning `char` with uses of the
__support function of the same name that returns `int`.  The uses
of the old local function lacked the casts that all other uses of
the shared function of the same name had.  Add them.

Added: 
    

Modified: 
    libc/test/src/stdlib/StrtolTest.h

Removed: 
    


################################################################################
diff  --git a/libc/test/src/stdlib/StrtolTest.h b/libc/test/src/stdlib/StrtolTest.h
index 6cfaddcbedeb6a..ed302f14d03ef4 100644
--- a/libc/test/src/stdlib/StrtolTest.h
+++ b/libc/test/src/stdlib/StrtolTest.h
@@ -200,8 +200,8 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
     char small_string[4] = {'\0', '\0', '\0', '\0'};
     for (int base = 2; base <= 36; ++base) {
       for (int first_digit = 0; first_digit <= 36; ++first_digit) {
-        small_string[0] =
-            LIBC_NAMESPACE::internal::int_to_b36_char(first_digit);
+        small_string[0] = static_cast<char>(
+            LIBC_NAMESPACE::internal::int_to_b36_char(first_digit));
         if (first_digit < base) {
           LIBC_NAMESPACE::libc_errno = 0;
           ASSERT_EQ(func(small_string, nullptr, base),
@@ -217,11 +217,11 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
 
     for (int base = 2; base <= 36; ++base) {
       for (int first_digit = 0; first_digit <= 36; ++first_digit) {
-        small_string[0] =
-            LIBC_NAMESPACE::internal::int_to_b36_char(first_digit);
+        small_string[0] = static_cast<char>(
+            LIBC_NAMESPACE::internal::int_to_b36_char(first_digit));
         for (int second_digit = 0; second_digit <= 36; ++second_digit) {
-          small_string[1] =
-              LIBC_NAMESPACE::internal::int_to_b36_char(second_digit);
+          small_string[1] = static_cast<char>(
+              LIBC_NAMESPACE::internal::int_to_b36_char(second_digit));
           if (first_digit < base && second_digit < base) {
             LIBC_NAMESPACE::libc_errno = 0;
             ASSERT_EQ(
@@ -244,14 +244,14 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
 
     for (int base = 2; base <= 36; ++base) {
       for (int first_digit = 0; first_digit <= 36; ++first_digit) {
-        small_string[0] =
-            LIBC_NAMESPACE::internal::int_to_b36_char(first_digit);
+        small_string[0] = static_cast<char>(
+            LIBC_NAMESPACE::internal::int_to_b36_char(first_digit));
         for (int second_digit = 0; second_digit <= 36; ++second_digit) {
-          small_string[1] =
-              LIBC_NAMESPACE::internal::int_to_b36_char(second_digit);
+          small_string[1] = static_cast<char>(
+              LIBC_NAMESPACE::internal::int_to_b36_char(second_digit));
           for (int third_digit = 0; third_digit <= limit; ++third_digit) {
-            small_string[2] =
-                LIBC_NAMESPACE::internal::int_to_b36_char(third_digit);
+            small_string[2] = static_cast<char>(
+                LIBC_NAMESPACE::internal::int_to_b36_char(third_digit));
 
             if (first_digit < base && second_digit < base &&
                 third_digit < base) {


        


More information about the libc-commits mailing list