On Saturday 19 April 2008 12:32, Joakim Tjernlund wrote:
> > 
> > >   foundany = 0;
> > > - while ((entry = readdir(procdir)) != NULL) {
> > > -         pid = bb_strtou(entry->d_name, NULL, 10);
> > > -         if (errno)
> > > + while(1) {
> > > +         errno = 0;
> > > +         entry = readdir(procdir);
> > > +         if (errno) /* Stale file ? */
> > >                   continue;
> > 
> > When exactly this happens? I would like to document it in comment.
> 
> Well, files comes and goes quickly in /proc so I guess that it
> happens when a file/directory is deleted after /proc has been opened.
> 
> The man page for readdir is pretty clear though. Will return a
> NULL ptr when either EOF or an error has been encountered so
> you have to test for errno to know why NULL is returned.

Joakim,

I am not saying or implying that this change is bad. I do believe that
people won't send patches just because they like to do so.

I think that you saw something in real world usage and you had to make
this change in order to make it work reliably.

But please realize that your change, as written, will not tell casual
code reader WHY it is required, and it bears the risk of this code
being *deleted again* under impression that it is not needed.

In order to prevent that, you have to give at least one real example
where it is needed.
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to