Mailing List Archive

Re: User vs. Kernel (was: To be smug, or not to be smug, that isthe
Anthony Barbachan wrote:
> prereadlabel:
>
> if((bytesread = read(...)) == -1)
> {
> if(errno == EINTR) goto prereadlabel;
>
> // fatal read error handling code
> }
>
> I dislike having to use a goto but its the cleanest method I've scene
> that takes care of this problem.
I prefer:
do
ret = read (...);
while (ret == -1 && errno == EINTR);
if (ret == -1) {
/* Handle real errors... */
}
Using your style of assigning in a conditional, this would be very compact:
while ((ret = read (...)) == -1 && errno == EINTR) ;
if (ret == -1) {
/* Handle real errors... */
}
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/