From a8c975d25b8973125837f3cd4c63b4a611f5c5f5 Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 14 Dec 2021 21:25:27 +0000 Subject: [PATCH] sys/param.h cleanup, mostly using MINIMUM() and ok dtucker --- regress/usr.bin/ssh/unittests/authopt/tests.c | 3 +-- regress/usr.bin/ssh/unittests/bitmap/tests.c | 3 +-- regress/usr.bin/ssh/unittests/conversion/tests.c | 4 ++-- .../usr.bin/ssh/unittests/hostkeys/test_iterate.c | 3 +-- regress/usr.bin/ssh/unittests/kex/test_kex.c | 3 +-- regress/usr.bin/ssh/unittests/match/tests.c | 3 +-- regress/usr.bin/ssh/unittests/misc/test_argv.c | 3 +-- regress/usr.bin/ssh/unittests/misc/test_convtime.c | 4 ++-- regress/usr.bin/ssh/unittests/misc/test_expand.c | 3 +-- regress/usr.bin/ssh/unittests/misc/test_parse.c | 3 +-- regress/usr.bin/ssh/unittests/misc/test_strdelim.c | 3 +-- regress/usr.bin/ssh/unittests/misc/tests.c | 3 +-- regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf.c | 5 +++-- .../usr.bin/ssh/unittests/sshbuf/test_sshbuf_fixed.c | 3 +-- .../usr.bin/ssh/unittests/sshbuf/test_sshbuf_fuzz.c | 3 +-- .../ssh/unittests/sshbuf/test_sshbuf_getput_basic.c | 3 +-- .../ssh/unittests/sshbuf/test_sshbuf_getput_crypto.c | 3 +-- .../ssh/unittests/sshbuf/test_sshbuf_getput_fuzz.c | 3 +-- .../usr.bin/ssh/unittests/sshbuf/test_sshbuf_misc.c | 3 +-- regress/usr.bin/ssh/unittests/sshkey/common.c | 3 +-- regress/usr.bin/ssh/unittests/sshkey/test_file.c | 3 +-- regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c | 3 +-- regress/usr.bin/ssh/unittests/sshkey/test_sshkey.c | 3 +-- regress/usr.bin/ssh/unittests/sshsig/tests.c | 3 +-- .../usr.bin/ssh/unittests/test_helper/test_helper.c | 12 +++++++----- 25 files changed, 35 insertions(+), 53 deletions(-) diff --git a/regress/usr.bin/ssh/unittests/authopt/tests.c b/regress/usr.bin/ssh/unittests/authopt/tests.c index 4fedf0a3e8a..93b806e5de1 100644 --- a/regress/usr.bin/ssh/unittests/authopt/tests.c +++ b/regress/usr.bin/ssh/unittests/authopt/tests.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tests.c,v 1.2 2021/07/24 01:54:23 djm Exp $ */ +/* $OpenBSD: tests.c,v 1.3 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for keys options functions. @@ -7,7 +7,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/bitmap/tests.c b/regress/usr.bin/ssh/unittests/bitmap/tests.c index 6789661ce38..51f6d67d92c 100644 --- a/regress/usr.bin/ssh/unittests/bitmap/tests.c +++ b/regress/usr.bin/ssh/unittests/bitmap/tests.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tests.c,v 1.1 2015/01/15 07:36:28 djm Exp $ */ +/* $OpenBSD: tests.c,v 1.2 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for bitmap.h bitmap API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/conversion/tests.c b/regress/usr.bin/ssh/unittests/conversion/tests.c index c10d8753d7c..693625b29a6 100644 --- a/regress/usr.bin/ssh/unittests/conversion/tests.c +++ b/regress/usr.bin/ssh/unittests/conversion/tests.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tests.c,v 1.3 2021/01/18 11:43:34 dtucker Exp $ */ +/* $OpenBSD: tests.c,v 1.4 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for conversions * @@ -6,10 +6,10 @@ */ #include -#include #include #include #include +#include #include #include "test_helper.h" diff --git a/regress/usr.bin/ssh/unittests/hostkeys/test_iterate.c b/regress/usr.bin/ssh/unittests/hostkeys/test_iterate.c index 6be074b7ad9..71f523bfe08 100644 --- a/regress/usr.bin/ssh/unittests/hostkeys/test_iterate.c +++ b/regress/usr.bin/ssh/unittests/hostkeys/test_iterate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_iterate.c,v 1.7 2020/12/21 01:31:06 djm Exp $ */ +/* $OpenBSD: test_iterate.c,v 1.8 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for hostfile.h hostkeys_foreach() * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/kex/test_kex.c b/regress/usr.bin/ssh/unittests/kex/test_kex.c index d0d26051dd5..1cb5b239715 100644 --- a/regress/usr.bin/ssh/unittests/kex/test_kex.c +++ b/regress/usr.bin/ssh/unittests/kex/test_kex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_kex.c,v 1.5 2020/12/29 01:02:15 djm Exp $ */ +/* $OpenBSD: test_kex.c,v 1.6 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test KEX * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/match/tests.c b/regress/usr.bin/ssh/unittests/match/tests.c index e413849ce23..49198dd86e4 100644 --- a/regress/usr.bin/ssh/unittests/match/tests.c +++ b/regress/usr.bin/ssh/unittests/match/tests.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tests.c,v 1.7 2020/07/15 06:43:16 dtucker Exp $ */ +/* $OpenBSD: tests.c,v 1.8 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for matching functions * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/misc/test_argv.c b/regress/usr.bin/ssh/unittests/misc/test_argv.c index 061369dfe04..85526a94608 100644 --- a/regress/usr.bin/ssh/unittests/misc/test_argv.c +++ b/regress/usr.bin/ssh/unittests/misc/test_argv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_argv.c,v 1.3 2021/06/08 07:40:12 djm Exp $ */ +/* $OpenBSD: test_argv.c,v 1.4 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for misc argv handling functions. * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/misc/test_convtime.c b/regress/usr.bin/ssh/unittests/misc/test_convtime.c index 8da05a26181..8ec9b74d3f8 100644 --- a/regress/usr.bin/ssh/unittests/misc/test_convtime.c +++ b/regress/usr.bin/ssh/unittests/misc/test_convtime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_convtime.c,v 1.1 2021/03/19 03:25:01 djm Exp $ */ +/* $OpenBSD: test_convtime.c,v 1.2 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for misc time conversion functions. * @@ -6,10 +6,10 @@ */ #include -#include #include #include #include +#include #include #include "test_helper.h" diff --git a/regress/usr.bin/ssh/unittests/misc/test_expand.c b/regress/usr.bin/ssh/unittests/misc/test_expand.c index 97804a94367..8fbd005c9ce 100644 --- a/regress/usr.bin/ssh/unittests/misc/test_expand.c +++ b/regress/usr.bin/ssh/unittests/misc/test_expand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_expand.c,v 1.2 2021/04/06 09:07:33 dtucker Exp $ */ +/* $OpenBSD: test_expand.c,v 1.3 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for misc string expansion functions. * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/misc/test_parse.c b/regress/usr.bin/ssh/unittests/misc/test_parse.c index 6fa4558e22d..530f7b09b65 100644 --- a/regress/usr.bin/ssh/unittests/misc/test_parse.c +++ b/regress/usr.bin/ssh/unittests/misc/test_parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_parse.c,v 1.1 2021/03/19 03:25:01 djm Exp $ */ +/* $OpenBSD: test_parse.c,v 1.2 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for misc user/host/URI parsing functions. * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/misc/test_strdelim.c b/regress/usr.bin/ssh/unittests/misc/test_strdelim.c index 0a791e753d2..f972f960a02 100644 --- a/regress/usr.bin/ssh/unittests/misc/test_strdelim.c +++ b/regress/usr.bin/ssh/unittests/misc/test_strdelim.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_strdelim.c,v 1.2 2021/05/21 03:59:01 djm Exp $ */ +/* $OpenBSD: test_strdelim.c,v 1.3 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for misc strdelim() and co * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/misc/tests.c b/regress/usr.bin/ssh/unittests/misc/tests.c index 9d619fc7d6c..307d6aee98a 100644 --- a/regress/usr.bin/ssh/unittests/misc/tests.c +++ b/regress/usr.bin/ssh/unittests/misc/tests.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tests.c,v 1.7 2021/05/21 03:48:07 djm Exp $ */ +/* $OpenBSD: tests.c,v 1.8 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for misc helper functions. * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf.c b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf.c index 834dcd050df..9c876db72c8 100644 --- a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf.c +++ b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_sshbuf.c,v 1.1 2014/04/30 05:32:00 djm Exp $ */ +/* $OpenBSD: test_sshbuf.c,v 1.2 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshbuf.h buffer API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include @@ -20,6 +19,8 @@ void sshbuf_tests(void); +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) + void sshbuf_tests(void) { diff --git a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_fixed.c b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_fixed.c index 62c815a2eaf..2916de313b8 100644 --- a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_fixed.c +++ b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_fixed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_sshbuf_fixed.c,v 1.1 2014/04/30 05:32:00 djm Exp $ */ +/* $OpenBSD: test_sshbuf_fixed.c,v 1.2 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshbuf.h buffer API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_fuzz.c b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_fuzz.c index b14340702b6..fcf01819a83 100644 --- a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_fuzz.c +++ b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_fuzz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_sshbuf_fuzz.c,v 1.2 2018/10/17 23:28:05 djm Exp $ */ +/* $OpenBSD: test_sshbuf_fuzz.c,v 1.3 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshbuf.h buffer API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_basic.c b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_basic.c index 1ac2382f152..820207cca2d 100644 --- a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_basic.c +++ b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_basic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_sshbuf_getput_basic.c,v 1.2 2019/07/14 23:33:19 djm Exp $ */ +/* $OpenBSD: test_sshbuf_getput_basic.c,v 1.3 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshbuf.h buffer API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_crypto.c b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_crypto.c index ef9ce835515..9e47c1457a9 100644 --- a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_crypto.c +++ b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_sshbuf_getput_crypto.c,v 1.2 2019/01/21 12:29:35 djm Exp $ */ +/* $OpenBSD: test_sshbuf_getput_crypto.c,v 1.3 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshbuf.h buffer API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_fuzz.c b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_fuzz.c index bbc099ecb2d..0912bc24ed1 100644 --- a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_fuzz.c +++ b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_getput_fuzz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_sshbuf_getput_fuzz.c,v 1.4 2019/01/21 12:29:35 djm Exp $ */ +/* $OpenBSD: test_sshbuf_getput_fuzz.c,v 1.5 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshbuf.h buffer API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_misc.c b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_misc.c index a61f7a46437..a2e57cc61d2 100644 --- a/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_misc.c +++ b/regress/usr.bin/ssh/unittests/sshbuf/test_sshbuf_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_sshbuf_misc.c,v 1.4 2019/07/16 22:16:49 djm Exp $ */ +/* $OpenBSD: test_sshbuf_misc.c,v 1.5 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshbuf.h buffer API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshkey/common.c b/regress/usr.bin/ssh/unittests/sshkey/common.c index 6b2ccdbf88a..1e19fa5b4a5 100644 --- a/regress/usr.bin/ssh/unittests/sshkey/common.c +++ b/regress/usr.bin/ssh/unittests/sshkey/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.4 2020/01/26 00:09:50 djm Exp $ */ +/* $OpenBSD: common.c,v 1.5 2021/12/14 21:25:27 deraadt Exp $ */ /* * Helpers for key API tests * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshkey/test_file.c b/regress/usr.bin/ssh/unittests/sshkey/test_file.c index bab9c42026e..6a0fdbad0a2 100644 --- a/regress/usr.bin/ssh/unittests/sshkey/test_file.c +++ b/regress/usr.bin/ssh/unittests/sshkey/test_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_file.c,v 1.9 2020/06/19 03:48:49 djm Exp $ */ +/* $OpenBSD: test_file.c,v 1.10 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshkey.h key management API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c b/regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c index 0768c533c59..2c3ffc720d2 100644 --- a/regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c +++ b/regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_fuzz.c,v 1.12 2020/08/27 03:55:22 djm Exp $ */ +/* $OpenBSD: test_fuzz.c,v 1.13 2021/12/14 21:25:27 deraadt Exp $ */ /* * Fuzz tests for key parsing * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshkey/test_sshkey.c b/regress/usr.bin/ssh/unittests/sshkey/test_sshkey.c index 7d90d6fb59f..749aebc4e50 100644 --- a/regress/usr.bin/ssh/unittests/sshkey/test_sshkey.c +++ b/regress/usr.bin/ssh/unittests/sshkey/test_sshkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_sshkey.c,v 1.21 2020/08/27 03:55:22 djm Exp $ */ +/* $OpenBSD: test_sshkey.c,v 1.22 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshkey.h key management API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/sshsig/tests.c b/regress/usr.bin/ssh/unittests/sshsig/tests.c index 728451ebb9a..f1d7addae91 100644 --- a/regress/usr.bin/ssh/unittests/sshsig/tests.c +++ b/regress/usr.bin/ssh/unittests/sshsig/tests.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tests.c,v 1.2 2020/06/22 06:00:06 djm Exp $ */ +/* $OpenBSD: tests.c,v 1.3 2021/12/14 21:25:27 deraadt Exp $ */ /* * Regress test for sshbuf.h buffer API * @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/regress/usr.bin/ssh/unittests/test_helper/test_helper.c b/regress/usr.bin/ssh/unittests/test_helper/test_helper.c index 4b29a33523c..35010e4c723 100644 --- a/regress/usr.bin/ssh/unittests/test_helper/test_helper.c +++ b/regress/usr.bin/ssh/unittests/test_helper/test_helper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_helper.c,v 1.12 2019/08/02 01:41:24 djm Exp $ */ +/* $OpenBSD: test_helper.c,v 1.13 2021/12/14 21:25:27 deraadt Exp $ */ /* * Copyright (c) 2011 Damien Miller * @@ -18,7 +18,6 @@ /* Utility functions/framework for regress tests */ #include -#include #include #include @@ -26,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +34,8 @@ #include +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + #include "test_helper.h" #include "atomicio.h" @@ -379,8 +381,8 @@ assert_mem(const char *file, int line, const char *a1, const char *a2, r = memcmp(aa1, aa2, l); TEST_CHECK_INT(r, pred); test_header(file, line, a1, a2, "STRING", pred); - aa1_tohex = tohex(aa1, MIN(l, 256)); - aa2_tohex = tohex(aa2, MIN(l, 256)); + aa1_tohex = tohex(aa1, MINIMUM(l, 256)); + aa2_tohex = tohex(aa2, MINIMUM(l, 256)); fprintf(stderr, "%12s = %s (len %zu)\n", a1, aa1_tohex, l); fprintf(stderr, "%12s = %s (len %zu)\n", a2, aa2_tohex, l); free(aa1_tohex); @@ -419,7 +421,7 @@ assert_mem_filled(const char *file, int line, const char *a1, r = memvalcmp(aa1, v, l, &where); TEST_CHECK_INT(r, pred); test_header(file, line, a1, NULL, "MEM_ZERO", pred); - aa1_tohex = tohex(aa1, MIN(l, 20)); + aa1_tohex = tohex(aa1, MINIMUM(l, 20)); fprintf(stderr, "%20s = %s%s (len %zu)\n", a1, aa1_tohex, l > 20 ? "..." : "", l); free(aa1_tohex); -- 2.20.1