[libc-commits] [libc] [libc] Move a few -Wshadow warnings in __support/File (PR #196810)

Nico Weber via libc-commits libc-commits at lists.llvm.org
Sun May 10 07:36:50 PDT 2026


https://github.com/nico created https://github.com/llvm/llvm-project/pull/196810

No behavior change.

>From 894608202d4719573ae664cd3ed8eb60b1f82720 Mon Sep 17 00:00:00 2001
From: Nico Weber <thakis at chromium.org>
Date: Sun, 10 May 2026 10:36:03 -0400
Subject: [PATCH] [libc] Move a few -Wshadow warnings in __support/File

No behavior change.
---
 libc/src/__support/File/file.cpp       | 10 +++++-----
 libc/src/__support/File/linux/file.cpp |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libc/src/__support/File/file.cpp b/libc/src/__support/File/file.cpp
index 31e6b7dab95a2..1499ab56578a9 100644
--- a/libc/src/__support/File/file.cpp
+++ b/libc/src/__support/File/file.cpp
@@ -170,7 +170,7 @@ FileIOResult File::write_unlocked_fbf(const uint8_t *data, size_t len) {
 
     FileIOResult result =
         platform_write(this, remainder.data(), remainder.size());
-    size_t bytes_written = result.value;
+    bytes_written = result.value;
 
     // If less bytes were written than expected, then an error occurred. Return
     // the number of bytes that have been written from |data|.
@@ -658,8 +658,8 @@ wint_t File::ungetwc_unlocked(wint_t wc) {
     break;
   }
 
-  char buf[4];
-  auto result = internal::wcrtomb(buf, static_cast<wchar_t>(wc), &mbstate);
+  char mb_buf[4];
+  auto result = internal::wcrtomb(mb_buf, static_cast<wchar_t>(wc), &mbstate);
   if (!result.has_value())
     return WEOF;
 
@@ -670,7 +670,7 @@ wint_t File::ungetwc_unlocked(wint_t wc) {
       return WEOF;
 
     for (size_t i = 0; i < n; ++i)
-      this->buf[i] = static_cast<uint8_t>(buf[i]);
+      buf[i] = static_cast<uint8_t>(mb_buf[i]);
 
     read_limit = n;
     pos = 0;
@@ -679,7 +679,7 @@ wint_t File::ungetwc_unlocked(wint_t wc) {
       return WEOF;
     pos -= n;
     for (size_t i = 0; i < n; ++i)
-      this->buf[pos + i] = static_cast<uint8_t>(buf[i]);
+      buf[pos + i] = static_cast<uint8_t>(mb_buf[i]);
   }
   eof = false;
   err = false;
diff --git a/libc/src/__support/File/linux/file.cpp b/libc/src/__support/File/linux/file.cpp
index 10a6f2a97dc41..2bef96a102a0c 100644
--- a/libc/src/__support/File/linux/file.cpp
+++ b/libc/src/__support/File/linux/file.cpp
@@ -169,7 +169,7 @@ ErrorOr<LinuxFile *> create_file_from_fd(int fd, const char *mode) {
   }
   File::add_file(file);
   if (do_seek) {
-    auto result = file->seek(0, SEEK_END);
+    result = file->seek(0, SEEK_END);
     if (!result.has_value()) {
       File::remove_file(file);
       delete file;



More information about the libc-commits mailing list