upstream: sys/param.h cleanup, mostly using MINIMUM() and

<limits.h> ok dtucker

OpenBSD-Regress-ID: 172a4c45d3bcf92fa6cdf6c4b9db3f1b3abe4db0
This commit is contained in:
deraadt@openbsd.org 2021-12-14 21:25:27 +00:00 committed by Damien Miller
parent 266678e19e
commit 3eead81583
25 changed files with 33 additions and 52 deletions

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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)
{

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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);