commit 3ab69790dd41093a2a3ae7e35a7497f9b3f51c88
parent 63d7991a6acfbee0b340e7528dc250b4dd3885ff
Author: Drew DeVault <sir@cmpwn.com>
Date: Mon, 1 Feb 2021 14:46:03 -0500
Remove hacks with slice casts
Diffstat:
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/os/+linux/fdstream.ha b/os/+linux/fdstream.ha
@@ -46,7 +46,7 @@ fn static_fdopen(fd: int, name: str, stream: *fd_stream) void = {
fn fd_read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = {
let stream = s: *fd_stream;
- let r = rt::read(stream.fd, (&buf: *types::slice).data: *[*]u8, len(buf));
+ let r = rt::read(stream.fd, buf: *[*]u8, len(buf));
return match (rt::wrap_return(r)) {
err: rt::errno => errno_to_io(err),
n: size => switch (n) {
@@ -59,8 +59,7 @@ fn fd_read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = {
fn fd_write(s: *io::stream, buf: const []u8) (size | io::error) = {
let stream = s: *fd_stream;
- let r = rt::write(stream.fd,
- (&buf: *types::slice).data: *const [*]u8, len(buf));
+ let r = rt::write(stream.fd, buf: *const [*]u8, len(buf));
return match (rt::wrap_return(r)) {
err: rt::errno => errno_to_io(err),
n: size => n,
diff --git a/os/+linux/open.ha b/os/+linux/open.ha
@@ -18,8 +18,7 @@ export fn open(path: (str | []u8), mode: io::mode) (*io::stream | io::error) = {
b: []u8 => "<open([]u8)>", // TODO: try to decode it?
};
- // TODO: Cast slice to array
- let r = rt::open((&p: *types::slice).data: *const char, mode: int, 0u);
+ let r = rt::open(p: *[*]u8: *const char, mode: int, 0u);
let fd: int = match (rt::wrap_return(r)) {
err: rt::errno => return errno_to_io(err),
n: size => n: int,
diff --git a/strings/utf8.ha b/strings/utf8.ha
@@ -4,7 +4,7 @@ use types;
// valid UTF-8 string.
export fn from_utf8_unsafe(in: []u8) str = {
const s = types::string {
- data = (&in: *types::slice).data: *[*]u8,
+ data = in: *[*]u8,
length = len(in),
capacity = len(in),
};