From 1181e0590c9f059c40b71718d4fb3b6c339f65db Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Mon, 16 Mar 2020 21:02:18 +0000 Subject: Use PAM_ARRAY_SIZE Replace all instances of sizeof(x) / sizeof(*x) with PAM_ARRAY_SIZE(x) which is less error-prone and implements an additional type check. * libpam/pam_handlers.c: Include "pam_inline.h". (_pam_open_config_file): Use PAM_ARRAY_SIZE. * modules/pam_exec/pam_exec.c: Include "pam_inline.h". (call_exec): Use PAM_ARRAY_SIZE. * modules/pam_namespace/pam_namespace.c: Include "pam_inline.h". (filter_mntopts): Use PAM_ARRAY_SIZE. * modules/pam_timestamp/hmacfile.c: Include "pam_inline.h". (testvectors): Use PAM_ARRAY_SIZE. * modules/pam_xauth/pam_xauth.c: Include "pam_inline.h". (run_coprocess, pam_sm_open_session): Use PAM_ARRAY_SIZE. * tests/tst-pam_get_item.c: Include "pam_inline.h". (main): Use PAM_ARRAY_SIZE. * tests/tst-pam_set_item.c: Likewise. * xtests/tst-pam_pwhistory1.c: Likewise. * xtests/tst-pam_time1.c: Likewise. --- xtests/tst-pam_time1.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'xtests/tst-pam_time1.c') diff --git a/xtests/tst-pam_time1.c b/xtests/tst-pam_time1.c index 9fc0669e..18dfeba9 100644 --- a/xtests/tst-pam_time1.c +++ b/xtests/tst-pam_time1.c @@ -49,6 +49,7 @@ #include #include #include +#include "pam_inline.h" struct test_t { @@ -65,8 +66,6 @@ static struct test_t tests[] = { {"y", 6}, }; -static int num_tests = sizeof (tests) / sizeof (struct test_t); - static struct pam_conv conv = { NULL, NULL }; @@ -77,12 +76,12 @@ main(int argc, char *argv[]) pam_handle_t *pamh = NULL; int retval; int debug = 0; - int i; + unsigned int i; if (argc > 1 && strcmp (argv[1], "-d") == 0) debug = 1; - for (i = 0; i < num_tests; i++) + for (i = 0; i < PAM_ARRAY_SIZE(tests); i++) { retval = pam_start("tst-pam_time1", tests[i].user, &conv, &pamh); if (retval != PAM_SUCCESS) -- cgit v1.2.3