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.
This commit is contained in:
cinap_lenrek 2015-04-16 01:20:30 +02:00
parent 46070c3122
commit bcf54c0bfb
2 changed files with 6 additions and 7 deletions

View file

@ -406,7 +406,7 @@ struct Segio
char *addr;
int dlen;
int cmd;
char err[64];
char *err;
};
enum

View file

@ -797,11 +797,11 @@ cmddone(void *arg)
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 @@ segmentioproc(void *arg)
;
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);