Author: mcayland Date: Mon Mar 3 18:00:20 2014 New Revision: 1271 URL: http://tracker.coreboot.org/trac/openbios/changeset/1271
Log: ciface.fs: alter nextprop to preserve output buffer unless an error occurs
Previously nextprop would always write a 0 length string to the output buffer before calling the underlying property words, with the assumption that this would be the default return value in the case of an error.
MorphOS breaks this assumption by specifying buf == prev when calling nextprop which caused the prev value to be overwritten before it could be used, and so nextprop would always return an (error) exit code of -1.
Fix nextprop so that the 0 length string is only written into the output buffer when an error exit code of -1 or 0 is returned, as per the IEEE1275 specification. As reported by BALATON Zoltan balaton@eik.bme.hu.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/forth/system/ciface.fs
Modified: trunk/openbios-devel/forth/system/ciface.fs ============================================================================== --- trunk/openbios-devel/forth/system/ciface.fs Mon Mar 3 00:18:34 2014 (r1270) +++ trunk/openbios-devel/forth/system/ciface.fs Mon Mar 3 18:00:20 2014 (r1271) @@ -108,12 +108,13 @@ dup 0= if 0 else dup cstrlen then
( buf prev prev_len ) - 0 3 pick c!
\ verify that prev exists (overkill...) dup if 2dup r@ get-package-property if - r> 2drop 2drop -1 exit + r> 2drop drop + 0 swap c! + -1 exit else 2drop then @@ -126,7 +127,8 @@ dup 1+ -rot ci-strcpy drop 1 else ( buf ) - drop 0 + 0 swap c! + 0 then ;