Closed BastiDood closed 1 year ago
fair point. I added one line to indicate the function should return something on success/error. Thanks! Your update will propagate to the ostep site and printed book soon, and your name will also soon appear in the preface. Much appreciated!
Awesome! Thank you so much. For your reference, I prefer to be named as "Sebastian Luis Ortiz" (affiliated with the University of the Philippines - Diliman) in the credits.
Chapter 36 (on I/O devices) provides a simplified implementation of xv6's IDE disk driver. Among the helper functions is
ide_wait_ready
, which (according to its function definition) returns anint
. In the actual xv6 code, thisint
is used as an error indicator.However, in the simplified code (see Figure 36.6), observe the absence of the
return
statement. In C, it is undefined behavior for a value-returning function not toreturn
anything (in any code path).The actual invocation of undefined behavior occurs later in
ide_intr
, where we use the (presumed) return value ofide_wait_ready
inside anif
-condition.