On Wed, Jan 19, 2022 at 06:01:38PM +0100, Theo Buehler wrote:
> Not sure if it is that much of a win, but it saves some repetition and
> makes sure we don't forget checking the file name to be longer than 4
> another time (missed on review in main() and proc_parser_file()).
I like the diff. It is a good first step.
One thing below but the diff is OK claudio@
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v
> retrieving revision 1.178
> diff -u -p -r1.178 main.c
> --- main.c 19 Jan 2022 15:50:31 -0000 1.178
> +++ main.c 19 Jan 2022 16:51:05 -0000
> @@ -371,17 +372,18 @@ queue_add_from_mft_set(const struct mft
> f = &mft->files[i];
> sz = strlen(f->file);
> assert(sz > 4);
> - if (strcasecmp(f->file + sz - 4, ".crl") == 0)
> + type = rtype_from_file_extension(f->file);
> + switch (type) {
> + case RTYPE_CER:
> + case RTYPE_ROA:
> + case RTYPE_GBR:
> + queue_add_from_mft(mft->path, f, type, rp);
> + break;
> + case RTYPE_CRL:
> continue;
> - else if (strcasecmp(f->file + sz - 4, ".cer") == 0)
> - queue_add_from_mft(mft->path, f, RTYPE_CER, rp);
> - else if (strcasecmp(f->file + sz - 4, ".roa") == 0)
> - queue_add_from_mft(mft->path, f, RTYPE_ROA, rp);
> - else if (strcasecmp(f->file + sz - 4, ".gbr") == 0)
> - queue_add_from_mft(mft->path, f, RTYPE_GBR, rp);
> - else
> - logx("%s: unsupported file type: %s", name,
> - f->file);
> + default:
> + logx("%s: unsupported file type: %s", name, f->file);
> + }
> }
> }
>
I was a bit confused here because you did not adjust the first for loop
that just checks for .crl. I wonder if we should pass the RTYPE value in
struct mftfile. This would make this code a lot simpler.
--
:wq Claudio