rename macro ERROR(x) into ADD_TO_LOG(x) to avoid problems on MSVC
authorRoker <roker@pep-project.org>
Tue, 13 Jun 2017 21:15:16 +0200
changeset 1853a86d6290d493
parent 1852 8b786dad8b60
child 1854 b76315c0117d
rename macro ERROR(x) into ADD_TO_LOG(x) to avoid problems on MSVC
src/keymanagement.c
src/message_api.c
src/pEpEngine.c
src/pEp_internal.h
     1.1 --- a/src/keymanagement.c	Mon Jun 12 22:37:40 2017 +0200
     1.2 +++ b/src/keymanagement.c	Tue Jun 13 21:15:16 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 ERROR(PEP_ILLEGAL_VALUE);
     1.8 +        return ADD_TO_LOG(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 @@ -326,7 +326,7 @@
    1.13      free_identity(stored_identity);
    1.14      free_identity(temp_id);
    1.15      
    1.16 -    return ERROR(status);
    1.17 +    return ADD_TO_LOG(status);
    1.18  }
    1.19  
    1.20  PEP_STATUS elect_ownkey(
    1.21 @@ -416,7 +416,7 @@
    1.22      
    1.23      *is_usable = !dont_use_fpr;
    1.24      
    1.25 -    return ERROR(status);
    1.26 +    return ADD_TO_LOG(status);
    1.27  }
    1.28  
    1.29  PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen, bool ignore_flags)
    1.30 @@ -434,7 +434,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 ERROR(PEP_ILLEGAL_VALUE);
    1.35 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.36  
    1.37      identity->comm_type = PEP_ct_pEp;
    1.38      identity->me = true;
    1.39 @@ -522,7 +522,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 ERROR(status);
    1.44 +            return ADD_TO_LOG(status);
    1.45          }
    1.46  
    1.47          bool has_private = false;
    1.48 @@ -554,7 +554,7 @@
    1.49  
    1.50          if (status != PEP_STATUS_OK) 
    1.51          {
    1.52 -            return ERROR(status);
    1.53 +            return ADD_TO_LOG(status);
    1.54          }
    1.55      }
    1.56     
    1.57 @@ -563,7 +563,7 @@
    1.58      if (EMPTYSTR(identity->fpr) || revoked)
    1.59      {
    1.60          if(!do_keygen){
    1.61 -            return ERROR(PEP_GET_KEY_FAILED);
    1.62 +            return ADD_TO_LOG(PEP_GET_KEY_FAILED);
    1.63          }
    1.64  
    1.65          if(revoked)
    1.66 @@ -581,7 +581,7 @@
    1.67              DEBUG_LOG("generating key pair failed", "debug", buf);
    1.68              if(revoked && r_fpr)
    1.69                  free(r_fpr);
    1.70 -            return ERROR(status);
    1.71 +            return ADD_TO_LOG(status);
    1.72          }
    1.73  
    1.74          new_key_generated = true;
    1.75 @@ -592,7 +592,7 @@
    1.76                                   identity->fpr, time(NULL));
    1.77              free(r_fpr);
    1.78              if (status != PEP_STATUS_OK) {
    1.79 -                return ERROR(status);
    1.80 +                return ADD_TO_LOG(status);
    1.81              }
    1.82          }
    1.83      }
    1.84 @@ -605,7 +605,7 @@
    1.85  
    1.86          assert(status == PEP_STATUS_OK);
    1.87          if (status != PEP_STATUS_OK) {
    1.88 -            return ERROR(status);
    1.89 +            return ADD_TO_LOG(status);
    1.90          }
    1.91  
    1.92          if (status == PEP_STATUS_OK && expired) {
    1.93 @@ -633,12 +633,12 @@
    1.94          }
    1.95      }
    1.96  
    1.97 -    return ERROR(PEP_STATUS_OK);
    1.98 +    return ADD_TO_LOG(PEP_STATUS_OK);
    1.99  }
   1.100  
   1.101  DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
   1.102  {
   1.103 -    return ERROR(_myself(session, identity, true, false));
   1.104 +    return ADD_TO_LOG(_myself(session, identity, true, false));
   1.105  }
   1.106  
   1.107  DYNAMIC_API PEP_STATUS register_examine_function(
     2.1 --- a/src/message_api.c	Mon Jun 12 22:37:40 2017 +0200
     2.2 +++ b/src/message_api.c	Tue Jun 13 21:15:16 2017 +0200
     2.3 @@ -1104,14 +1104,14 @@
     2.4      assert(enc_format != PEP_enc_none);
     2.5  
     2.6      if (!(session && src && dst && enc_format != PEP_enc_none))
     2.7 -        return ERROR(PEP_ILLEGAL_VALUE);
     2.8 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
     2.9  
    2.10      if (src->dir == PEP_dir_incoming)
    2.11 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.12 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.13  
    2.14      determine_encryption_format(src);
    2.15      if (src->enc_format != PEP_enc_none)
    2.16 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.17 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.18  
    2.19      *dst = NULL;
    2.20  
    2.21 @@ -1218,7 +1218,7 @@
    2.22          free_stringlist(keys);
    2.23          if (!session->passive_mode && !(flags & PEP_encrypt_flag_force_no_attached_key))
    2.24              attach_own_key(session, src);
    2.25 -        return ERROR(PEP_UNENCRYPTED);
    2.26 +        return ADD_TO_LOG(PEP_UNENCRYPTED);
    2.27      }
    2.28      else {
    2.29          msg = clone_to_empty_message(src);
    2.30 @@ -1275,7 +1275,7 @@
    2.31      }
    2.32  
    2.33      *dst = msg;
    2.34 -    return ERROR(status);
    2.35 +    return ADD_TO_LOG(status);
    2.36  
    2.37  enomem:
    2.38      status = PEP_OUT_OF_MEMORY;
    2.39 @@ -1284,7 +1284,7 @@
    2.40      free_stringlist(keys);
    2.41      free_message(msg);
    2.42  
    2.43 -    return ERROR(status);
    2.44 +    return ADD_TO_LOG(status);
    2.45  }
    2.46  
    2.47  DYNAMIC_API PEP_STATUS encrypt_message_for_self(
    2.48 @@ -1306,14 +1306,14 @@
    2.49      assert(enc_format != PEP_enc_none);
    2.50  
    2.51      if (!(session && src && dst && enc_format != PEP_enc_none))
    2.52 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.53 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.54  
    2.55      if (src->dir == PEP_dir_incoming)
    2.56 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.57 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.58  
    2.59      determine_encryption_format(src);
    2.60      if (src->enc_format != PEP_enc_none)
    2.61 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.62 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.63  
    2.64      status = myself(session, target_id);
    2.65      if (status != PEP_STATUS_OK)
    2.66 @@ -1394,7 +1394,7 @@
    2.67      free_stringlist(keys);
    2.68      free_message(msg);
    2.69  
    2.70 -    return ERROR(status);
    2.71 +    return ADD_TO_LOG(status);
    2.72  }
    2.73  
    2.74  static bool is_a_pEpmessage(const message *msg)
    2.75 @@ -1669,7 +1669,7 @@
    2.76      assert(flags);
    2.77  
    2.78      if (!(session && src && dst && keylist && rating && flags))
    2.79 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.80 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.81  
    2.82      *flags = 0;
    2.83  
    2.84 @@ -1680,7 +1680,7 @@
    2.85      // we would need to check signature
    2.86      status = _update_identity_for_incoming_message(session, src);
    2.87      if(status != PEP_STATUS_OK)
    2.88 -        return ERROR(status);
    2.89 +        return ADD_TO_LOG(status);
    2.90  
    2.91      // Get detached signature, if any
    2.92      bloblist_t* detached_sig = NULL;
    2.93 @@ -1714,7 +1714,7 @@
    2.94                                  PEP_decrypt_flag_consume;
    2.95                  }
    2.96                  else if (status != PEP_STATUS_OK) {
    2.97 -                    return ERROR(status);
    2.98 +                    return ADD_TO_LOG(status);
    2.99                  }
   2.100              }
   2.101              
   2.102 @@ -1746,7 +1746,7 @@
   2.103                  }
   2.104              }
   2.105              
   2.106 -            return ERROR(PEP_UNENCRYPTED);
   2.107 +            return ADD_TO_LOG(PEP_UNENCRYPTED);
   2.108  
   2.109          case PEP_enc_PGP_MIME:
   2.110              ctext = src->attachments->next->value;
   2.111 @@ -2117,7 +2117,7 @@
   2.112      free_message(msg);
   2.113      free_stringlist(_keylist);
   2.114  
   2.115 -    return ERROR(status);
   2.116 +    return ADD_TO_LOG(status);
   2.117  }
   2.118  
   2.119  DYNAMIC_API PEP_STATUS decrypt_message(
   2.120 @@ -2166,7 +2166,7 @@
   2.121  
   2.122      free_identity_list(private_il);
   2.123  
   2.124 -    return ERROR(status);
   2.125 +    return ADD_TO_LOG(status);
   2.126  }
   2.127  
   2.128  static void _max_comm_type_from_identity_list(
   2.129 @@ -2207,10 +2207,10 @@
   2.130      assert(rating);
   2.131  
   2.132      if (!(session && msg && rating))
   2.133 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.134 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.135  
   2.136      if (msg->dir != PEP_dir_outgoing)
   2.137 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.138 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.139  
   2.140      *rating = PEP_rating_undefined;
   2.141  
   2.142 @@ -2357,7 +2357,7 @@
   2.143                  goto error_release;
   2.144              break;
   2.145          default:
   2.146 -            return ERROR(PEP_UNKNOWN_ERROR); // shouldn't be possible
   2.147 +            return ADD_TO_LOG(PEP_UNKNOWN_ERROR); // shouldn't be possible
   2.148      }
   2.149  
   2.150      size_t _wsize = first_wsize + second_wsize;
   2.151 @@ -2399,7 +2399,7 @@
   2.152      the_end:
   2.153      free(first_set);
   2.154      free(second_set);
   2.155 -    return ERROR(status);
   2.156 +    return ADD_TO_LOG(status);
   2.157  }
   2.158  
   2.159  DYNAMIC_API PEP_STATUS get_message_trustwords(
   2.160 @@ -2485,7 +2485,7 @@
   2.161  
   2.162      if (status != PEP_STATUS_OK) {
   2.163          free_identity(partner);
   2.164 -        return ERROR(status);
   2.165 +        return ADD_TO_LOG(status);
   2.166      }
   2.167     
   2.168      // Find own identity corresponding to given account address.
   2.169 @@ -2498,7 +2498,7 @@
   2.170  
   2.171      if (status != PEP_STATUS_OK) {
   2.172          free_identity(stored_identity);
   2.173 -        return ERROR(status);
   2.174 +        return ADD_TO_LOG(status);
   2.175      }
   2.176  
   2.177      // get the trustwords
   2.178 @@ -2507,7 +2507,7 @@
   2.179                              partner, received_by, 
   2.180                              lang, words, &wsize, full);
   2.181  
   2.182 -    return ERROR(status);
   2.183 +    return ADD_TO_LOG(status);
   2.184  }
   2.185  
   2.186  DYNAMIC_API PEP_STATUS MIME_decrypt_message(
   2.187 @@ -2558,14 +2558,14 @@
   2.188      {
   2.189          free(tmp_msg);
   2.190          free(dec_msg);
   2.191 -        return ERROR(decrypt_status);
   2.192 +        return ADD_TO_LOG(decrypt_status);
   2.193      }
   2.194      
   2.195  pep_error:
   2.196      free_message(tmp_msg);
   2.197      free_message(dec_msg);
   2.198  
   2.199 -    return ERROR(status);
   2.200 +    return ADD_TO_LOG(status);
   2.201  }
   2.202  
   2.203  
   2.204 @@ -2610,7 +2610,7 @@
   2.205      free_message(tmp_msg);
   2.206      free_message(enc_msg);
   2.207  
   2.208 -    return ERROR(status);
   2.209 +    return ADD_TO_LOG(status);
   2.210  
   2.211  }
   2.212  
   2.213 @@ -2654,7 +2654,7 @@
   2.214      free_message(tmp_msg);
   2.215      free_message(enc_msg);
   2.216  
   2.217 -    return ERROR(status);
   2.218 +    return ADD_TO_LOG(status);
   2.219  }
   2.220  
   2.221  static PEP_rating string_to_rating(const char * rating)
   2.222 @@ -2747,7 +2747,7 @@
   2.223      assert(rating);
   2.224  
   2.225      if (!(session && msg && rating))
   2.226 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.227 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.228  
   2.229      *rating = PEP_rating_undefined;
   2.230  
   2.231 @@ -2758,7 +2758,7 @@
   2.232                  goto got_rating;
   2.233              }
   2.234          }
   2.235 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.236 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.237      }
   2.238  
   2.239  got_rating:
   2.240 @@ -2775,7 +2775,7 @@
   2.241                  goto got_keylist;
   2.242              }
   2.243          }
   2.244 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.245 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.246      }
   2.247  got_keylist:
   2.248  
   2.249 @@ -2794,5 +2794,5 @@
   2.250      if (must_free_keylist)
   2.251          free_stringlist(_keylist);
   2.252  
   2.253 -    return ERROR(status);
   2.254 +    return ADD_TO_LOG(status);
   2.255  }
     3.1 --- a/src/pEpEngine.c	Mon Jun 12 22:37:40 2017 +0200
     3.2 +++ b/src/pEpEngine.c	Tue Jun 13 21:15:16 2017 +0200
     3.3 @@ -886,7 +886,7 @@
     3.4      } while (result == SQLITE_BUSY);
     3.5      sqlite3_reset(session->log);
     3.6  
     3.7 -    return ERROR(status);
     3.8 +    return ADD_TO_LOG(status);
     3.9  }
    3.10  
    3.11  DYNAMIC_API PEP_STATUS log_service(
    3.12 @@ -1988,7 +1988,7 @@
    3.13      status = PEP_OUT_OF_MEMORY;
    3.14  
    3.15  the_end:
    3.16 -    return ERROR(status);
    3.17 +    return ADD_TO_LOG(status);
    3.18  }
    3.19  
    3.20  DYNAMIC_API PEP_STATUS get_languagelist(
     4.1 --- a/src/pEp_internal.h	Mon Jun 12 22:37:40 2017 +0200
     4.2 +++ b/src/pEp_internal.h	Tue Jun 13 21:15:16 2017 +0200
     4.3 @@ -316,9 +316,9 @@
     4.4  
     4.5  #ifdef DEBUG_ERRORSTACK
     4.6      PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status);
     4.7 -    #define ERROR(status)   session_add_error(session, __FILE__, __LINE__, (status))
     4.8 -    #define GOTO(label)     do{ (void)session_add_error(session, __FILE__, __LINE__, status); goto label; }while(0)
     4.9 +    #define ADD_TO_LOG(status)   session_add_error(session, __FILE__, __LINE__, (status))
    4.10 +    #define GOTO(label)          do{ (void)session_add_error(session, __FILE__, __LINE__, status); goto label; }while(0)
    4.11  #else
    4.12 -    #define ERROR(status)   (status)
    4.13 -    #define GOTO(label)     goto label
    4.14 +    #define ADD_TO_LOG(status)   (status)
    4.15 +    #define GOTO(label)          goto label
    4.16  #endif