Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/crypto/opencrypto constify more to avoid gcc stupidity.



details:   https://anonhg.NetBSD.org/src/rev/6b348850a2a3
branches:  trunk
changeset: 824695:6b348850a2a3
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jun 14 21:43:02 2017 +0000

description:
constify more to avoid gcc stupidity.

diffstat:

 tests/crypto/opencrypto/h_ioctl.c |  39 ++++++++++++++++++---------------------
 1 files changed, 18 insertions(+), 21 deletions(-)

diffs (127 lines):

diff -r 73421c427378 -r 6b348850a2a3 tests/crypto/opencrypto/h_ioctl.c
--- a/tests/crypto/opencrypto/h_ioctl.c Wed Jun 14 21:05:02 2017 +0000
+++ b/tests/crypto/opencrypto/h_ioctl.c Wed Jun 14 21:43:02 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: h_ioctl.c,v 1.2 2017/06/13 08:16:16 martin Exp $       */
+/*     $NetBSD: h_ioctl.c,v 1.3 2017/06/14 21:43:02 christos Exp $     */
 
 /*-
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -57,6 +57,8 @@
 { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
   0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a, };
 
+#define COUNT 2
+
 /*
  * CRIOGET is deprecated.
  */
@@ -70,10 +72,9 @@
 {
        int ret;
        struct crypt_sgop sg;
-       struct session_n_op css[2];
-       const size_t cs_count = __arraycount(css);
+       struct session_n_op css[COUNT];
 
-       for (size_t i = 0; i < cs_count; i++) {
+       for (size_t i = 0; i < COUNT; i++) {
                struct session_n_op *cs = &css[i];
 
                memset(cs, 0, sizeof(*cs));
@@ -82,7 +83,7 @@
                cs->key = __UNCONST(&aes_key);
        }
        memset(&sg, 0, sizeof(sg));
-       sg.count = cs_count;
+       sg.count = COUNT;
        sg.sessions = css;
 
        ret = ioctl(fd, CIOCNGSESSION, &sg);
@@ -101,12 +102,11 @@
 {
        int ret;
        struct crypt_sfop sf;
-       u_int32_t sids[2];
-       const size_t sid_count = __arraycount(sids);
+       u_int32_t sids[COUNT];
 
        memset(sids, 0, sizeof(sids));
        memset(&sf, 0, sizeof(sf));
-       sf.count = sid_count;
+       sf.count = COUNT;
        sf.sesid = sids;
 
        ret = ioctl(fd, CIOCNFSESSION, &sf);
@@ -125,10 +125,9 @@
 {
        int ret;
        struct crypt_mop mop;
-       struct crypt_n_op css[2];
-       const size_t cs_count = __arraycount(css);
+       struct crypt_n_op css[COUNT];
 
-       for (size_t i = 0; i < cs_count; i++) {
+       for (size_t i = 0; i < COUNT; i++) {
                struct crypt_n_op *cs;
                cs = &css[i];
 
@@ -139,7 +138,7 @@
        }
 
        memset(&mop, 0, sizeof(mop));
-       mop.count = cs_count;
+       mop.count = COUNT;
        mop.reqs = css;
 
        ret = ioctl(fd, CIOCNCRYPTM, &mop);
@@ -160,12 +159,10 @@
        struct session_op cs;
 
        struct crypt_mop mop;
-       struct crypt_n_op cnos[2];
-       const size_t req_count = __arraycount(cnos);
-       unsigned char cno_dst[req_count][AES_CIPHER_LEN];
-
+       struct crypt_n_op cnos[COUNT];
+       unsigned char cno_dst[COUNT][AES_CIPHER_LEN];
        struct cryptret cret;
-       struct crypt_result crs[req_count];
+       struct crypt_result crs[COUNT];
 
        memset(&cs, 0, sizeof(cs));
        cs.cipher = CRYPTO_AES_CBC;
@@ -177,7 +174,7 @@
                return ret;
        }
 
-       for (size_t i = 0; i < req_count; i++) {
+       for (size_t i = 0; i < COUNT; i++) {
                struct crypt_n_op *cno = &cnos[i];
 
                memset(cno, 0, sizeof(*cno));
@@ -190,13 +187,13 @@
        }
 
        memset(&mop, 0, sizeof(mop));
-       mop.count = req_count;
+       mop.count = COUNT;
        mop.reqs = cnos;
        ret = ioctl(fd, CIOCNCRYPTM, &mop);
        if (ret < 0)
                fprintf(stderr, "failed: CIOCNCRYPTM\n");
 
-       for (size_t i = 0; i < req_count; i++) {
+       for (size_t i = 0; i < COUNT; i++) {
                struct crypt_result *cr = &crs[i];
 
                memset(cr, 0, sizeof(*cr));
@@ -204,7 +201,7 @@
        }
 
        memset(&cret, 0, sizeof(cret));
-       cret.count = req_count;
+       cret.count = COUNT;
        cret.results = crs;
        ret = ioctl(fd, CIOCNCRYPTRETM, &cret);
        if (ret < 0)



Home | Main Index | Thread Index | Old Index