From 8ae751d3dac7ad4be26107f599521c4a59b51836 Mon Sep 17 00:00:00 2001 From: Awni Hannun Date: Wed, 21 Aug 2024 13:14:46 -0700 Subject: [PATCH] fix io (#1343) * fix io * fix io * comment --- mlx/io/load.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlx/io/load.h b/mlx/io/load.h index 565f748d8..ec9026c4f 100644 --- a/mlx/io/load.h +++ b/mlx/io/load.h @@ -70,7 +70,7 @@ class FileReader : public Reader { void read(char* data, size_t n) override { while (n != 0) { - auto m = ::read(fd_, data, n); + auto m = ::read(fd_, data, std::min(n, static_cast(INT32_MAX))); if (m <= 0) { std::ostringstream msg; msg << "[read] Unable to read " << n << " bytes from file."; @@ -123,7 +123,7 @@ class FileWriter : public Writer { void write(const char* data, size_t n) override { while (n != 0) { - auto m = ::write(fd_, data, n); + auto m = ::write(fd_, data, std::min(n, static_cast(INT32_MAX))); if (m <= 0) { std::ostringstream msg; msg << "[write] Unable to write " << n << " bytes to file.";