diff options
author | Tomas Mraz <tomas@openssl.org> | 2023-06-26 17:13:30 +0200 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-06-28 08:31:07 +1000 |
commit | 32d2b5fdd93ceee192abefb3fd0ce8f9a1b329c2 (patch) | |
tree | 42cce26610d1170a35cbebdc4e8db6513dd30d3c | |
parent | 64aa8eaf125a33c573d47067849e3cfe89d23070 (diff) |
s390xcap.c: Avoid copying structure on initialization
This is problematic on old compilers. It also avoids duplicating
the read-only data.
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21284)
(cherry picked from commit 0dee3b0421047354abd0b70cedd4c1bceaf323b0)
-rw-r--r-- | crypto/s390xcap.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crypto/s390xcap.c b/crypto/s390xcap.c index 5d2e96805c..6bb9abb809 100644 --- a/crypto/s390xcap.c +++ b/crypto/s390xcap.c @@ -57,14 +57,16 @@ cap->NAME[1] = ~cap->NAME[1]; \ } -#define TOK_CPU(NAME) \ +#define TOK_CPU_ALIAS(NAME, STRUCT_NAME) \ (sscanf(tok_begin, \ " %" STR(LEN) "s %" STR(LEN) "s ", \ tok[0], tok[1]) == 1 \ && !strcmp(tok[0], #NAME)) { \ - memcpy(cap, &NAME, sizeof(*cap)); \ + memcpy(cap, &STRUCT_NAME, sizeof(*cap)); \ } +#define TOK_CPU(NAME) TOK_CPU_ALIAS(NAME, NAME) + #ifndef OSSL_IMPLEMENT_GETAUXVAL static sigjmp_buf ill_jmp; static void ill_handler(int sig) @@ -746,9 +748,8 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap, int *cex) /*- * z16 (2022) - z/Architecture POP - * Implements MSA and MSA1-9 (same as z15). + * Implements MSA and MSA1-9 (same as z15, no need to repeat). */ - static const struct OPENSSL_s390xcap_st z16 = z15; char *tok_begin, *tok_end, *buff, tok[S390X_STFLE_MAX][LEN + 1]; int rc, off, i, n; @@ -804,7 +805,7 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap, int *cex) else if TOK_CPU(z13) else if TOK_CPU(z14) else if TOK_CPU(z15) - else if TOK_CPU(z16) + else if TOK_CPU_ALIAS(z16, z15) /* nocex to deactivate cex support */ else if (sscanf(tok_begin, " %" STR(LEN) "s %" STR(LEN) "s ", |