Browse Source

ADD_TO_LOG and GOTO are now simply removed everywhere.

doc_update_sequoia
Krista Bennett 4 years ago
parent
commit
26422fbe28
4 changed files with 74 additions and 83 deletions
  1. +13
    -13
      src/keymanagement.c
  2. +60
    -60
      src/message_api.c
  3. +1
    -1
      src/pEpEngine.c
  4. +0
    -9
      src/pEp_internal.h

+ 13
- 13
src/keymanagement.c View File

@ -142,7 +142,7 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
status = key_revoked(session, fpr, &revoked);
if (status != PEP_STATUS_OK) {
return ADD_TO_LOG(status);
return status;
}
if (!revoked) {
@ -155,7 +155,7 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
assert(status == PEP_STATUS_OK);
if (status != PEP_STATUS_OK)
return ADD_TO_LOG(status);
return status;
if ((ct | PEP_ct_confirmed) == PEP_ct_OpenPGP &&
!ident->me) {
@ -164,7 +164,7 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
&blacklisted);
if (status != PEP_STATUS_OK)
return ADD_TO_LOG(status);
return status;
}
}
@ -180,7 +180,7 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
status = key_expired(session, fpr, time(NULL), &expired);
if (status != PEP_STATUS_OK) {
ident->comm_type = PEP_ct_key_expired;
return ADD_TO_LOG(status);
return status;
}
// communicate key(?)
}
@ -458,7 +458,7 @@ DYNAMIC_API PEP_STATUS update_identity(
assert(!EMPTYSTR(identity->address));
if (!(session && identity && !EMPTYSTR(identity->address)))
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
char* default_own_id = NULL;
status = get_default_own_userid(session, &default_own_id);
@ -729,7 +729,7 @@ DYNAMIC_API PEP_STATUS update_identity(
if (session->examine_identity)
session->examine_identity(identity, session->examine_management);
return ADD_TO_LOG(status);
return status;
}
PEP_STATUS elect_ownkey(
@ -819,7 +819,7 @@ PEP_STATUS _has_usable_priv_key(PEP_SESSION session, char* fpr,
*is_usable = !dont_use_fpr;
return ADD_TO_LOG(status);
return status;
}
PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen, bool ignore_flags)
@ -834,7 +834,7 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
if (!session || !identity || EMPTYSTR(identity->address) ||
EMPTYSTR(identity->user_id))
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
pEp_identity *stored_identity = NULL;
char* revoked_fpr = NULL;
@ -871,7 +871,7 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
// Let's see if we have an identity record in the DB for
// this user_id + address
DEBUG_LOG("myself", "debug", identity->address);
// DEBUG_LOG("myself", "debug", identity->address);
status = get_identity(session,
identity->address,
@ -942,7 +942,7 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
if (!do_keygen)
status = PEP_GET_KEY_FAILED;
else {
DEBUG_LOG("Generating key pair", "debug", identity->address);
// / DEBUG_LOG("Generating key pair", "debug", identity->address);
free(identity->fpr);
identity->fpr = NULL;
@ -952,7 +952,7 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
if (status != PEP_STATUS_OK) {
char buf[11];
snprintf(buf, 11, "%d", status); // uh, this is kludgey. FIXME
DEBUG_LOG("Generating key pair failed", "debug", buf);
// DEBUG_LOG("Generating key pair failed", "debug", buf);
}
else {
valid_key_found = true;
@ -980,7 +980,7 @@ pep_free:
free(default_own_id);
free(revoked_fpr);
free_identity(stored_identity);
return ADD_TO_LOG(status);
return status;
}
DYNAMIC_API PEP_STATUS initialise_own_identities(PEP_SESSION session,
@ -1011,7 +1011,7 @@ pep_error:
DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
{
return ADD_TO_LOG(_myself(session, identity, true, false));
return _myself(session, identity, true, false);
}
DYNAMIC_API PEP_STATUS register_examine_function(


+ 60
- 60
src/message_api.c View File

@ -1461,15 +1461,15 @@ DYNAMIC_API PEP_STATUS encrypt_message(
assert(dst);
if (!(session && src && dst))
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
if (src->dir == PEP_dir_incoming)
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
determine_encryption_format(src);
// TODO: change this for multi-encryption in message format 2.0
if (src->enc_format != PEP_enc_none)
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
*dst = NULL;
@ -1484,7 +1484,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
status = myself(session, src->from);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
keys = new_stringlist(src->from->fpr);
if (keys == NULL)
@ -1531,7 +1531,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
_status = myself(session, _il->ident);
if (_status != PEP_STATUS_OK) {
status = PEP_UNENCRYPTED;
GOTO(pep_error);
goto pep_error;
}
if (_il->ident->fpr && _il->ident->fpr[0]) {
@ -1563,7 +1563,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
_status = myself(session, _il->ident);
if (_status != PEP_STATUS_OK) {
status = PEP_UNENCRYPTED;
GOTO(pep_error);
goto pep_error;
}
if (_il->ident->fpr && _il->ident->fpr[0]) {
@ -1595,7 +1595,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
if (_status != PEP_STATUS_OK)
{
status = PEP_UNENCRYPTED;
GOTO(pep_error);
goto pep_error;
}
if (_il->ident->fpr && _il->ident->fpr[0]) {
@ -1622,7 +1622,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
attach_own_key(session, src);
decorate_message(src, PEP_rating_undefined, NULL, true);
}
return ADD_TO_LOG(PEP_UNENCRYPTED);
return PEP_UNENCRYPTED;
}
else {
// FIXME - we need to deal with transport types (via flag)
@ -1663,14 +1663,14 @@ DYNAMIC_API PEP_STATUS encrypt_message(
default:
assert(0);
status = PEP_ILLEGAL_VALUE;
GOTO(pep_error);
goto pep_error;
}
if (status == PEP_OUT_OF_MEMORY)
goto enomem;
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
}
free_stringlist(keys);
@ -1699,7 +1699,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
if (_src && _src != src)
free_message(_src);
return ADD_TO_LOG(status);
return status;
enomem:
status = PEP_OUT_OF_MEMORY;
@ -1710,7 +1710,7 @@ pep_error:
if (_src && _src != src)
free_message(_src);
return ADD_TO_LOG(status);
return status;
}
DYNAMIC_API PEP_STATUS encrypt_message_for_self(
@ -1733,14 +1733,14 @@ DYNAMIC_API PEP_STATUS encrypt_message_for_self(
assert(enc_format != PEP_enc_none);
if (!(session && src && dst && enc_format != PEP_enc_none))
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
if (src->dir == PEP_dir_incoming)
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
determine_encryption_format(src);
if (src->enc_format != PEP_enc_none)
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
if (target_id && (!target_id->user_id || target_id->user_id[0] == '\0')) {
char* own_id = NULL;
@ -1753,7 +1753,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_for_self(
status = myself(session, target_id);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
*dst = NULL;
@ -1831,7 +1831,7 @@ pep_error:
if (src != _src)
free_message(_src);
return ADD_TO_LOG(status);
return status;
}
// static PEP_STATUS _update_identity_for_incoming_message(
@ -2508,7 +2508,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
assert(flags);
if (!(session && src && dst && keylist && rating && flags))
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
/*** Begin init ***/
PEP_STATUS status = PEP_STATUS_OK;
@ -2569,7 +2569,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
status = myself(session, src->from);
if (status != PEP_STATUS_OK)
return ADD_TO_LOG(status);
return status;
/*** End Import any attached public keys and update identities accordingly ***/
@ -2598,7 +2598,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
pull_up_attached_main_msg(src);
return ADD_TO_LOG(PEP_UNENCRYPTED);
return PEP_UNENCRYPTED;
}
status = get_crypto_text(src, &ctext, &csize);
@ -2611,7 +2611,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
&ptext, &psize, &_keylist);
if (status > PEP_CANNOT_DECRYPT_UNKNOWN)
GOTO(pep_error);
goto pep_error;
decrypt_status = status;
@ -2644,7 +2644,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
&imported_private_key_address,
private_il);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
/* if decrypted, but not verified... */
if (decrypt_status == PEP_DECRYPTED) {
@ -2705,7 +2705,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
actual_message->size,
&inner_message);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
if (inner_message) {
// Though this will strip any message info on the
@ -2722,7 +2722,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
if (strcmp(wrap_info, "INNER") == 0) {
if (status != PEP_STATUS_OK) {
free_message(inner_message);
GOTO(pep_error);
goto pep_error;
}
// THIS is our message
@ -2740,7 +2740,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
else { // should never happen
status = PEP_UNKNOWN_ERROR;
free_message(inner_message);
GOTO(pep_error);
goto pep_error;
}
}
inner_message->enc_format = PEP_enc_none;
@ -2775,7 +2775,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
rating, src->from, _keylist);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
/* We decrypted ok, hallelujah. */
msg->enc_format = PEP_enc_none;
@ -2822,9 +2822,9 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
*keylist = _keylist;
if(decrypt_status == PEP_DECRYPTED_AND_VERIFIED)
return ADD_TO_LOG(PEP_STATUS_OK);
return PEP_STATUS_OK;
else
return ADD_TO_LOG(decrypt_status);
return decrypt_status;
enomem:
status = PEP_OUT_OF_MEMORY;
@ -2835,7 +2835,7 @@ pep_error:
free_message(msg);
free_stringlist(_keylist);
return ADD_TO_LOG(status);
return status;
}
DYNAMIC_API PEP_STATUS decrypt_message(
@ -2884,7 +2884,7 @@ DYNAMIC_API PEP_STATUS own_message_private_key_details(
free_identity_list(private_il);
return ADD_TO_LOG(status);
return status;
}
// Note: if comm_type_determine is false, it generally means that
@ -2941,10 +2941,10 @@ DYNAMIC_API PEP_STATUS outgoing_message_rating(
assert(rating);
if (!(session && msg && rating))
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
if (msg->dir != PEP_dir_outgoing)
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
*rating = PEP_rating_undefined;
@ -3222,7 +3222,7 @@ DYNAMIC_API PEP_STATUS get_trustwords(
free (XORed_fpr);
the_end:
return ADD_TO_LOG(status);
return status;
}
DYNAMIC_API PEP_STATUS get_message_trustwords(
@ -3308,7 +3308,7 @@ DYNAMIC_API PEP_STATUS get_message_trustwords(
if (status != PEP_STATUS_OK) {
free_identity(partner);
return ADD_TO_LOG(status);
return status;
}
// Find own identity corresponding to given account address.
@ -3321,7 +3321,7 @@ DYNAMIC_API PEP_STATUS get_message_trustwords(
if (status != PEP_STATUS_OK) {
free_identity(stored_identity);
return ADD_TO_LOG(status);
return status;
}
// get the trustwords
@ -3330,7 +3330,7 @@ DYNAMIC_API PEP_STATUS get_message_trustwords(
partner, received_by,
lang, words, &wsize, full);
return ADD_TO_LOG(status);
return status;
}
DYNAMIC_API PEP_STATUS MIME_decrypt_message(
@ -3356,7 +3356,7 @@ DYNAMIC_API PEP_STATUS MIME_decrypt_message(
status = mime_decode_message(mimetext, size, &tmp_msg);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
// MIME decode message delivers only addresses. We need more.
if (tmp_msg->from) {
@ -3366,20 +3366,20 @@ DYNAMIC_API PEP_STATUS MIME_decrypt_message(
status = myself(session, tmp_msg->from);
if (status == PEP_ILLEGAL_VALUE || status == PEP_OUT_OF_MEMORY)
GOTO(pep_error);
goto pep_error;
}
status = update_identity_recip_list(session, tmp_msg->to);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
status = update_identity_recip_list(session, tmp_msg->cc);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
status = update_identity_recip_list(session, tmp_msg->bcc);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
PEP_STATUS decrypt_status = decrypt_message(session,
tmp_msg,
@ -3395,7 +3395,7 @@ DYNAMIC_API PEP_STATUS MIME_decrypt_message(
if (decrypt_status > PEP_CANNOT_DECRYPT_UNKNOWN || !dec_msg)
{
status = decrypt_status;
GOTO(pep_error);
goto pep_error;
}
// FIXME: test with att
@ -3405,14 +3405,14 @@ DYNAMIC_API PEP_STATUS MIME_decrypt_message(
{
free(tmp_msg);
free(dec_msg);
return ADD_TO_LOG(decrypt_status);
return decrypt_status;
}
pep_error:
free_message(tmp_msg);
free_message(dec_msg);
return ADD_TO_LOG(status);
return status;
}
@ -3432,7 +3432,7 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message(
status = mime_decode_message(mimetext, size, &tmp_msg);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
// MIME decode message delivers only addresses. We need more.
if (tmp_msg->from) {
@ -3449,7 +3449,7 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message(
status = myself(session, tmp_msg->from);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
}
// Own identities can be retrieved here where they would otherwise
@ -3457,15 +3457,15 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message(
// desired. FIXME: IS it?
status = update_identity_recip_list(session, tmp_msg->to);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
status = update_identity_recip_list(session, tmp_msg->cc);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
status = update_identity_recip_list(session, tmp_msg->bcc);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
// This isn't incoming, though... so we need to reverse the direction
tmp_msg->dir = PEP_dir_outgoing;
@ -3476,12 +3476,12 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message(
enc_format,
flags);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
if (!enc_msg) {
status = PEP_UNKNOWN_ERROR;
GOTO(pep_error);
goto pep_error;
}
status = _mime_encode_message_internal(enc_msg, false, mime_ciphertext, false);
@ -3490,7 +3490,7 @@ pep_error:
free_message(tmp_msg);
free_message(enc_msg);
return ADD_TO_LOG(status);
return status;
}
@ -3534,7 +3534,7 @@ pep_error:
free_message(tmp_msg);
free_message(enc_msg);
return ADD_TO_LOG(status);
return status;
}
static PEP_rating string_to_rating(const char * rating)
@ -3627,7 +3627,7 @@ DYNAMIC_API PEP_STATUS re_evaluate_message_rating(
assert(rating);
if (!(session && msg && rating))
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
*rating = PEP_rating_undefined;
@ -3638,7 +3638,7 @@ DYNAMIC_API PEP_STATUS re_evaluate_message_rating(
goto got_rating;
}
}
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
}
got_rating:
@ -3650,7 +3650,7 @@ got_rating:
if (strcasecmp(i->value->key, "X-KeyList") == 0){
status = string_to_keylist(i->value->value, &_keylist);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
must_free_keylist = true;
goto got_keylist;
}
@ -3659,10 +3659,10 @@ got_rating:
// there was no rcpt fpr, it could be an unencrypted mail
if(_rating == PEP_rating_unencrypted) {
*rating = _rating;
return ADD_TO_LOG(PEP_STATUS_OK);
return PEP_STATUS_OK;
}
return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
return PEP_ILLEGAL_VALUE;
}
got_keylist:
@ -3672,7 +3672,7 @@ got_keylist:
status = myself(session, msg->from);
if (status != PEP_STATUS_OK)
GOTO(pep_error);
goto pep_error;
status = amend_rating_according_to_sender_and_recipients(session, &_rating,
msg->from, _keylist);
@ -3683,5 +3683,5 @@ pep_error:
if (must_free_keylist)
free_stringlist(_keylist);
return ADD_TO_LOG(status);
return status;
}

+ 1
- 1
src/pEpEngine.c View File

@ -3356,7 +3356,7 @@ enomem:
status = PEP_OUT_OF_MEMORY;
the_end:
return ADD_TO_LOG(status);
return status;
}
DYNAMIC_API PEP_STATUS get_languagelist(


+ 0
- 9
src/pEp_internal.h View File

@ -425,12 +425,3 @@ static inline void _init_globals() {
_pEp_rand_max_bits = ceil(log2(RAND_MAX));
_pEp_log2_36 = log2(36);
}
#ifdef DEBUG_ERRORSTACK
PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status);
#define ADD_TO_LOG(status) session_add_error(session, __FILE__, __LINE__, (status))
#define GOTO(label) do{ (void)session_add_error(session, __FILE__, __LINE__, status); goto label; }while(0)
#else
#define ADD_TO_LOG(status) (status)
#define GOTO(label) goto label
#endif

Loading…
Cancel
Save