cast to usize for non 64 bit targets
Some checks failed
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Failing after 4m10s

This commit is contained in:
Emil Lerch 2023-08-15 08:41:06 -07:00
parent bad00517a3
commit db82116103
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -131,9 +131,9 @@ fn getContainerCredentials(allocator: std.mem.Allocator) !?auth.Credentials {
if (req.response.status == .not_found) return null; if (req.response.status == .not_found) return null;
if (req.response.content_length == null or req.response.content_length.? == 0) return null; if (req.response.content_length == null or req.response.content_length.? == 0) return null;
var resp_payload = try std.ArrayList(u8).initCapacity(allocator, req.response.content_length.?); var resp_payload = try std.ArrayList(u8).initCapacity(allocator, @intCast(req.response.content_length.?));
defer resp_payload.deinit(); defer resp_payload.deinit();
try resp_payload.resize(req.response.content_length.?); try resp_payload.resize(@intCast(req.response.content_length.?));
var response_data = try resp_payload.toOwnedSlice(); var response_data = try resp_payload.toOwnedSlice();
defer allocator.free(response_data); defer allocator.free(response_data);
_ = try req.readAll(response_data); _ = try req.readAll(response_data);
@ -192,9 +192,9 @@ fn getImdsv2Credentials(allocator: std.mem.Allocator) !?auth.Credentials {
return null; return null;
} }
var resp_payload = try std.ArrayList(u8).initCapacity(allocator, req.response.content_length.?); var resp_payload = try std.ArrayList(u8).initCapacity(allocator, @intCast(req.response.content_length.?));
defer resp_payload.deinit(); defer resp_payload.deinit();
try resp_payload.resize(req.response.content_length.?); try resp_payload.resize(@intCast(req.response.content_length.?));
token = try resp_payload.toOwnedSlice(); token = try resp_payload.toOwnedSlice();
errdefer if (token) |t| allocator.free(t); errdefer if (token) |t| allocator.free(t);
_ = try req.readAll(token.?); _ = try req.readAll(token.?);
@ -238,9 +238,9 @@ fn getImdsRoleName(allocator: std.mem.Allocator, client: *std.http.Client, imds_
return null; return null;
} }
// TODO: This is all stupid. We can just allocate a freaking array and be done // TODO: This is all stupid. We can just allocate a freaking array and be done
var resp_payload = try std.ArrayList(u8).initCapacity(allocator, req.response.content_length.?); var resp_payload = try std.ArrayList(u8).initCapacity(allocator, @intCast(req.response.content_length.?));
defer resp_payload.deinit(); defer resp_payload.deinit();
try resp_payload.resize(req.response.content_length.?); try resp_payload.resize(@intCast(req.response.content_length.?));
// TODO: This feels safer, but can we avoid this? // TODO: This feels safer, but can we avoid this?
const resp = try resp_payload.toOwnedSlice(); const resp = try resp_payload.toOwnedSlice();
defer allocator.free(resp); defer allocator.free(resp);
@ -296,9 +296,9 @@ fn getImdsCredentials(allocator: std.mem.Allocator, client: *std.http.Client, ro
return null; return null;
} }
// TODO: This is still stupid // TODO: This is still stupid
var resp_payload = try std.ArrayList(u8).initCapacity(allocator, req.response.content_length.?); var resp_payload = try std.ArrayList(u8).initCapacity(allocator, @intCast(req.response.content_length.?));
defer resp_payload.deinit(); defer resp_payload.deinit();
try resp_payload.resize(req.response.content_length.?); try resp_payload.resize(@intCast(req.response.content_length.?));
const resp = try resp_payload.toOwnedSlice(); const resp = try resp_payload.toOwnedSlice();
defer allocator.free(resp); defer allocator.free(resp);
_ = try req.readAll(resp); _ = try req.readAll(resp);