Fixed test problem - apparently, C compilers have different opinions about goto than C++ ones sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 20 Nov 2019 16:10:51 +0100
branchsync
changeset 42183c8fbe9246c5
parent 4208 0edca795564a
child 4219 5b85e2e8bb70
Fixed test problem - apparently, C compilers have different opinions about goto than C++ ones
src/aux_mime_msg.c
test/src/test_util.cc
     1.1 --- a/src/aux_mime_msg.c	Tue Nov 19 15:22:46 2019 +0100
     1.2 +++ b/src/aux_mime_msg.c	Wed Nov 20 16:10:51 2019 +0100
     1.3 @@ -156,8 +156,10 @@
     1.4  )
     1.5  {
     1.6      PEP_STATUS status = PEP_STATUS_OK;
     1.7 +    PEP_STATUS tmp_status = PEP_STATUS_OK;
     1.8      message* tmp_msg = NULL;
     1.9      message* enc_msg = NULL;
    1.10 +    message* ret_msg = NULL;                             
    1.11  
    1.12      status = mime_decode_message(mimetext, size, &tmp_msg);
    1.13      if (status != PEP_STATUS_OK)
    1.14 @@ -205,7 +207,6 @@
    1.15                               enc_format,
    1.16                               flags);
    1.17                               
    1.18 -    message* ret_msg = NULL;                         
    1.19      if (status == PEP_STATUS_OK || status == PEP_UNENCRYPTED)
    1.20          ret_msg = (status == PEP_STATUS_OK ? enc_msg : tmp_msg);
    1.21      else                                
    1.22 @@ -216,12 +217,12 @@
    1.23          goto pEp_error;
    1.24      }
    1.25      
    1.26 -    PEP_STATUS tmp_status = _mime_encode_message_internal(
    1.27 -                                    ret_msg, 
    1.28 -                                    false, 
    1.29 -                                    mime_ciphertext, 
    1.30 -                                    false, 
    1.31 -                                    false);
    1.32 +    tmp_status = _mime_encode_message_internal(
    1.33 +                                ret_msg, 
    1.34 +                                false, 
    1.35 +                                mime_ciphertext, 
    1.36 +                                false, 
    1.37 +                                false);
    1.38      
    1.39      if (tmp_status != PEP_STATUS_OK)
    1.40          status = tmp_status;
     2.1 --- a/test/src/test_util.cc	Tue Nov 19 15:22:46 2019 +0100
     2.2 +++ b/test/src/test_util.cc	Wed Nov 20 16:10:51 2019 +0100
     2.3 @@ -24,6 +24,15 @@
     2.4  
     2.5  std::string _main_test_home_dir;
     2.6  
     2.7 +bool is_pEpmsg(const message *msg)
     2.8 +{
     2.9 +    for (stringpair_list_t *i = msg->opt_fields; i && i->value ; i=i->next) {
    2.10 +        if (strcasecmp(i->value->key, "X-pEp-Version") == 0)
    2.11 +            return true;
    2.12 +    }
    2.13 +    return false;
    2.14 +}
    2.15 +
    2.16  // Lazy:
    2.17  // https://stackoverflow.com/questions/440133/how-do-i-create-a-random-alpha-numeric-string-in-c
    2.18  std::string random_string( size_t length )
    2.19 @@ -57,15 +66,6 @@
    2.20      return _main_test_home_dir;
    2.21  }
    2.22  
    2.23 -bool is_pEpmsg(const message *msg)
    2.24 -{
    2.25 -    for (stringpair_list_t *i = msg->opt_fields; i && i->value ; i=i->next) {
    2.26 -        if (strcasecmp(i->value->key, "X-pEp-Version") == 0)
    2.27 -            return true;
    2.28 -    }
    2.29 -    return false;
    2.30 -}
    2.31 -
    2.32  PEP_STATUS read_file_and_import_key(PEP_SESSION session, const char* fname) {
    2.33      const std::string key = slurp(fname);
    2.34      PEP_STATUS status = (key.empty() ? PEP_KEY_NOT_FOUND : PEP_STATUS_OK);
    2.35 @@ -617,7 +617,7 @@
    2.36      return status;
    2.37  }
    2.38  
    2.39 -DYNAMIC_API PEP_STATUS MIME_encrypt_message(
    2.40 +PEP_STATUS MIME_encrypt_message(
    2.41      PEP_SESSION session,
    2.42      const char *mimetext,
    2.43      size_t size,
    2.44 @@ -628,8 +628,10 @@
    2.45  )
    2.46  {
    2.47      PEP_STATUS status = PEP_STATUS_OK;
    2.48 +    PEP_STATUS tmp_status = PEP_STATUS_OK;
    2.49      message* tmp_msg = NULL;
    2.50      message* enc_msg = NULL;
    2.51 +    message* ret_msg = NULL;                             
    2.52  
    2.53      status = mime_decode_message(mimetext, size, &tmp_msg);
    2.54      if (status != PEP_STATUS_OK)
    2.55 @@ -640,14 +642,14 @@
    2.56          char* own_id = NULL;
    2.57          status = get_default_own_userid(session, &own_id);
    2.58          free(tmp_msg->from->user_id);
    2.59 -        
    2.60 +    
    2.61          if (status != PEP_STATUS_OK || !own_id) {
    2.62              tmp_msg->from->user_id = strdup(PEP_OWN_USERID);
    2.63          }
    2.64          else {
    2.65              tmp_msg->from->user_id = own_id; // ownership transfer
    2.66          }
    2.67 -            
    2.68 +    
    2.69          status = myself(session, tmp_msg->from);
    2.70          if (status != PEP_STATUS_OK)
    2.71              goto pEp_error;
    2.72 @@ -676,8 +678,7 @@
    2.73                               &enc_msg,
    2.74                               enc_format,
    2.75                               flags);
    2.76 -                             
    2.77 -    message* ret_msg = NULL;                         
    2.78 +    
    2.79      if (status == PEP_STATUS_OK || status == PEP_UNENCRYPTED)
    2.80          ret_msg = (status == PEP_STATUS_OK ? enc_msg : tmp_msg);
    2.81      else                                
    2.82 @@ -688,12 +689,15 @@
    2.83          goto pEp_error;
    2.84      }
    2.85      
    2.86 -    PEP_STATUS tmp_status = _mime_encode_message_internal(
    2.87 -                                    ret_msg, 
    2.88 -                                    false, 
    2.89 -                                    mime_ciphertext, 
    2.90 -                                    false, 
    2.91 -                                    false);
    2.92 +    tmp_status = _mime_encode_message_internal(
    2.93 +                    ret_msg, 
    2.94 +                    false, 
    2.95 +                    mime_ciphertext, 
    2.96 +                    false, 
    2.97 +                    false);
    2.98 +    
    2.99 +    if (tmp_status != PEP_STATUS_OK)
   2.100 +        status = tmp_status;
   2.101  
   2.102  pEp_error:
   2.103      free_message(tmp_msg);