[libc-commits] [libc] 8fbc3c1 - [libc][Obvious] Use the correct StringView constructor in dirent_test.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Mon Jul 25 13:50:20 PDT 2022


Author: Siva Chandra Reddy
Date: 2022-07-25T20:47:17Z
New Revision: 8fbc3c1179e061e45f9da278d15d8adf489148a0

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

LOG: [libc][Obvious] Use the correct StringView constructor in dirent_test.

Added: 
    

Modified: 
    libc/test/src/dirent/dirent_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/dirent/dirent_test.cpp b/libc/test/src/dirent/dirent_test.cpp
index 6826c283a5caa..f88122fcd589b 100644
--- a/libc/test/src/dirent/dirent_test.cpp
+++ b/libc/test/src/dirent/dirent_test.cpp
@@ -27,18 +27,19 @@ TEST(LlvmLibcDirentTest, SimpleOpenAndRead) {
   // greater than 2.
   ASSERT_GT(__llvm_libc::dirfd(dir), 2);
 
-  struct ::dirent *file1, *file2, *dir1, *dir2;
+  struct ::dirent *file1 = nullptr, *file2 = nullptr, *dir1 = nullptr,
+                  *dir2 = nullptr;
   while (true) {
     struct ::dirent *d = __llvm_libc::readdir(dir);
     if (d == nullptr)
       break;
-    if (StringView(d->d_name).equals("file1.txt"))
+    if (StringView(&d->d_name[0]).equals("file1.txt"))
       file1 = d;
-    if (StringView(d->d_name).equals("file2.txt"))
+    if (StringView(&d->d_name[0]).equals("file2.txt"))
       file2 = d;
-    if (StringView(d->d_name).equals("dir1"))
+    if (StringView(&d->d_name[0]).equals("dir1"))
       dir1 = d;
-    if (StringView(d->d_name).equals("dir2.txt"))
+    if (StringView(&d->d_name[0]).equals("dir2"))
       dir2 = d;
   }
 


        


More information about the libc-commits mailing list