authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-10 23:19:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-11 15:39:49-08:00
log476cbe871aedf13a48be040dd04aa2fc5e59332a
tree2826230fdb6823d727eebdf47f09214eab26fa4d
parentfe8951cc941a55b23387b8d8bc09c62ea71409dd

fix build failures on 32-bit arm due to u64/usize coercion


2 files changed, 33 insertions(+), 7 deletions(-)

lib/std/http/Client.zig+25-1
......@@ -625,6 +625,29 @@ pub const Request = struct {
625625 InvalidSignature,
626626 NotSquare,
627627 DiskQuota,
628 InvalidEnd,
629 Incomplete,
630 InvalidIpv4Mapping,
631 InvalidIPAddressFormat,
632 BadPathName,
633 DeviceBusy,
634 FileBusy,
635 FileLocksNotSupported,
636 InvalidHandle,
637 InvalidUtf8,
638 NameTooLong,
639 NoDevice,
640 PathAlreadyExists,
641 PipeBusy,
642 SharingViolation,
643 SymLinkLoop,
644 FileSystem,
645 InterfaceNotFound,
646 AlreadyBound,
647 FileDescriptorNotASocket,
648 NetworkSubsystemFailed,
649 NotDir,
650 ReadOnlyFileSystem,
628651 };
629652
630653 pub fn read(req: *Request, buffer: []u8) ReadError!usize {
......@@ -770,7 +793,8 @@ pub const Request = struct {
770793 }
771794 },
772795 .chunk_data => {
773 const sub_amt = @min(req.response.next_chunk_length, in.len);
796 // TODO https://github.com/ziglang/zig/issues/14039
797 const sub_amt = @intCast(usize, @min(req.response.next_chunk_length, in.len));
774798 req.response.next_chunk_length -= sub_amt;
775799 if (req.response.next_chunk_length > 0) {
776800 if (in.ptr == buffer.ptr) {
lib/std/tar.zig+8-6
......@@ -93,7 +93,7 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
9393 start += 512;
9494 const file_size = try header.fileSize();
9595 const rounded_file_size = std.mem.alignForwardGeneric(u64, file_size, 512);
96 const pad_len = rounded_file_size - file_size;
96 const pad_len = @intCast(usize, rounded_file_size - file_size);
9797 const unstripped_file_name = try header.fullFileName(&file_name_buffer);
9898 switch (header.fileType()) {
9999 .directory => {
......@@ -117,13 +117,15 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
117117 start = 0;
118118 }
119119 // Ask for the rounded up file size + 512 for the next header.
120 const ask = @min(
120 // TODO: https://github.com/ziglang/zig/issues/14039
121 const ask = @intCast(usize, @min(
121122 buffer.len - end,
122123 rounded_file_size + 512 - file_off -| (end - start),
123 );
124 ));
124125 end += try reader.readAtLeast(buffer[end..], ask);
125126 if (end - start < ask) return error.UnexpectedEndOfStream;
126 const slice = buffer[start..@min(file_size - file_off + start, end)];
127 // TODO: https://github.com/ziglang/zig/issues/14039
128 const slice = buffer[start..@intCast(usize, @min(file_size - file_off + start, end))];
127129 try file.writeAll(slice);
128130 file_off += slice.len;
129131 start += slice.len;
......@@ -136,8 +138,8 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
136138 }
137139 },
138140 .global_extended_header, .extended_header => {
139 start += rounded_file_size;
140 if (start > end) return error.TarHeadersTooBig;
141 if (start + rounded_file_size > end) return error.TarHeadersTooBig;
142 start = @intCast(usize, start + rounded_file_size);
141143 },
142144 .hard_link => return error.TarUnsupportedFileType,
143145 .symbolic_link => return error.TarUnsupportedFileType,