[libc][Obvious] Use the correct StringView constructor in dirent_test.
authorSiva Chandra Reddy <sivachandra@google.com>
Mon, 25 Jul 2022 20:45:46 +0000 (20:45 +0000)
committerSiva Chandra Reddy <sivachandra@google.com>
Mon, 25 Jul 2022 20:47:17 +0000 (20:47 +0000)
libc/test/src/dirent/dirent_test.cpp

index 6826c283a5caa4ad605342400111044d0a8d1bc5..f88122fcd589b06274064f0c5f593fccb53fe36f 100644 (file)
@@ -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;
   }