Skip to content

Commit

Permalink
crypto: rename error flags in internal structures
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #14405)
  • Loading branch information
tniessen authored and paulidale committed Mar 4, 2021
1 parent 33ac7b3 commit e3a2ba7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions crypto/encode_decode/decoder_meth.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct decoder_data_st {
const char *names; /* For get_decoder_from_store() */
const char *propquery; /* For get_decoder_from_store() */

unsigned int flag_construct_error_occured : 1;
unsigned int flag_construct_error_occurred : 1;
};

/*
Expand Down Expand Up @@ -268,7 +268,7 @@ static void *construct_decoder(const OSSL_ALGORITHM *algodef,
* record on inaccessible algorithms.
*/
if (method == NULL)
methdata->flag_construct_error_occured = 1;
methdata->flag_construct_error_occurred = 1;

return method;
}
Expand Down Expand Up @@ -340,7 +340,7 @@ static OSSL_DECODER *inner_ossl_decoder_fetch(OSSL_LIB_CTX *libctx, int id,
mcmdata.id = id;
mcmdata.names = name;
mcmdata.propquery = properties;
mcmdata.flag_construct_error_occured = 0;
mcmdata.flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(libctx, OSSL_OP_DECODER,
0 /* !force_cache */,
&mcm, &mcmdata)) != NULL) {
Expand All @@ -360,7 +360,7 @@ static OSSL_DECODER *inner_ossl_decoder_fetch(OSSL_LIB_CTX *libctx, int id,
* If we never were in the constructor, the algorithm to be fetched
* is unsupported.
*/
unsupported = !mcmdata.flag_construct_error_occured;
unsupported = !mcmdata.flag_construct_error_occurred;
}

if (method == NULL) {
Expand Down
10 changes: 5 additions & 5 deletions crypto/encode_decode/decoder_pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ struct collect_decoder_data_st {
STACK_OF(OPENSSL_CSTRING) *names;
OSSL_DECODER_CTX *ctx;

unsigned int error_occured:1;
unsigned int error_occurred:1;
};

static void collect_decoder(OSSL_DECODER *decoder, void *arg)
Expand All @@ -229,10 +229,10 @@ static void collect_decoder(OSSL_DECODER *decoder, void *arg)
const OSSL_PROVIDER *prov = OSSL_DECODER_provider(decoder);
void *provctx = OSSL_PROVIDER_get0_provider_ctx(prov);

if (data->error_occured)
if (data->error_occurred)
return;

data->error_occured = 1; /* Assume the worst */
data->error_occurred = 1; /* Assume the worst */
if (data->names == NULL)
return;

Expand Down Expand Up @@ -266,7 +266,7 @@ static void collect_decoder(OSSL_DECODER *decoder, void *arg)
decoder->freectx(decoderctx);
}

data->error_occured = 0; /* All is good now */
data->error_occurred = 0; /* All is good now */
}

int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
Expand Down Expand Up @@ -326,7 +326,7 @@ int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
collect_decoder, &collect_decoder_data);
sk_OPENSSL_CSTRING_free(names);

if (collect_decoder_data.error_occured)
if (collect_decoder_data.error_occurred)
goto err;
}

Expand Down
8 changes: 4 additions & 4 deletions crypto/encode_decode/encoder_meth.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct encoder_data_st {
const char *names; /* For get_encoder_from_store() */
const char *propquery; /* For get_encoder_from_store() */

unsigned int flag_construct_error_occured : 1;
unsigned int flag_construct_error_occurred : 1;
};

/*
Expand Down Expand Up @@ -280,7 +280,7 @@ static void *construct_encoder(const OSSL_ALGORITHM *algodef,
* record on inaccessible algorithms.
*/
if (method == NULL)
methdata->flag_construct_error_occured = 1;
methdata->flag_construct_error_occurred = 1;

return method;
}
Expand Down Expand Up @@ -352,7 +352,7 @@ static OSSL_ENCODER *inner_ossl_encoder_fetch(OSSL_LIB_CTX *libctx,
mcmdata.id = id;
mcmdata.names = name;
mcmdata.propquery = properties;
mcmdata.flag_construct_error_occured = 0;
mcmdata.flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(libctx, OSSL_OP_ENCODER,
0 /* !force_cache */,
&mcm, &mcmdata)) != NULL) {
Expand All @@ -372,7 +372,7 @@ static OSSL_ENCODER *inner_ossl_encoder_fetch(OSSL_LIB_CTX *libctx,
* If we never were in the constructor, the algorithm to be fetched
* is unsupported.
*/
unsupported = !mcmdata.flag_construct_error_occured;
unsupported = !mcmdata.flag_construct_error_occurred;
}

if (method == NULL) {
Expand Down
24 changes: 12 additions & 12 deletions crypto/encode_decode/encoder_pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ struct collected_encoder_st {

OSSL_ENCODER_CTX *ctx;

int error_occured;
int error_occurred;
};

static void collect_encoder(OSSL_ENCODER *encoder, void *arg)
{
struct collected_encoder_st *data = arg;
size_t i, end_i;

if (data->error_occured)
if (data->error_occurred)
return;

data->error_occured = 1; /* Assume the worst */
data->error_occurred = 1; /* Assume the worst */

if (data->names == NULL)
return;
Expand All @@ -110,27 +110,27 @@ static void collect_encoder(OSSL_ENCODER *encoder, void *arg)
break;
}

data->error_occured = 0; /* All is good now */
data->error_occurred = 0; /* All is good now */
}

struct collected_names_st {
STACK_OF(OPENSSL_CSTRING) *names;
unsigned int error_occured:1;
unsigned int error_occurred:1;
};

static void collect_name(const char *name, void *arg)
{
struct collected_names_st *data = arg;

if (data->error_occured)
if (data->error_occurred)
return;

data->error_occured = 1; /* Assume the worst */
data->error_occurred = 1; /* Assume the worst */

if (sk_OPENSSL_CSTRING_push(data->names, name) <= 0)
return;

data->error_occured = 0; /* All is good now */
data->error_occurred = 0; /* All is good now */
}

/*
Expand Down Expand Up @@ -241,21 +241,21 @@ static int ossl_encoder_ctx_setup_for_pkey(OSSL_ENCODER_CTX *ctx,
* First, collect the keymgmt names, then the encoders that match.
*/
keymgmt_data.names = sk_OPENSSL_CSTRING_new_null();
keymgmt_data.error_occured = 0;
keymgmt_data.error_occurred = 0;
EVP_KEYMGMT_names_do_all(pkey->keymgmt, collect_name, &keymgmt_data);
if (keymgmt_data.error_occured) {
if (keymgmt_data.error_occurred) {
sk_OPENSSL_CSTRING_free(keymgmt_data.names);
goto err;
}

encoder_data.names = keymgmt_data.names;
encoder_data.output_type = ctx->output_type;
encoder_data.output_structure = ctx->output_structure;
encoder_data.error_occured = 0;
encoder_data.error_occurred = 0;
encoder_data.ctx = ctx;
OSSL_ENCODER_do_all_provided(libctx, collect_encoder, &encoder_data);
sk_OPENSSL_CSTRING_free(keymgmt_data.names);
if (encoder_data.error_occured) {
if (encoder_data.error_occurred) {
ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_MALLOC_FAILURE);
goto err;
}
Expand Down
8 changes: 4 additions & 4 deletions crypto/evp/evp_fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct evp_method_data_st {
const char *names; /* For get_evp_method_from_store() */
const char *propquery; /* For get_evp_method_from_store() */

unsigned int flag_construct_error_occured : 1;
unsigned int flag_construct_error_occurred : 1;

void *(*method_from_dispatch)(int name_id, const OSSL_DISPATCH *,
OSSL_PROVIDER *);
Expand Down Expand Up @@ -203,7 +203,7 @@ static void *construct_evp_method(const OSSL_ALGORITHM *algodef,
* record on inaccessible algorithms.
*/
if (method == NULL)
methdata->flag_construct_error_occured = 1;
methdata->flag_construct_error_occurred = 1;

return method;
}
Expand Down Expand Up @@ -299,7 +299,7 @@ inner_evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
mcmdata.method_from_dispatch = new_method;
mcmdata.refcnt_up_method = up_ref_method;
mcmdata.destruct_method = free_method;
mcmdata.flag_construct_error_occured = 0;
mcmdata.flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(libctx, operation_id,
0 /* !force_cache */,
&mcm, &mcmdata)) != NULL) {
Expand All @@ -320,7 +320,7 @@ inner_evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
* If we never were in the constructor, the algorithm to be fetched
* is unsupported.
*/
unsupported = !mcmdata.flag_construct_error_occured;
unsupported = !mcmdata.flag_construct_error_occurred;
}

if (method == NULL) {
Expand Down
8 changes: 4 additions & 4 deletions crypto/store/store_meth.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct loader_data_st {
const char *scheme; /* For get_loader_from_store() */
const char *propquery; /* For get_loader_from_store() */

unsigned int flag_construct_error_occured : 1;
unsigned int flag_construct_error_occurred : 1;
};

/*
Expand Down Expand Up @@ -253,7 +253,7 @@ static void *construct_loader(const OSSL_ALGORITHM *algodef,
* record on inaccessible algorithms.
*/
if (method == NULL)
methdata->flag_construct_error_occured = 1;
methdata->flag_construct_error_occurred = 1;

return method;
}
Expand Down Expand Up @@ -316,7 +316,7 @@ static OSSL_STORE_LOADER *inner_loader_fetch(OSSL_LIB_CTX *libctx,
mcmdata.scheme_id = id;
mcmdata.scheme = scheme;
mcmdata.propquery = properties;
mcmdata.flag_construct_error_occured = 0;
mcmdata.flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(libctx, OSSL_OP_STORE,
0 /* !force_cache */,
&mcm, &mcmdata)) != NULL) {
Expand All @@ -335,7 +335,7 @@ static OSSL_STORE_LOADER *inner_loader_fetch(OSSL_LIB_CTX *libctx,
* If we never were in the constructor, the algorithm to be fetched
* is unsupported.
*/
unsupported = !mcmdata.flag_construct_error_occured;
unsupported = !mcmdata.flag_construct_error_occurred;
}

if (method == NULL) {
Expand Down

0 comments on commit e3a2ba7

Please sign in to comment.