mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
55 lines
2.2 KiB
Diff
55 lines
2.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Tyler Veness <calcmogul@gmail.com>
|
|
Date: Wed, 18 May 2022 10:21:49 -0700
|
|
Subject: [PATCH 1/3] Don't throw on write failure
|
|
|
|
---
|
|
include/fmt/format-inl.h | 4 +---
|
|
include/fmt/xchar.h | 3 +--
|
|
src/os.cc | 3 +--
|
|
3 files changed, 3 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h
|
|
index 22b1ec8df0eb14b3f7f21797a19586b50b8423fd..abe4ff13db6287f9c5229df6c4b46beeed020bce 100644
|
|
--- a/include/fmt/format-inl.h
|
|
+++ b/include/fmt/format-inl.h
|
|
@@ -79,9 +79,7 @@ FMT_FUNC void report_error(format_func func, int error_code,
|
|
// A wrapper around fwrite that throws on error.
|
|
inline void fwrite_fully(const void* ptr, size_t size, size_t count,
|
|
FILE* stream) {
|
|
- size_t written = std::fwrite(ptr, size, count, stream);
|
|
- if (written < count)
|
|
- FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
|
+ std::fwrite(ptr, size, count, stream);
|
|
}
|
|
|
|
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
|
diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h
|
|
index 3b5bc15ca0a1d92d721611ddc70e80f098fb79ae..fc3c67f21c2294b8e73d6ea53f25c877f733082c 100644
|
|
--- a/include/fmt/xchar.h
|
|
+++ b/include/fmt/xchar.h
|
|
@@ -200,8 +200,7 @@ inline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {
|
|
wmemory_buffer buffer;
|
|
detail::vformat_to(buffer, fmt, args);
|
|
buffer.push_back(L'\0');
|
|
- if (std::fputws(buffer.data(), f) == -1)
|
|
- FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
|
+ std::fputws(buffer.data(), f);
|
|
}
|
|
|
|
inline void vprint(wstring_view fmt, wformat_args args) {
|
|
diff --git a/src/os.cc b/src/os.cc
|
|
index f388ead0191b61ae0e5c24692c1f523aae3c9fbb..2c499512b5396830d7f1eb8fb5874586898802dd 100644
|
|
--- a/src/os.cc
|
|
+++ b/src/os.cc
|
|
@@ -277,8 +277,7 @@ std::size_t file::read(void* buffer, std::size_t count) {
|
|
std::size_t file::write(const void* buffer, std::size_t count) {
|
|
rwresult result = 0;
|
|
FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count))));
|
|
- if (result < 0) FMT_THROW(system_error(errno, "cannot write to file"));
|
|
- return detail::to_unsigned(result);
|
|
+ return count;
|
|
}
|
|
|
|
file file::dup(int fd) {
|