add more ERROR() and GOTO() to find out why the call failed. it is in keymanagement.c :-D ENGINE-199
authorRoker <roker@pep-project.org>
Fri, 21 Apr 2017 21:38:20 +0200
branchENGINE-199
changeset 17346d5ea8793614
parent 1730 f8f1a806a051
child 1735 486bfe88057f
add more ERROR() and GOTO() to find out why the call failed. it is in keymanagement.c :-D
src/keymanagement.c
src/message_api.c
src/pEpEngine.c
     1.1 --- a/src/keymanagement.c	Thu Apr 20 15:46:16 2017 +0200
     1.2 +++ b/src/keymanagement.c	Fri Apr 21 21:38:20 2017 +0200
     1.3 @@ -91,7 +91,7 @@
     1.4      assert(!EMPTYSTR(identity->address));
     1.5  
     1.6      if (!(session && identity && !EMPTYSTR(identity->address)))
     1.7 -        return PEP_ILLEGAL_VALUE;
     1.8 +        return ERROR(PEP_ILLEGAL_VALUE);
     1.9  
    1.10      if (identity->me || (identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0)) {
    1.11          identity->me = true;
    1.12 @@ -311,7 +311,7 @@
    1.13      free_identity(stored_identity);
    1.14      free_identity(temp_id);
    1.15      
    1.16 -    return status;
    1.17 +    return ERROR(status);
    1.18  }
    1.19  
    1.20  PEP_STATUS elect_ownkey(
    1.21 @@ -406,7 +406,7 @@
    1.22      
    1.23      *is_usable = !dont_use_fpr;
    1.24      
    1.25 -    return status;
    1.26 +    return ERROR(status);
    1.27  }
    1.28  
    1.29  PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen, bool ignore_flags)
    1.30 @@ -424,7 +424,7 @@
    1.31      if (!(session && identity && !EMPTYSTR(identity->address) &&
    1.32              (EMPTYSTR(identity->user_id) ||
    1.33              strcmp(identity->user_id, PEP_OWN_USERID) == 0)))
    1.34 -        return PEP_ILLEGAL_VALUE;
    1.35 +        return ERROR(PEP_ILLEGAL_VALUE);
    1.36  
    1.37      identity->comm_type = PEP_ct_pEp;
    1.38      identity->me = true;
    1.39 @@ -512,7 +512,7 @@
    1.40          status = elect_ownkey(session, identity);
    1.41          assert(status == PEP_STATUS_OK);
    1.42          if (status != PEP_STATUS_OK) {
    1.43 -            return status;
    1.44 +            return ERROR(status);
    1.45          }
    1.46  
    1.47          bool has_private = false;
    1.48 @@ -548,21 +548,21 @@
    1.49              status = elect_ownkey(session, identity);
    1.50              assert(status == PEP_STATUS_OK);
    1.51              if (status != PEP_STATUS_OK) {
    1.52 -                return status;
    1.53 +                return ERROR(status);
    1.54              }
    1.55          } 
    1.56          else if (status != PEP_STATUS_OK) 
    1.57          {
    1.58 -            return status;
    1.59 +            return ERROR(status);
    1.60          }
    1.61      }
    1.62     
    1.63      bool new_key_generated = false;
    1.64  
    1.65      if (EMPTYSTR(identity->fpr) || revoked)
    1.66 -    {        
    1.67 +    {
    1.68          if(!do_keygen){
    1.69 -            return PEP_GET_KEY_FAILED;
    1.70 +            return ERROR(PEP_GET_KEY_FAILED);
    1.71          }
    1.72  
    1.73          if(revoked)
    1.74 @@ -580,7 +580,7 @@
    1.75              DEBUG_LOG("generating key pair failed", "debug", buf);
    1.76              if(revoked && r_fpr)
    1.77                  free(r_fpr);
    1.78 -            return status;
    1.79 +            return ERROR(status);
    1.80          }
    1.81  
    1.82          new_key_generated = true;
    1.83 @@ -591,7 +591,7 @@
    1.84                                   identity->fpr, time(NULL));
    1.85              free(r_fpr);
    1.86              if (status != PEP_STATUS_OK) {
    1.87 -                return status;
    1.88 +                return ERROR(status);
    1.89              }
    1.90          }
    1.91      }
    1.92 @@ -604,7 +604,7 @@
    1.93  
    1.94          assert(status == PEP_STATUS_OK);
    1.95          if (status != PEP_STATUS_OK) {
    1.96 -            return status;
    1.97 +            return ERROR(status);
    1.98          }
    1.99  
   1.100          if (status == PEP_STATUS_OK && expired) {
   1.101 @@ -632,12 +632,12 @@
   1.102          }
   1.103      }
   1.104  
   1.105 -    return PEP_STATUS_OK;
   1.106 +    return ERROR(PEP_STATUS_OK);
   1.107  }
   1.108  
   1.109  DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
   1.110  {
   1.111 -    return _myself(session, identity, true, false);
   1.112 +    return ERROR(_myself(session, identity, true, false));
   1.113  }
   1.114  
   1.115  DYNAMIC_API PEP_STATUS register_examine_function(
     2.1 --- a/src/message_api.c	Thu Apr 20 15:46:16 2017 +0200
     2.2 +++ b/src/message_api.c	Fri Apr 21 21:38:20 2017 +0200
     2.3 @@ -1100,20 +1100,20 @@
     2.4      assert(enc_format != PEP_enc_none);
     2.5  
     2.6      if (!(session && src && dst && enc_format != PEP_enc_none))
     2.7 -        return PEP_ILLEGAL_VALUE;
     2.8 +        return ERROR(PEP_ILLEGAL_VALUE);
     2.9  
    2.10      if (src->dir == PEP_dir_incoming)
    2.11 -        return PEP_ILLEGAL_VALUE;
    2.12 +        return ERROR(PEP_ILLEGAL_VALUE);
    2.13  
    2.14      determine_encryption_format(src);
    2.15      if (src->enc_format != PEP_enc_none)
    2.16 -        return PEP_ILLEGAL_VALUE;
    2.17 +        return ERROR(PEP_ILLEGAL_VALUE);
    2.18  
    2.19      *dst = NULL;
    2.20  
    2.21      status = myself(session, src->from);
    2.22      if (status != PEP_STATUS_OK)
    2.23 -        goto pep_error;
    2.24 +        GOTO(pep_error);
    2.25  
    2.26      keys = new_stringlist(src->from->fpr);
    2.27      if (keys == NULL)
    2.28 @@ -1147,7 +1147,7 @@
    2.29          PEP_STATUS _status = update_identity(session, _il->ident);
    2.30          if (_status != PEP_STATUS_OK) {
    2.31              status = _status;
    2.32 -            goto pep_error;
    2.33 +            GOTO(pep_error);
    2.34          }
    2.35  
    2.36          if (_il->ident->fpr && _il->ident->fpr[0]) {
    2.37 @@ -1168,7 +1168,7 @@
    2.38              PEP_STATUS _status = update_identity(session, _il->ident);
    2.39              if (_status != PEP_STATUS_OK) {
    2.40                  status = _status;
    2.41 -                goto pep_error;
    2.42 +                GOTO(pep_error);
    2.43              }
    2.44  
    2.45              if (_il->ident->fpr && _il->ident->fpr[0]) {
    2.46 @@ -1189,7 +1189,7 @@
    2.47              if (_status != PEP_STATUS_OK)
    2.48              {
    2.49                  status = _status;
    2.50 -                goto pep_error;
    2.51 +                GOTO(pep_error);
    2.52              }
    2.53  
    2.54              if (_il->ident->fpr && _il->ident->fpr[0]) {
    2.55 @@ -1214,7 +1214,7 @@
    2.56          free_stringlist(keys);
    2.57          if (!session->passive_mode && !(flags & PEP_encrypt_flag_force_no_attached_key))
    2.58              attach_own_key(session, src);
    2.59 -        return PEP_UNENCRYPTED;
    2.60 +        return ERROR(PEP_UNENCRYPTED);
    2.61      }
    2.62      else {
    2.63          msg = clone_to_empty_message(src);
    2.64 @@ -1241,14 +1241,14 @@
    2.65          default:
    2.66              assert(0);
    2.67              status = PEP_ILLEGAL_VALUE;
    2.68 -            goto pep_error;
    2.69 +            GOTO(pep_error);
    2.70          }
    2.71  
    2.72          if (status == PEP_OUT_OF_MEMORY)
    2.73              goto enomem;
    2.74  
    2.75          if (status != PEP_STATUS_OK)
    2.76 -            goto pep_error;
    2.77 +            GOTO(pep_error);
    2.78      }
    2.79  
    2.80      free_stringlist(keys);
    2.81 @@ -1271,7 +1271,7 @@
    2.82      }
    2.83  
    2.84      *dst = msg;
    2.85 -    return status;
    2.86 +    return ERROR(status);
    2.87  
    2.88  enomem:
    2.89      status = PEP_OUT_OF_MEMORY;
    2.90 @@ -1280,7 +1280,7 @@
    2.91      free_stringlist(keys);
    2.92      free_message(msg);
    2.93  
    2.94 -    return status;
    2.95 +    return ERROR(status);
    2.96  }
    2.97  
    2.98  DYNAMIC_API PEP_STATUS encrypt_message_for_self(
    2.99 @@ -1302,18 +1302,18 @@
   2.100      assert(enc_format != PEP_enc_none);
   2.101  
   2.102      if (!(session && src && dst && enc_format != PEP_enc_none))
   2.103 -        return PEP_ILLEGAL_VALUE;
   2.104 +        return ERROR(PEP_ILLEGAL_VALUE);
   2.105  
   2.106      if (src->dir == PEP_dir_incoming)
   2.107 -        return PEP_ILLEGAL_VALUE;
   2.108 +        return ERROR(PEP_ILLEGAL_VALUE);
   2.109  
   2.110      determine_encryption_format(src);
   2.111      if (src->enc_format != PEP_enc_none)
   2.112 -        return PEP_ILLEGAL_VALUE;
   2.113 +        return ERROR(PEP_ILLEGAL_VALUE);
   2.114  
   2.115      status = myself(session, target_id);
   2.116      if (status != PEP_STATUS_OK)
   2.117 -        goto pep_error;
   2.118 +        GOTO(pep_error);
   2.119  
   2.120      *dst = NULL;
   2.121  
   2.122 @@ -1390,7 +1390,7 @@
   2.123      free_stringlist(keys);
   2.124      free_message(msg);
   2.125  
   2.126 -    return status;
   2.127 +    return ERROR(status);
   2.128  }
   2.129  
   2.130  static bool is_a_pEpmessage(const message *msg)
   2.131 @@ -2608,7 +2608,7 @@
   2.132  
   2.133      status = mime_decode_message(mimetext, size, &tmp_msg);
   2.134      if (status != PEP_STATUS_OK)
   2.135 -        goto pep_error;
   2.136 +        GOTO(pep_error);
   2.137  
   2.138      // This isn't incoming, though... so we need to reverse the direction
   2.139      tmp_msg->dir = PEP_dir_outgoing;
   2.140 @@ -2619,7 +2619,7 @@
   2.141                               enc_format,
   2.142                               flags);
   2.143      if (status != PEP_STATUS_OK)
   2.144 -        goto pep_error;
   2.145 +        GOTO(pep_error);
   2.146  
   2.147      status = mime_encode_message(enc_msg, false, mime_ciphertext);
   2.148  
     3.1 --- a/src/pEpEngine.c	Thu Apr 20 15:46:16 2017 +0200
     3.2 +++ b/src/pEpEngine.c	Fri Apr 21 21:38:20 2017 +0200
     3.3 @@ -2286,9 +2286,9 @@
     3.4      char logline[48];
     3.5      if(status>0)
     3.6      {
     3.7 -        snprintf(logline,47, "%24s:%u status=%u (0x%x)", file, line, status, status);
     3.8 +        snprintf(logline,47, "%.24s:%u status=%u (0x%x)", file, line, status, status);
     3.9      }else{
    3.10 -        snprintf(logline,47, "%24s:%u status=%i.", file, line, status);
    3.11 +        snprintf(logline,47, "%.24s:%u status=%i.", file, line, status);
    3.12      }
    3.13      stringlist_add(session->errorstack, logline); // logline is copied! :-)
    3.14      return status;