From c1593c930b5ae71711b3c866592c9afd06824553 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Tue, 6 Feb 2024 14:09:15 +0100 Subject: [PATCH] Get rid of a couple of time_t uses We are using our 'unsigned long long' numeric data type anyway later on. --- ext/repo_autopattern.c | 4 ++-- ext/repo_products.c | 4 ++-- ext/repo_updateinfoxml.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/repo_autopattern.c b/ext/repo_autopattern.c index bbc90cbf..40d21128 100644 --- a/ext/repo_autopattern.c +++ b/ext/repo_autopattern.c @@ -58,7 +58,7 @@ unescape(char *p) *q = 0; } -static time_t +static unsigned long long datestr2timestamp(const char *date) { const char *p; @@ -69,7 +69,7 @@ datestr2timestamp(const char *date) for (p = date; *p >= '0' && *p <= '9'; p++) ; if (!*p) - return atoi(date); + return strtoull(date, 0, 10); memset(&tm, 0, sizeof(tm)); p = strptime(date, "%F%T", &tm); if (!p) diff --git a/ext/repo_products.c b/ext/repo_products.c index edf15bf7..4772be3e 100644 --- a/ext/repo_products.c +++ b/ext/repo_products.c @@ -120,7 +120,7 @@ struct parsedata { }; -static time_t +static unsigned long long datestr2timestamp(const char *date) { const char *p; @@ -131,7 +131,7 @@ datestr2timestamp(const char *date) for (p = date; *p >= '0' && *p <= '9'; p++) ; if (!*p) - return atoi(date); + return strtoull(date, 0, 10); memset(&tm, 0, sizeof(tm)); p = strptime(date, "%F%T", &tm); if (!p) diff --git a/ext/repo_updateinfoxml.c b/ext/repo_updateinfoxml.c index 0725f033..39028745 100644 --- a/ext/repo_updateinfoxml.c +++ b/ext/repo_updateinfoxml.c @@ -109,7 +109,7 @@ struct parsedata { Repodata *data; Id handle; Solvable *solvable; - time_t buildtime; + unsigned long long buildtime; Id pkghandle; struct solv_xmlparser xmlp; struct joindata jd; @@ -120,7 +120,7 @@ struct parsedata { * Convert date strings ("1287746075" or "2010-10-22 13:14:35") * to timestamp. */ -static time_t +static unsigned long long datestr2timestamp(const char *date) { const char *p; @@ -131,7 +131,7 @@ datestr2timestamp(const char *date) for (p = date; *p >= '0' && *p <= '9'; p++) ; if (!*p) - return atoi(date); + return strtoull(date, 0, 10); memset(&tm, 0, sizeof(tm)); if (!strptime(date, "%F%T", &tm)) return 0; @@ -243,7 +243,7 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha repodata_set_str(pd->data, pd->handle, SOLVABLE_PATCHCATEGORY, type); if (status) repodata_set_poolstr(pd->data, pd->handle, UPDATE_STATUS, status); - pd->buildtime = (time_t)0; + pd->buildtime = 0; } break; @@ -253,7 +253,7 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha const char *date = solv_xmlparser_find_attr("date", atts); if (date) { - time_t t = datestr2timestamp(date); + unsigned long long t = datestr2timestamp(date); if (t && t > pd->buildtime) pd->buildtime = t; } @@ -395,7 +395,7 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content) if (pd->buildtime) { repodata_set_num(pd->data, pd->handle, SOLVABLE_BUILDTIME, pd->buildtime); - pd->buildtime = (time_t)0; + pd->buildtime = 0; } break; -- 2.47.2