[SLOF] [PATCH v6 1/2] Fix output word
segher at kernel.crashing.org
Sun Apr 8 21:05:14 AEST 2018
On Fri, Apr 06, 2018 at 10:47:03AM +0200, Laurent Vivier wrote:
> : output ( dev-str dev-len -- )
> open-dev ?dup IF
It's a lot simple if you do an early exit if there is no such device.
You're supposed to output an error message in that case, fwiw.
> - \ Close old stdout:
> - s" stdout" get-chosen IF
> - decode-int nip nip ?dup IF close-dev THEN
> + \ find new ihandle and xt handle
> + dup s" write" rot ihandle>phandle find-method
> + 0= IF
> + drop
> + cr ." Cannot find the write method for the given output console " cr
> + EXIT
This leaks the instance. The description in the standard say to search
for the method before doing the open-dev, that solves this problem too.
> +: term-io-emit ( char -- )
> + write-xt IF
> + (term-io-char-buf) c!
> + (term-io-char-buf) 1 write-xt stdout @ call-package
> + drop
> + ELSE
> + [ ' emit behavior compile, ]
> + THEN
What do you expect to be in the emit hook at this point? Could you
just use _that_?
Looks nice and readable otherwise, great :-)
More information about the SLOF