On Tue, Oct 13, 2009 at 09:02:10PM +0200, Denys Vlasenko wrote:

>Perhaps I thought time() is cheaper than stat(), but

that's what i thought, yes :)

>this patch will make us see new /etc/resolv.conf
>at once -> better user experience. I like it.
>
>
>+       static time_t resolv_conf_mtime;
>...
>+               struct stat sb;
>+               stat("/etc/resolv.conf", &sb);
>+               if ((difftime(resolv_conf_mtime, sb.st_mtime)) < 0) {
>
>To use difftime here looks like overkill:
>
>double difftime(time_t time1, time_t time0);
>
>You don't need the difference. You only want to know whether it
>has changed, right?

erm, yes.
>
>
>
>I propose using:
>
>        static unsigned resolv_conf_mtime;
>...
>        if (resolv_conf_mtime != (unsigned)sb.st_mtime) < 0) {
s/) < 0//
>
>I use "unsigned" in order to minimize statics - time_t is a long, and
>there is no need to use 8 bytes on amd64 etc where 4 is quite enough.
>
>We can explicitly use uint32_t there if you are concerned we'll
>ever get arches with sizeof(int) > 4.

I'd go for time_t, just because i'm paranoid.

May i ask you to apply such a thing (with whatever type you think is
safe)? TIA!
cheers,
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to