From: Ben Harris Date: Thu, 27 Feb 2025 23:00:24 +0000 (+0000) Subject: Further SOURCE_DATE_EPOCH simplification X-Git-Tag: bedstead-3.252~5 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=0d2296e4afe2a53bb42006536b6ad0c3564f5da2;p=bedstead.git Further SOURCE_DATE_EPOCH simplification Rather than mucking about with errno, we can just take advantage of the fact that on overflow, strtoull() is specified to return ULLONG_MAX, which is guaranteed to be (much) bigger than the maximum SOURCE_DATE_EPOCH that we can cope with. So our usual range check can cope with overflow as well. --- diff --git a/bedstead.c b/bedstead.c index a4f30e4..e0b12af 100644 --- a/bedstead.c +++ b/bedstead.c @@ -98,7 +98,6 @@ #include #include -#include #include #include #include @@ -3149,11 +3148,9 @@ time_for_ttx(void) /* Work out what timestamp to use. */ if ((epochstr = getenv("SOURCE_DATE_EPOCH")) != NULL) { - errno = 0; epochull = strtoull(epochstr, &endptr, 10); if (!isdigit((unsigned char)epochstr[0]) || endptr == epochstr || *endptr != '\0' || - errno == ERANGE || /* Allow years up to 9999. */ epochull >= 253402300800) { fprintf(stderr, "Invalid SOURCE_DATE_EPOCH\n");