Re: [PATCH v4] gc: call "prune --expire 2.weeks.ago" by default

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



El 13/3/2008, a las 0:39, Junio C Hamano escribió:

Ah,...

But C language rules haven't changed in such a way that it guarantees B to
be evaluated before A when you write "A >= B", have it?

So at least I think you would need something like this if you go that
route:

 		if (strcmp(value, "now")) {
               	unsigned long now = approxidate("now");
               	if (approxidate(value) >= now)
				return error("Invalid %s: '%s'", var, value);
			...
		}


Are you sure that that alternative provides any guarantees about evaluation order either? (I'm not a compiler expert, nor am I consulting a copy of the standard; but I don't think it does.)

In order to enforce evaluation in the required order I think it might have to be something like this:

	if (strcmp(value, "now")) {
		unsigned long now;
		if ((now = approxidate("now")) &&
		    approxidate(value) >= now)
			return error("Invalid %s: '%s'", var, value);
		...
	}

ie. the && operator guarantees left to right evaluation order, and since approxidate always returns a non-zero ulong the second expression (after the &&) will always be evaluated.

Cheers,
Wincent



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux