Skip to content

Commit 76b6fd8

Browse files
committed
evp_fetch: reduce the amount of ifdefery for handling PQ
Signed-off-by: Eugene Syromiatnikov <[email protected]>
1 parent ba12014 commit 76b6fd8

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

source/evp_fetch.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
#if OPENSSL_VERSION_MAJOR > 3 || \
3030
(OPENSSL_VERSION_MAJOR == 3 && OPENSSL_VERSION_MINOR >= 5)
3131
# define OPENSSL_DO_PQ
32+
# define PQ_GETOPT "q"
33+
# define PQ_USAGE_OPT " [-q]"
34+
# define PQ_USAGE_DESC "-q - include post-quantum algorithms\n"
35+
#else
36+
# define PQ_GETOPT ""
37+
# define PQ_USAGE_OPT ""
38+
# define PQ_USAGE_DESC ""
3239
#endif
3340

3441
#define RUN_TIME 5
@@ -287,15 +294,10 @@ void do_fetch(size_t num)
287294
static void
288295
usage(const char *progname)
289296
{
290-
#ifdef OPENSSL_DO_PQ
291-
printf("Usage: %s [-t] [-q] threadcount\n", progname);
292-
#else
293-
printf("Usage: %s [-t] threadcount\n", progname);
294-
#endif
295-
printf("-t - terse output\n");
296-
#ifdef OPENSSL_DO_PQ
297-
printf("-q - include post-quantum algorithms\n");
298-
#endif
297+
printf("Usage: %s [-t]" PQ_USAGE_OPT " threadcount\n"
298+
"-t - terse output\n"
299+
PQ_USAGE_DESC,
300+
progname);
299301
}
300302

301303
int main(int argc, char *argv[])
@@ -310,11 +312,7 @@ int main(int argc, char *argv[])
310312
char *fetch_type = getenv("EVP_FETCH_TYPE");
311313
int opt;
312314

313-
#ifdef OPENSSL_DO_PQ
314-
while ((opt = getopt(argc, argv, "tq")) != -1) {
315-
#else
316-
while ((opt = getopt(argc, argv, "t")) != -1) {
317-
#endif
315+
while ((opt = getopt(argc, argv, "t" PQ_GETOPT)) != -1) {
318316
switch (opt) {
319317
case 't':
320318
terse = 1;

0 commit comments

Comments
 (0)