]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: sys/param.h cleanup, mostly using MINIMUM() and
authorderaadt@openbsd.org <deraadt@openbsd.org>
Tue, 14 Dec 2021 21:25:27 +0000 (21:25 +0000)
committerDamien Miller <djm@mindrot.org>
Mon, 20 Dec 2021 01:16:49 +0000 (12:16 +1100)
<limits.h> ok dtucker

OpenBSD-Regress-ID: 172a4c45d3bcf92fa6cdf6c4b9db3f1b3abe4db0

25 files changed:
regress/unittests/authopt/tests.c
regress/unittests/bitmap/tests.c
regress/unittests/conversion/tests.c
regress/unittests/hostkeys/test_iterate.c
regress/unittests/kex/test_kex.c
regress/unittests/match/tests.c
regress/unittests/misc/test_argv.c
regress/unittests/misc/test_convtime.c
regress/unittests/misc/test_expand.c
regress/unittests/misc/test_parse.c
regress/unittests/misc/test_strdelim.c
regress/unittests/misc/tests.c
regress/unittests/sshbuf/test_sshbuf.c
regress/unittests/sshbuf/test_sshbuf_fixed.c
regress/unittests/sshbuf/test_sshbuf_fuzz.c
regress/unittests/sshbuf/test_sshbuf_getput_basic.c
regress/unittests/sshbuf/test_sshbuf_getput_crypto.c
regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c
regress/unittests/sshbuf/test_sshbuf_misc.c
regress/unittests/sshkey/common.c
regress/unittests/sshkey/test_file.c
regress/unittests/sshkey/test_fuzz.c
regress/unittests/sshkey/test_sshkey.c
regress/unittests/sshsig/tests.c
regress/unittests/test_helper/test_helper.c

index 9873c09c6545ae4d401a2ba9264a2b475046f48a..d9e190305e761d7c1c80027b815f2e088f4af767 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index f66a4ce46a560202196be1be55f04517bc143f0b..576b863f4066dd5366011214763c2eb7c4f716d8 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index bbdc5f5a7cb1a73d3ab3bb051d40df370652ac0f..5b526f7afa07af227e3e427b74b6231b74625761 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index a5b17d7e4056d6f211e2ba622ddc0e131efadd9f..84f26b5c72f500683474f2df3bdc8fbb65c62df4 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index 3bd71a9f4d5613da399e5bdd3bcdf9733bf4d902..c26761ee7c48fc2e2171e265d6aeee9190117116 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index 4fefaf4f3756bf4109f8a807c6dda0fd6675e9d8..f00d1f9348fcfc29dad78a1081064526ec17a59e 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index 2cfebf2d958893cf26743b8b72f0d4d183b086ab..682863e73ba91161ae5113e766c9359b90231ee1 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index 8f9be89ff900b20939fa376b87fa04eab65d1cf7..ef6fd77deda5740532aefb03c77d8795b851bb22 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
+#include <limits.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index 513c69bce4e2c08813fd36c78e31056c87dd95d5..6f2cd8adbedd342185ea95da03513b5b072984dd 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index 727ff3dea9d7539e8d305664c8655a66bb6fb1f8..1f1ea31d149c251fb436f2ac5920448961f88ebf 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index 1d9133d4b31b88a8141ffbf5ec17cbdb0d0ee285..f7bea4bfe8f7a54c9d5d1bc75534899ab4c91ebd 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index b0b7cd4332e322a77bc6a04d84d82e45bc441ee7..d086a063e9aa184b7b97d568f01dc4ac172922ab 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index ee77d6934a4d162d00aaa9b052e635d1384d1f2a..052d4f2ba470ad2b9357b591a9410947baf01aba 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
@@ -24,6 +23,8 @@
 
 void sshbuf_tests(void);
 
+#define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
+
 void
 sshbuf_tests(void)
 {
index df4925f7c6f6b2b9bd208ac917128aca6b226511..dff77f0421527997688fdc5540c135db6b458bc1 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
index e236c82f96fc77c638ed929fde9423914029d7fb..e3f570be46abdf783664217840745f45836decde 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
index bea89881a4638604e67a0e4875518f1978e2024b..3da413edd35c8d2fadcf2c9b068f0a8bca7595c7 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
index 492b3bdf0627f9034326ff7a89c915cb6187f007..e3620e97fe991fbeee0519ab80547efde98522cb 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
index 1ca30be973ce4699cf2246fd3338b23ed6bc9423..5de8707c47c81663c80ec06c7190f7c6f5cff38b 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
index c53db937f2f1a781d29a5d8f985c2079b8f7a9f6..249ecf235764a28a0557b7b39604846cea8652b5 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
index effea578c0947ef325cf9883b5cb93663e965d77..51b0d92e1d0734bd0ab7078b94a5e9d1422a162b 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdio.h>
index deb3ec125c9a2bef10817be601c4a9018f63c3f8..497ab6dded1d0fa841cd74cbf4819578aee3c5a3 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdio.h>
index f111446a9398a58e9d6370a5742a5d28379ec784..a583c4a5774e23ed7cc26b9619d01d95835f671d 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdio.h>
index 7dc20cc857a542ed62c973bcde3d64c5719aa64c..1f5da68b138e5574bce3aa38dbeba8b774f41fc7 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <stdio.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
index 48db08bfbefb73882f78ef3f53bab33964010745..c44a98079f94d9745d5514cf9238c7f01106f8f5 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/param.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdio.h>
index 9014ce8e4d020f1f84fe59e805dbc756f312ec30..de125fcd4b294cba32dfbd5dcd2717fb550eb96a 100644 (file)
@@ -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 <djm@mindrot.org>
  *
@@ -44,6 +44,8 @@
 # include <vis.h>
 #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);