[libc-commits] [PATCH] D127984: [libc][obvious] fix sign warning in file_writer

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jun 16 10:14:54 PDT 2022

michaelrj created this revision.
michaelrj added reviewers: sivachandra, lntue.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
michaelrj requested review of this revision.

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.

  rG LLVM Github Monorepo



Index: libc/src/stdio/printf_core/file_writer.cpp
--- libc/src/stdio/printf_core/file_writer.cpp
+++ libc/src/stdio/printf_core/file_writer.cpp
@@ -15,7 +15,7 @@
 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;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127984.437589.patch
Type: text/x-patch
Size: 489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220616/522ebf7e/attachment.bin>

More information about the libc-commits mailing list