Skip to content

Conversation

@codefaber
Copy link
Contributor

Fix using wrong variable due to copy/paste error.

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc label Jul 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 26, 2025

@llvm/pr-subscribers-libc

Author: None (codefaber)

Changes

Fix using wrong variable due to copy/paste error.


Full diff: https://github.com/llvm/llvm-project/pull/150802.diff

1 Files Affected:

  • (modified) libc/src/__support/File/file.cpp (+1-1)
diff --git a/libc/src/__support/File/file.cpp b/libc/src/__support/File/file.cpp
index 303852dbbb717..4217e73828388 100644
--- a/libc/src/__support/File/file.cpp
+++ b/libc/src/__support/File/file.cpp
@@ -123,7 +123,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 = buf_result.value;
+    size_t 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|.

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can you add a test that'd catch this error?

@codefaber
Copy link
Contributor Author

OK

@github-actions
Copy link

github-actions bot commented Aug 3, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR. Do you need me to merge this for you?

@codefaber
Copy link
Contributor Author

Yes, please merge it. Thanks.

@michaelrj-google michaelrj-google merged commit fd7f69b into llvm:main Aug 19, 2025
19 checks passed
@github-actions
Copy link

@codefaber Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 19, 2025

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-dbg-asan running on libc-x86_64-debian while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/147/builds/27438

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[ RUN      ] LlvmLibcFMinimumTest.InfArg
[       OK ] LlvmLibcFMinimumTest.InfArg (14 us)
[ RUN      ] LlvmLibcFMinimumTest.NegInfArg
[       OK ] LlvmLibcFMinimumTest.NegInfArg (13 us)
[ RUN      ] LlvmLibcFMinimumTest.BothZero
[       OK ] LlvmLibcFMinimumTest.BothZero (10 us)
[ RUN      ] LlvmLibcFMinimumTest.Range
[       OK ] LlvmLibcFMinimumTest.Range (228 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[507/1205] Running unit test libc.test.src.__support.File.file_test.__unit__
FAILED: libc/test/src/__support/File/CMakeFiles/libc.test.src.__support.File.file_test.__unit__ /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/__support/File/CMakeFiles/libc.test.src.__support.File.file_test.__unit__ 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/__support/File && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/__support/File/libc.test.src.__support.File.file_test.__unit__.__build__
[==========] Running 13 tests from 1 test suite.
[ RUN      ] LlvmLibcFileTest.WriteOnly
[       OK ] LlvmLibcFileTest.WriteOnly (205 us)
[ RUN      ] LlvmLibcFileTest.WriteLineBuffered
[       OK ] LlvmLibcFileTest.WriteLineBuffered (62 us)
[ RUN      ] LlvmLibcFileTest.WriteUnbuffered
[       OK ] LlvmLibcFileTest.WriteUnbuffered (12 us)
[ RUN      ] LlvmLibcFileTest.ReadOnly
[       OK ] LlvmLibcFileTest.ReadOnly (35 us)
[ RUN      ] LlvmLibcFileTest.ReadSeekCurAndRead
[       OK ] LlvmLibcFileTest.ReadSeekCurAndRead (30 us)
[ RUN      ] LlvmLibcFileTest.AppendOnly
[       OK ] LlvmLibcFileTest.AppendOnly (26 us)
[ RUN      ] LlvmLibcFileTest.WriteUpdate
[       OK ] LlvmLibcFileTest.WriteUpdate (25 us)
[ RUN      ] LlvmLibcFileTest.ReadUpdate
[       OK ] LlvmLibcFileTest.ReadUpdate (72 us)
[ RUN      ] LlvmLibcFileTest.AppendUpdate
[       OK ] LlvmLibcFileTest.AppendUpdate (47 us)
[ RUN      ] LlvmLibcFileTest.SmallBuffer
[       OK ] LlvmLibcFileTest.SmallBuffer (59 us)
[ RUN      ] LlvmLibcFileTest.ZeroLengthBuffer
[       OK ] LlvmLibcFileTest.ZeroLengthBuffer (59 us)
[ RUN      ] LlvmLibcFileTest.WriteNothing
[       OK ] LlvmLibcFileTest.WriteNothing (42 us)
[ RUN      ] LlvmLibcFileTest.WriteSplit
[       OK ] LlvmLibcFileTest.WriteSplit (13 us)
Ran 13 tests.  PASS: 13  FAIL: 0

=================================================================
==3342890==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 664 byte(s) in 1 object(s) allocated from:
    #0 0x5592c1d4d46e in malloc (/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/__support/File/libc.test.src.__support.File.file_test.__unit__.__build__+0xae46e) (BuildId: e7b8088b054e0a2a061c36457aa0573a8df8a350)
    #1 0x5592c1da2fa8 in __llvm_libc_20_0_0_git::AllocChecker::alloc(unsigned long, __llvm_libc_20_0_0_git::AllocChecker&) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/__support/CPP/new.h:54:17
    #2 0x5592c1d9f8fc in operator new(unsigned long, __llvm_libc_20_0_0_git::AllocChecker&) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/__support/CPP/new.h:79:10
    #3 0x5592c1d8b527 in new_string_file(char*, unsigned long, int, bool, char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/__support/File/file_test.cpp:112:10

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 19, 2025

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-fullbuild-dbg-asan running on libc-x86_64-debian-fullbuild while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/171/builds/28692

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[ RUN      ] LlvmLibcFMaximumNumTest.InfArg
[       OK ] LlvmLibcFMaximumNumTest.InfArg (17 us)
[ RUN      ] LlvmLibcFMaximumNumTest.NegInfArg
[       OK ] LlvmLibcFMaximumNumTest.NegInfArg (16 us)
[ RUN      ] LlvmLibcFMaximumNumTest.BothZero
[       OK ] LlvmLibcFMaximumNumTest.BothZero (13 us)
[ RUN      ] LlvmLibcFMaximumNumTest.Range
[       OK ] LlvmLibcFMaximumNumTest.Range (283 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[486/1350] Running unit test libc.test.src.__support.File.file_test.__unit__
FAILED: libc/test/src/__support/File/CMakeFiles/libc.test.src.__support.File.file_test.__unit__ /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/__support/File/CMakeFiles/libc.test.src.__support.File.file_test.__unit__ 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/__support/File && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/__support/File/libc.test.src.__support.File.file_test.__unit__.__build__
[==========] Running 13 tests from 1 test suite.
[ RUN      ] LlvmLibcFileTest.WriteOnly
[       OK ] LlvmLibcFileTest.WriteOnly (146 us)
[ RUN      ] LlvmLibcFileTest.WriteLineBuffered
[       OK ] LlvmLibcFileTest.WriteLineBuffered (54 us)
[ RUN      ] LlvmLibcFileTest.WriteUnbuffered
[       OK ] LlvmLibcFileTest.WriteUnbuffered (24 us)
[ RUN      ] LlvmLibcFileTest.ReadOnly
[       OK ] LlvmLibcFileTest.ReadOnly (43 us)
[ RUN      ] LlvmLibcFileTest.ReadSeekCurAndRead
[       OK ] LlvmLibcFileTest.ReadSeekCurAndRead (16 us)
[ RUN      ] LlvmLibcFileTest.AppendOnly
[       OK ] LlvmLibcFileTest.AppendOnly (20 us)
[ RUN      ] LlvmLibcFileTest.WriteUpdate
[       OK ] LlvmLibcFileTest.WriteUpdate (30 us)
[ RUN      ] LlvmLibcFileTest.ReadUpdate
[       OK ] LlvmLibcFileTest.ReadUpdate (19 us)
[ RUN      ] LlvmLibcFileTest.AppendUpdate
[       OK ] LlvmLibcFileTest.AppendUpdate (41 us)
[ RUN      ] LlvmLibcFileTest.SmallBuffer
[       OK ] LlvmLibcFileTest.SmallBuffer (10 us)
[ RUN      ] LlvmLibcFileTest.ZeroLengthBuffer
[       OK ] LlvmLibcFileTest.ZeroLengthBuffer (48 us)
[ RUN      ] LlvmLibcFileTest.WriteNothing
[       OK ] LlvmLibcFileTest.WriteNothing (40 us)
[ RUN      ] LlvmLibcFileTest.WriteSplit
[       OK ] LlvmLibcFileTest.WriteSplit (19 us)
Ran 13 tests.  PASS: 13  FAIL: 0

=================================================================
==3617037==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 664 byte(s) in 1 object(s) allocated from:
    #0 0x56334486843e in malloc (/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/__support/File/libc.test.src.__support.File.file_test.__unit__.__build__+0xad43e) (BuildId: 81418e6817efac9bdae511923971c3859a81e15e)
    #1 0x5633448bd768 in __llvm_libc_20_0_0_git::AllocChecker::alloc(unsigned long, __llvm_libc_20_0_0_git::AllocChecker&) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/new.h:54:17
    #2 0x5633448ba68c in operator new(unsigned long, __llvm_libc_20_0_0_git::AllocChecker&) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/new.h:79:10
    #3 0x5633448a64f7 in new_string_file(char*, unsigned long, int, bool, char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/__support/File/file_test.cpp:112:10

michaelrj-google added a commit to michaelrj-google/llvm-project that referenced this pull request Aug 19, 2025
The test added by llvm#150802 was missing a close at the end.
michaelrj-google added a commit that referenced this pull request Aug 19, 2025
The test added by #150802 was missing a close at the end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants