5336 geterror (abp) struct buf *abp; { register struct buf bp; bp = abp; if (bp->b flags & B_ERROR) if ((u.u_error=bp->b_error)==0) u.u_error = EIO; }
This procedure simply checks if there has been an error, and if the error indicator “u.u_error” has not been set, sets it to a general error indication
“B_ERROR” has the value 04 (see line 4575) so that, with only one bit set, it can be used as mask to isolate bit number 2. The operator “&” as used in
bp->b_flags & B_ERROR
is the bitwise logical conjunction (“and”) applied to arithmetic values.
The above expression is greater than one if bit 2 of the element “b_flags” of the “buf” structure pointed to by “bp”, is set.
Thus if there has been an error, the expression
(u.u_error) = bp->b_error)
is evaluated and compared with zero. Now this expression includes an assignment operator “=”. The value of the expression is the value of “u.u_error” after the value of “bp-b_flags” has been assigned to it.
This use of an assignment as part of an expression is useful and quite common.