Wrapping the chdir call in an if statement is much better. It gives the program a contingency plan if the call fails, regardless of how unlikely that is. It's also really easy to implement.
Would it be better to use 'if != 0' rather than 'if == -1'? If chdir() fails it returns -1, but if libc fails to call chdir() I'm not sure about the return value, it might be something else. 0 is only returned on success. Not just for chdir(), but in a general sense. robert On Friday 25 August 2006 10:48, Alex Merry wrote: > On Fri, Aug 25, 2006 at 01:00:33PM +0100, Alex Merry wrote: > > diff -urw make-3.81.old/main.c make-3.81/main.c > > --- make-3.81.old/main.c 2006-08-25 12:48:20.000000000 +0100 > > +++ make-3.81/main.c 2006-08-25 12:50:07.000000000 +0100 > > @@ -3066,7 +3066,8 @@ > > directory. Must wait until after remove_intermediates(), or unlinks > > of relative pathnames fail. */ > > if (directory_before_chdir != 0) > > - chdir (directory_before_chdir); > > + if (chdir (directory_before_chdir) != -1) > > + error (NILF, "Failed to return to original directory %s", > > directory_before_chdir); > > > > log_working_directory (0); > > } > > OK, that != should be == in the patch. Better one attached. > > Alex :-)
pgpZ3g63KAHsq.pgp
Description: PGP signature
-- http://linuxfromscratch.org/mailman/listinfo/hlfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
