* [PATCH] meta.c: fix compiler warning in date_type_parse()
@ 2022-04-05 16:43 Lukas Straub
2022-04-05 20:01 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Lukas Straub @ 2022-04-05 16:43 UTC (permalink / raw)
To: netfilter-devel; +Cc: Pablo Neira Ayuso
[-- Attachment #1: Type: text/plain, Size: 1736 bytes --]
After commit 0210097879 ("meta: time: use uint64_t instead of time_t")
there is a compiler warning due to comparison of the return value from
parse_iso_date with -1, which is now implicitly cast to uint64_t.
Fix this by making parse_iso_date take a pointer to the tstamp and
return bool instead.
Fixes: 0210097879 ("meta: time: use uint64_t instead of time_t")
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
src/meta.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/meta.c b/src/meta.c
index c0e2608d..80ace25b 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -405,7 +405,7 @@ static void date_type_print(const struct expr *expr, struct output_ctx *octx)
nft_print(octx, "Error converting timestamp to printed time");
}
-static time_t parse_iso_date(const char *sym)
+static bool parse_iso_date(uint64_t *tstamp, const char *sym)
{
struct tm tm, *cur_tm;
time_t ts;
@@ -419,7 +419,7 @@ static time_t parse_iso_date(const char *sym)
if (strptime(sym, "%F", &tm))
goto success;
- return -1;
+ return false;
success:
/*
@@ -436,7 +436,9 @@ success:
return ts;
/* Substract tm_gmtoff to get the current time */
- return ts - cur_tm->tm_gmtoff;
+ *tstamp = ts - cur_tm->tm_gmtoff;
+
+ return true;
}
static struct error_record *date_type_parse(struct parse_ctx *ctx,
@@ -446,7 +448,7 @@ static struct error_record *date_type_parse(struct parse_ctx *ctx,
const char *endptr = sym->identifier;
uint64_t tstamp;
- if ((tstamp = parse_iso_date(sym->identifier)) != -1)
+ if (parse_iso_date(&tstamp, sym->identifier))
goto success;
tstamp = strtoul(sym->identifier, (char **) &endptr, 10);
--
2.35.1
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] meta.c: fix compiler warning in date_type_parse()
2022-04-05 16:43 [PATCH] meta.c: fix compiler warning in date_type_parse() Lukas Straub
@ 2022-04-05 20:01 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-05 20:01 UTC (permalink / raw)
To: Lukas Straub; +Cc: netfilter-devel
On Tue, Apr 05, 2022 at 04:43:30PM +0000, Lukas Straub wrote:
> After commit 0210097879 ("meta: time: use uint64_t instead of time_t")
> there is a compiler warning due to comparison of the return value from
> parse_iso_date with -1, which is now implicitly cast to uint64_t.
>
> Fix this by making parse_iso_date take a pointer to the tstamp and
> return bool instead.
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-05 21:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 16:43 [PATCH] meta.c: fix compiler warning in date_type_parse() Lukas Straub
2022-04-05 20:01 ` Pablo Neira Ayuso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.