IOSAD-172 Less casting IOSAD-172
authorDirk Zimmermann <dz@pep.security>
Sat, 27 Jun 2020 14:26:44 +0200
branchIOSAD-172
changeset 1507b0474a0ced9d
parent 1506 264e11853a2b
child 1508 b9213edd31c4
IOSAD-172 Less casting
pEpObjCAdapter/PEPInternalSession+PassphraseCache.h
pEpObjCAdapter/PEPInternalSession+PassphraseCache.m
pEpObjCAdapter/PEPInternalSession.m
     1.1 --- a/pEpObjCAdapter/PEPInternalSession+PassphraseCache.h	Sat Jun 27 14:02:48 2020 +0200
     1.2 +++ b/pEpObjCAdapter/PEPInternalSession+PassphraseCache.h	Sat Jun 27 14:26:44 2020 +0200
     1.3 @@ -21,7 +21,7 @@
     1.4  /// until it returns something else other than PEP_PASSPHRASE_REQUIRED
     1.5  /// or PEP_WRONG_PASSPHRASE, or there are no passwords anymore.
     1.6  /// @param block The status-returning block to execute against different passwords
     1.7 -- (PEP_STATUS)runWithPasswords:(PEP_STATUS (^)(PEP_SESSION session))block;
     1.8 +- (PEPStatus)runWithPasswords:(PEP_STATUS (^)(PEP_SESSION session))block;
     1.9  
    1.10  @end
    1.11  
     2.1 --- a/pEpObjCAdapter/PEPInternalSession+PassphraseCache.m	Sat Jun 27 14:02:48 2020 +0200
     2.2 +++ b/pEpObjCAdapter/PEPInternalSession+PassphraseCache.m	Sat Jun 27 14:26:44 2020 +0200
     2.3 @@ -14,7 +14,7 @@
     2.4  
     2.5  @implementation PEPInternalSession (PassphraseCache)
     2.6  
     2.7 -- (PEP_STATUS)runWithPasswords:(PEP_STATUS (^)(PEP_SESSION session))block
     2.8 +- (PEPStatus)runWithPasswords:(PEP_STATUS (^)(PEP_SESSION session))block
     2.9  {
    2.10      PEP_STATUS lastStatus = PEP_UNKNOWN_ERROR;
    2.11  
    2.12 @@ -23,19 +23,19 @@
    2.13          PEP_STATUS status = config_passphrase(self.session, [passphrase UTF8String]);
    2.14  
    2.15          if (status != PEPStatusOK) {
    2.16 -            return status;
    2.17 +            return (PEPStatus) status;
    2.18          }
    2.19  
    2.20          lastStatus = block(self.session);
    2.21  
    2.22          if (lastStatus != PEP_PASSPHRASE_REQUIRED && lastStatus != PEP_WRONG_PASSPHRASE) {
    2.23 -            return lastStatus;
    2.24 +            return (PEPStatus) lastStatus;
    2.25          }
    2.26      }
    2.27  
    2.28      // If execution lands here, it means we ran out of passwords to set while
    2.29      // receiving password-related error codes.
    2.30 -    return lastStatus;
    2.31 +    return (PEPStatus) lastStatus;
    2.32  }
    2.33  
    2.34  @end
     3.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Sat Jun 27 14:02:48 2020 +0200
     3.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Sat Jun 27 14:26:44 2020 +0200
     3.3 @@ -113,7 +113,7 @@
     3.4  
     3.5      __block PEPRating internalRating = PEPRatingUndefined;
     3.6  
     3.7 -    PEPStatus theStatus = (PEPStatus) [self runWithPasswords:^PEP_STATUS(PEP_SESSION session) {
     3.8 +    PEPStatus theStatus = [self runWithPasswords:^PEP_STATUS(PEP_SESSION session) {
     3.9          return decrypt_message(session,
    3.10                                 _src,
    3.11                                 &_dst,
    3.12 @@ -198,7 +198,7 @@
    3.13          theKeys = PEP_arrayToStringlist(xKeyList);
    3.14      }
    3.15  
    3.16 -    PEPStatus theStatus = (PEPStatus) [self runWithPasswords:^PEP_STATUS(PEP_SESSION session) {
    3.17 +    PEPStatus theStatus = [self runWithPasswords:^PEP_STATUS(PEP_SESSION session) {
    3.18          return re_evaluate_message_rating(session,
    3.19                                            _src,
    3.20                                            theKeys,
    3.21 @@ -259,18 +259,20 @@
    3.22                                     status:(PEPStatus * _Nullable)status
    3.23                                      error:(NSError * _Nullable * _Nullable)error
    3.24  {
    3.25 -    PEP_encrypt_flags_t flags = 0;
    3.26 +    __block PEP_encrypt_flags_t flags = 0;
    3.27  
    3.28 -    message *_src = PEP_messageDictToStruct([self removeEmptyRecipients:messageDict]);
    3.29 -    message *_dst = NULL;
    3.30 -    stringlist_t *_keys = PEP_arrayToStringlist(extraKeys);
    3.31 +    __block message *_src = PEP_messageDictToStruct([self removeEmptyRecipients:messageDict]);
    3.32 +    __block message *_dst = NULL;
    3.33 +    __block stringlist_t *_keys = PEP_arrayToStringlist(extraKeys);
    3.34  
    3.35 -    PEPStatus theStatus = (PEPStatus) encrypt_message(_session,
    3.36 -                                                      _src,
    3.37 -                                                      _keys,
    3.38 -                                                      &_dst,
    3.39 -                                                      (PEP_enc_format) encFormat,
    3.40 -                                                      flags);
    3.41 +    PEPStatus theStatus = [self runWithPasswords:^PEP_STATUS(PEP_SESSION session) {
    3.42 +        return encrypt_message(session,
    3.43 +                               _src,
    3.44 +                               _keys,
    3.45 +                               &_dst,
    3.46 +                               (PEP_enc_format) encFormat,
    3.47 +                               flags);
    3.48 +    }];
    3.49  
    3.50      if (status) {
    3.51          *status = theStatus;