ref: bcf54c0bfb188214f6097cf02fe60040cf0d6d7f
parent: 46070c3122227f5fc04c9b7a29d0652600fa7074
author: cinap_lenrek <[email protected]>
date: Wed Apr 15 21:20:30 EDT 2015
kernel: pass segio error string by pointer there's no need to waste space for a error buffer in the Segio structure, as the segmentio kproc will be waiting for the next command after an error and will not overwite it until we issue another command.
--- a/sys/src/9/port/portdat.h
+++ b/sys/src/9/port/portdat.h
@@ -406,7 +406,7 @@
char *addr;
int dlen;
int cmd;
- char err[64];
+ char *err;
};
enum
--- a/sys/src/9/port/segment.c
+++ b/sys/src/9/port/segment.c
@@ -797,11 +797,11 @@
static void
docmd(Segio *sio, int cmd)
{
- sio->err[0] = 0;
+ sio->err = nil;
sio->cmd = cmd;
wakeup(&sio->cmdwait);
sleep(&sio->replywait, cmddone, sio);
- if(sio->err[0])
+ if(sio->err != nil)
error(sio->err);
}
@@ -838,10 +838,9 @@
;
for(done = 0; !done;){
sleep(&sio->cmdwait, cmdready, sio);
- if(waserror()){
- strncpy(sio->err, up->errstr, sizeof(sio->err)-1);
- sio->err[sizeof(sio->err)-1] = 0;
- } else {
+ if(waserror())
+ sio->err = up->errstr;
+ else {
if(sio->s != nil && up->seg[sno] != sio->s){
putseg(up->seg[sno]);
incref(sio->s);