From 3eead8158393b697f663ec4301e3c7b6f24580b1 Mon Sep 17 00:00:00 2001 From: "deraadt@openbsd.org" Date: Tue, 14 Dec 2021 21:25:27 +0000 Subject: [PATCH] upstream: sys/param.h cleanup, mostly using MINIMUM() and ok dtucker OpenBSD-Regress-ID: 172a4c45d3bcf92fa6cdf6c4b9db3f1b3abe4db0 --- regress/unittests/authopt/tests.c | 3 +-- regress/unittests/bitmap/tests.c | 3 +-- regress/unittests/conversion/tests.c | 3 +-- regress/unittests/hostkeys/test_iterate.c | 3 +-- regress/unittests/kex/test_kex.c | 3 +-- regress/unittests/match/tests.c | 3 +-- regress/unittests/misc/test_argv.c | 3 +-- regress/unittests/misc/test_convtime.c | 4 ++-- regress/unittests/misc/test_expand.c | 3 +-- regress/unittests/misc/test_parse.c | 3 +-- regress/unittests/misc/test_strdelim.c | 3 +-- regress/unittests/misc/tests.c | 3 +-- regress/unittests/sshbuf/test_sshbuf.c | 5 +++-- regress/unittests/sshbuf/test_sshbuf_fixed.c | 3 +-- regress/unittests/sshbuf/test_sshbuf_fuzz.c | 3 +-- regress/unittests/sshbuf/test_sshbuf_getput_basic.c | 3 +-- regress/unittests/sshbuf/test_sshbuf_getput_crypto.c | 3 +-- regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c | 3 +-- regress/unittests/sshbuf/test_sshbuf_misc.c | 3 +-- regress/unittests/sshkey/common.c | 3 +-- regress/unittests/sshkey/test_file.c | 3 +-- regress/unittests/sshkey/test_fuzz.c | 3 +-- regress/unittests/sshkey/test_sshkey.c | 3 +-- regress/unittests/sshsig/tests.c | 3 +-- regress/unittests/test_helper/test_helper.c | 10 ++++++---- 25 files changed, 33 insertions(+), 52 deletions(-) diff --git a/regress/unittests/authopt/tests.c b/regress/unittests/authopt/tests.c index 9873c09c6..d9e190305 100644 --- a/regress/unittests/authopt/tests.c +++ b/regress/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. @@ -9,7 +9,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/bitmap/tests.c b/regress/unittests/bitmap/tests.c index f66a4ce46..576b863f4 100644 --- a/regress/unittests/bitmap/tests.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/conversion/tests.c b/regress/unittests/conversion/tests.c index bbdc5f5a7..5b526f7af 100644 --- a/regress/unittests/conversion/tests.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/hostkeys/test_iterate.c b/regress/unittests/hostkeys/test_iterate.c index a5b17d7e4..84f26b5c7 100644 --- a/regress/unittests/hostkeys/test_iterate.c +++ b/regress/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() * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/kex/test_kex.c b/regress/unittests/kex/test_kex.c index 3bd71a9f4..c26761ee7 100644 --- a/regress/unittests/kex/test_kex.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/match/tests.c b/regress/unittests/match/tests.c index 4fefaf4f3..f00d1f934 100644 --- a/regress/unittests/match/tests.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/misc/test_argv.c b/regress/unittests/misc/test_argv.c index 2cfebf2d9..682863e73 100644 --- a/regress/unittests/misc/test_argv.c +++ b/regress/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. * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/misc/test_convtime.c b/regress/unittests/misc/test_convtime.c index 8f9be89ff..ef6fd77de 100644 --- a/regress/unittests/misc/test_convtime.c +++ b/regress/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. * @@ -8,7 +8,7 @@ #include "includes.h" #include -#include +#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/misc/test_expand.c b/regress/unittests/misc/test_expand.c index 513c69bce..6f2cd8adb 100644 --- a/regress/unittests/misc/test_expand.c +++ b/regress/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. * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/misc/test_parse.c b/regress/unittests/misc/test_parse.c index 727ff3dea..1f1ea31d1 100644 --- a/regress/unittests/misc/test_parse.c +++ b/regress/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. * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/misc/test_strdelim.c b/regress/unittests/misc/test_strdelim.c index 1d9133d4b..f7bea4bfe 100644 --- a/regress/unittests/misc/test_strdelim.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/misc/tests.c b/regress/unittests/misc/tests.c index b0b7cd433..d086a063e 100644 --- a/regress/unittests/misc/tests.c +++ b/regress/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. * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/sshbuf/test_sshbuf.c b/regress/unittests/sshbuf/test_sshbuf.c index ee77d6934..052d4f2ba 100644 --- a/regress/unittests/sshbuf/test_sshbuf.c +++ b/regress/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 * @@ -9,7 +9,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H # include @@ -24,6 +23,8 @@ void sshbuf_tests(void); +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) + void sshbuf_tests(void) { diff --git a/regress/unittests/sshbuf/test_sshbuf_fixed.c b/regress/unittests/sshbuf/test_sshbuf_fixed.c index df4925f7c..dff77f042 100644 --- a/regress/unittests/sshbuf/test_sshbuf_fixed.c +++ b/regress/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 * @@ -9,7 +9,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H # include diff --git a/regress/unittests/sshbuf/test_sshbuf_fuzz.c b/regress/unittests/sshbuf/test_sshbuf_fuzz.c index e236c82f9..e3f570be4 100644 --- a/regress/unittests/sshbuf/test_sshbuf_fuzz.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H # include diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_basic.c b/regress/unittests/sshbuf/test_sshbuf_getput_basic.c index bea89881a..3da413edd 100644 --- a/regress/unittests/sshbuf/test_sshbuf_getput_basic.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H # include diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c b/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c index 492b3bdf0..e3620e97f 100644 --- a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c +++ b/regress/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 * @@ -10,7 +10,6 @@ #ifdef WITH_OPENSSL #include -#include #include #ifdef HAVE_STDINT_H # include diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c b/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c index 1ca30be97..5de8707c4 100644 --- a/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H # include diff --git a/regress/unittests/sshbuf/test_sshbuf_misc.c b/regress/unittests/sshbuf/test_sshbuf_misc.c index c53db937f..249ecf235 100644 --- a/regress/unittests/sshbuf/test_sshbuf_misc.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H # include diff --git a/regress/unittests/sshkey/common.c b/regress/unittests/sshkey/common.c index effea578c..51b0d92e1 100644 --- a/regress/unittests/sshkey/common.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #include #include diff --git a/regress/unittests/sshkey/test_file.c b/regress/unittests/sshkey/test_file.c index deb3ec125..497ab6dde 100644 --- a/regress/unittests/sshkey/test_file.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #include #include diff --git a/regress/unittests/sshkey/test_fuzz.c b/regress/unittests/sshkey/test_fuzz.c index f111446a9..a583c4a57 100644 --- a/regress/unittests/sshkey/test_fuzz.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #include #include diff --git a/regress/unittests/sshkey/test_sshkey.c b/regress/unittests/sshkey/test_sshkey.c index 7dc20cc85..1f5da68b1 100644 --- a/regress/unittests/sshkey/test_sshkey.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #ifdef HAVE_STDINT_H #include diff --git a/regress/unittests/sshsig/tests.c b/regress/unittests/sshsig/tests.c index 48db08bfb..c44a98079 100644 --- a/regress/unittests/sshsig/tests.c +++ b/regress/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 * @@ -8,7 +8,6 @@ #include "includes.h" #include -#include #include #include #include diff --git a/regress/unittests/test_helper/test_helper.c b/regress/unittests/test_helper/test_helper.c index 9014ce8e4..de125fcd4 100644 --- a/regress/unittests/test_helper/test_helper.c +++ b/regress/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 * @@ -44,6 +44,8 @@ # include #endif +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + #include "entropy.h" #include "test_helper.h" #include "atomicio.h" @@ -415,8 +417,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); @@ -455,7 +457,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);