diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-01-31 06:54:44 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-01-31 06:54:44 +0000 |
commit | d8a58f6c5a7d5204bbf7277cfe5b44d09669c6b1 (patch) | |
tree | bcf56863ef36c641be8df2be9c362e42a0420330 | |
parent | 7b1b386df59d007a014405e79d99563351efa135 (diff) |
Rename mft_compare() to mft_compare_seqnum()
This makes it clearer what exactly this function compares. Also drop some
NULL checks that made the semantics of this function tricky.
ok job
-rw-r--r-- | usr.sbin/rpki-client/extern.h | 4 | ||||
-rw-r--r-- | usr.sbin/rpki-client/mft.c | 13 | ||||
-rw-r--r-- | usr.sbin/rpki-client/parser.c | 4 |
3 files changed, 7 insertions, 14 deletions
diff --git a/usr.sbin/rpki-client/extern.h b/usr.sbin/rpki-client/extern.h index 61527fdefb5..7245536c8bf 100644 --- a/usr.sbin/rpki-client/extern.h +++ b/usr.sbin/rpki-client/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.199 2024/01/18 14:34:26 job Exp $ */ +/* $OpenBSD: extern.h,v 1.200 2024/01/31 06:54:43 tb Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -629,7 +629,7 @@ void mft_free(struct mft *); struct mft *mft_parse(X509 **, const char *, int, const unsigned char *, size_t); struct mft *mft_read(struct ibuf *); -int mft_compare(const struct mft *, const struct mft *); +int mft_compare_seqnum(const struct mft *, const struct mft *); void roa_buffer(struct ibuf *, const struct roa *); void roa_free(struct roa *); diff --git a/usr.sbin/rpki-client/mft.c b/usr.sbin/rpki-client/mft.c index 8fd3755f1c9..17ddda63427 100644 --- a/usr.sbin/rpki-client/mft.c +++ b/usr.sbin/rpki-client/mft.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mft.c,v 1.100 2023/12/11 15:50:23 job Exp $ */ +/* $OpenBSD: mft.c,v 1.101 2024/01/31 06:54:43 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> @@ -545,20 +545,13 @@ mft_read(struct ibuf *b) } /* - * Compare the manifestNumber of two MFT files. - * Returns 1 if first MFT should be used, 0 if both are equal, and -1 if the - * second MFT should be used. + * Compare the manifestNumber of two mft files. */ int -mft_compare(const struct mft *a, const struct mft *b) +mft_compare_seqnum(const struct mft *a, const struct mft *b) { int r; - if (b == NULL) - return 1; - if (a == NULL) - return -1; - r = strlen(a->seqnum) - strlen(b->seqnum); if (r > 0) /* seqnum in a is longer -> higher */ return 1; diff --git a/usr.sbin/rpki-client/parser.c b/usr.sbin/rpki-client/parser.c index 3d89f9bf615..ab57a2e483b 100644 --- a/usr.sbin/rpki-client/parser.c +++ b/usr.sbin/rpki-client/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.111 2024/01/31 06:53:21 tb Exp $ */ +/* $OpenBSD: parser.c,v 1.112 2024/01/31 06:54:43 tb Exp $ */ /* * Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> @@ -315,7 +315,7 @@ proc_parser_mft_pre(struct entity *entp, enum location loc, char **file, * a smaller sequence number. */ - if ((seqnum_cmp = mft_compare(mft, cached_mft)) < 0) { + if ((seqnum_cmp = mft_compare_seqnum(mft, cached_mft)) < 0) { warnx("%s: unexpected manifest number (want >= #%s, got #%s)", *file, cached_mft->seqnum, mft->seqnum); goto err; |