I'm doing some experiments on risc-v, and found two changes I need. Since
they add no cost and are a bit more correct as to the intent of the code,
I'm mentioning them here.

In both cases, read is called, but in fact, a partial return is not
acceptable. Using readn makes that clear, as well as covering the case that
read and write can only do 1024 bytes at a time (I have reasons ...)

Impressively, these are the only changes I've found I needed for this
limited IO size case to let me do a full build of libraries and kernels.


+++ b/sys/src/cmd/mk/plan9.c
@@ -44,7 +44,7 @@ readenv(void)
                        if(f < 0)
                                continue;
                        p = Malloc(len+1);
-                       if(read(f, p, len) != len){
+                       if(readn(f, p, len) != len){
                                perror(path->start);
                                close(f);
                                continue;

+++ b/sys/src/libc/port/date.c
@@ -180,7 +180,7 @@ loadzone(Tzone *tz, char *name)
        f = open(path, OREAD|OCEXEC);
        if(f < 0)
                return -1;
-       r = read(f, buf, sizeof(buf));
+       r = readn(f, buf, sizeof(buf));

I am mentioning them here, in case multiple distros want them.

There are two changes to jl as well:
+++ b/sys/src/cmd/jl/obj.c
@@ -338,7 +338,7 @@ objfile(char *file)
        seek(f, off, 0);
        cnt = esym - off;
        start = malloc(cnt + 10);
-       cnt = read(f, start, cnt);
+       cnt = readn(f, start, cnt);
        if(cnt <= 0){
                close(f);
                return;
@@ -649,7 +649,7 @@ readsome(int f, uchar *buf, uchar *good, uchar *stop,
int max)
        n = MAXIO - n;
        if(n > max)
                n = max;
-       n = read(f, stop, n);
+       n = readn(f, stop, n);
        if(n <= 0)
                return 0;
        return stop + n;

but not everyone has jl yet.

------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Tbf658789fbb67968-M2e965e68f0df727a5353b0bd
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to