[libc-commits] [libc] ad709a7 - [libc][obvious] fix sign warning in file_writer

Michael Jones via libc-commits libc-commits at lists.llvm.org
Fri Jun 17 09:48:09 PDT 2022


Author: Michael Jones
Date: 2022-06-17T09:48:04-07:00
New Revision: ad709a752daa6aebf03a3d34fc5b2e24a8a0dbea

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

LOG: [libc][obvious] fix sign warning in file_writer

In the sign writer, a size_t was being compared to an int. This patch
casts the size_t to an int so that the comparison doesn't cause a sign
comparison warning.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D127984

Added: 
    

Modified: 
    libc/src/stdio/printf_core/file_writer.cpp

Removed: 
    


################################################################################
diff  --git a/libc/src/stdio/printf_core/file_writer.cpp b/libc/src/stdio/printf_core/file_writer.cpp
index 3f84dddaf275e..b87ae626a1df6 100644
--- a/libc/src/stdio/printf_core/file_writer.cpp
+++ b/libc/src/stdio/printf_core/file_writer.cpp
@@ -15,7 +15,7 @@ namespace printf_core {
 
 int FileWriter::write(const char *__restrict to_write, size_t len) {
   int written = file->write_unlocked(to_write, len);
-  if (written != len)
+  if (written != static_cast<int>(len))
     written = -1;
   if (file->error_unlocked())
     written = -2;


        


More information about the libc-commits mailing list