lkml.org 
[lkml]   [1999]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.018 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site