]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/crypto/isa-l/isa-l_crypto/sha256_mb/sha256_mb_rand_update_test.c
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / crypto / isa-l / isa-l_crypto / sha256_mb / sha256_mb_rand_update_test.c
index 1cd6583afba30a4db012e88f51ea404adb7f4147..9535d80dfcbf9b5c320c918b51af034d7c156d80 100644 (file)
@@ -2,7 +2,7 @@
   Copyright(c) 2011-2016 Intel Corporation All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions 
+  modification, are permitted provided that the following conditions
   are met:
     * Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
@@ -73,13 +73,19 @@ int main(void)
        unsigned char *buf_ptr[TEST_BUFS];
        uint32_t lens[TEST_BUFS];
        unsigned int joblen, jobs, t;
+       int ret;
 
        printf("multibinary_sha256_update test, %d sets of %dx%d max: ", RANDOMS, TEST_BUFS,
               TEST_LEN);
 
        srand(TEST_SEED);
 
-       posix_memalign((void *)&mgr, 16, sizeof(SHA256_HASH_CTX_MGR));
+       ret = posix_memalign((void *)&mgr, 16, sizeof(SHA256_HASH_CTX_MGR));
+       if ((ret != 0) || (mgr == NULL)) {
+               printf("posix_memalign failed test aborted\n");
+               return 1;
+       }
+
        sha256_ctx_mgr_init(mgr);
 
        for (i = 0; i < TEST_BUFS; i++) {
@@ -187,7 +193,7 @@ int main(void)
                // Run sha256_sb jobs
                i = 0;
                while (i < jobs) {
-                       // Submit a new job 
+                       // Submit a new job
                        len_rand = SHA256_BLOCK_SIZE +
                            SHA256_BLOCK_SIZE * (rand() % MAX_RAND_UPDATE_BLOCKS);
 
@@ -201,16 +207,16 @@ int main(void)
                                                            buf_ptr[i], lens[i], HASH_ENTIRE);
 
                        // Returned ctx could be:
-                       //  - null context (we are just getting started and lanes aren't full yet), or 
-                       //  - finished already (an ENTIRE we submitted or a previous LAST is returned), or 
+                       //  - null context (we are just getting started and lanes aren't full yet), or
+                       //  - finished already (an ENTIRE we submitted or a previous LAST is returned), or
                        //  - an unfinished ctx, we will resubmit
 
                        if ((ctx == NULL) || hash_ctx_complete(ctx)) {
                                i++;
                                continue;
                        } else {
-                               // unfinished ctx returned, choose another random update length and submit either 
-                               // UPDATE or LAST depending on the amount of buffer remaining 
+                               // unfinished ctx returned, choose another random update length and submit either
+                               // UPDATE or LAST depending on the amount of buffer remaining
                                while ((ctx != NULL) && !(hash_ctx_complete(ctx))) {
                                        j = (unsigned long)(ctx->user_data);    // Get index of the returned ctx
                                        buf_ptr[j] = bufs[j] + ctx->total_length;
@@ -230,8 +236,8 @@ int main(void)
                                                                            buf_ptr[j],
                                                                            len_rand,
                                                                            HASH_UPDATE);
-                               }       // Either continue submitting any contexts returned here as UPDATE/LAST, or 
-                               // go back to submitting new jobs using the index i. 
+                               }       // Either continue submitting any contexts returned here as UPDATE/LAST, or
+                               // go back to submitting new jobs using the index i.
 
                                i++;
                        }