Changeset 14476


Ignore:
Timestamp:
Mar 15, 2015, 11:43:32 AM (6 years ago)
Author:
mikedld
Message:

Minor type adjustments (incomplete, it takes way too much time)

Location:
trunk/libtransmission
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer-udp.c

    r14354 r14476  
    124124
    125125static bool
    126 is_tau_response_message (int action, int msglen)
     126is_tau_response_message (tau_action_t action, size_t msglen)
    127127{
    128128    if (action == TAU_ACTION_CONNECT) return msglen == 16;
  • trunk/libtransmission/cache.c

    r14241 r14476  
    7373  bool is_multi_piece;
    7474  bool is_piece_done;
    75   unsigned len;
     75  unsigned int len;
    7676};
    7777
  • trunk/libtransmission/clients.c

    r14286 r14476  
    2727}
    2828
    29 static int
     29static bool
    3030getShadowInt (uint8_t ch, int * setme)
    3131{
     
    3333    const char * pch = strchr (str, ch);
    3434    if (!pch)
    35         return 0;
     35        return false;
    3636    *setme = pch - str;
    37     return 1;
     37    return true;
    3838}
    3939
     
    9898}
    9999
    100 static int
     100static bool
    101101isMainlineStyle (const uint8_t * peer_id)
    102102{
     
    111111}
    112112
    113 static int
     113static bool
    114114decodeBitCometClient (char * buf, size_t buflen, const uint8_t * id)
    115115{
  • trunk/libtransmission/crypto.c

    r14360 r14476  
    121121tr_cryptoDecryptInit (tr_crypto * crypto)
    122122{
    123   unsigned char discard[1024];
     123  uint8_t discard[1024];
    124124  const char * txt = crypto->isIncoming ? "keyA" : "keyB";
    125125
     
    148148tr_cryptoEncryptInit (tr_crypto * crypto)
    149149{
    150   unsigned char discard[1024];
     150  uint8_t discard[1024];
    151151  const char * txt = crypto->isIncoming ? "keyB" : "keyA";
    152152
  • trunk/libtransmission/handshake.c

    r14358 r14476  
    6363
    6464#ifdef ENABLE_LTEP
    65  #define HANDSHAKE_HAS_LTEP(bits)(((bits)[5] & 0x10) ? 1 : 0)
     65 #define HANDSHAKE_HAS_LTEP(bits)(((bits)[5] & 0x10) != 0)
    6666 #define HANDSHAKE_SET_LTEP(bits)((bits)[5] |= 0x10)
    6767#else
    68  #define HANDSHAKE_HAS_LTEP(bits)(0)
     68 #define HANDSHAKE_HAS_LTEP(bits)(false)
    6969 #define HANDSHAKE_SET_LTEP(bits)((void)0)
    7070#endif
    7171
    7272#ifdef ENABLE_FAST
    73  #define HANDSHAKE_HAS_FASTEXT(bits)(((bits)[7] & 0x04) ? 1 : 0)
     73 #define HANDSHAKE_HAS_FASTEXT(bits)(((bits)[7] & 0x04) != 0)
    7474 #define HANDSHAKE_SET_FASTEXT(bits)((bits)[7] |= 0x04)
    7575#else
    76  #define HANDSHAKE_HAS_FASTEXT(bits)(0)
     76 #define HANDSHAKE_HAS_FASTEXT(bits)(false)
    7777 #define HANDSHAKE_SET_FASTEXT(bits)((void)0)
    7878#endif
    7979
    8080#ifdef ENABLE_DHT
    81  #define HANDSHAKE_HAS_DHT(bits)(((bits)[7] & 0x01) ? 1 : 0)
     81 #define HANDSHAKE_HAS_DHT(bits)(((bits)[7] & 0x01) != 0)
    8282 #define HANDSHAKE_SET_DHT(bits)((bits)[7] |= 0x01)
    8383#else
    84  #define HANDSHAKE_HAS_DHT(bits)(0)
     84 #define HANDSHAKE_HAS_DHT(bits)(false)
    8585 #define HANDSHAKE_SET_DHT(bits)((void)0)
    8686#endif
     
    9292#define HANDSHAKE_SET_EXTPREF(reserved, val)((reserved)[5] |= 0x03 & (val))
    9393
    94 typedef uint8_t handshake_state_t;
     94/**
     95***
     96**/
     97
     98typedef enum
     99{
     100  /* incoming */
     101  AWAITING_HANDSHAKE,
     102  AWAITING_PEER_ID,
     103  AWAITING_YA,
     104  AWAITING_PAD_A,
     105  AWAITING_CRYPTO_PROVIDE,
     106  AWAITING_PAD_C,
     107  AWAITING_IA,
     108  AWAITING_PAYLOAD_STREAM,
     109
     110  /* outgoing */
     111  AWAITING_YB,
     112  AWAITING_VC,
     113  AWAITING_CRYPTO_SELECT,
     114  AWAITING_PAD_D,
     115
     116  N_STATES
     117}
     118handshake_state_t;
    95119
    96120struct tr_handshake
     
    119143**/
    120144
    121 enum
    122 {
    123   /* incoming */
    124   AWAITING_HANDSHAKE,
    125   AWAITING_PEER_ID,
    126   AWAITING_YA,
    127   AWAITING_PAD_A,
    128   AWAITING_CRYPTO_PROVIDE,
    129   AWAITING_PAD_C,
    130   AWAITING_IA,
    131   AWAITING_PAYLOAD_STREAM,
    132 
    133   /* outgoing */
    134   AWAITING_YB,
    135   AWAITING_VC,
    136   AWAITING_CRYPTO_SELECT,
    137   AWAITING_PAD_D,
    138 
    139   N_STATES
    140 };
    141 
    142 /**
    143 ***
    144 **/
    145 
    146145#define dbgmsg(handshake, ...) \
    147146  do { \
     
    230229}
    231230
    232 static int tr_handshakeDone (tr_handshake * handshake,
    233                              bool           isConnected);
    234 
    235 enum
     231static ReadState tr_handshakeDone (tr_handshake * handshake,
     232                                   bool           isConnected);
     233
     234typedef enum
    236235{
    237236  HANDSHAKE_OK,
     
    239238  HANDSHAKE_BAD_TORRENT,
    240239  HANDSHAKE_PEER_IS_SELF,
    241 };
    242 
    243 static int
     240}
     241handshake_parse_err_t;
     242
     243static handshake_parse_err_t
    244244parseHandshake (tr_handshake *    handshake,
    245245                struct evbuffer * inbuf)
     
    255255
    256256  if (evbuffer_get_length (inbuf) < HANDSHAKE_SIZE)
    257     return READ_LATER;
     257    return HANDSHAKE_ENCRYPTION_WRONG;
    258258
    259259  /* confirm the protocol */
     
    393393}
    394394
    395 static int
     395static ReadState
    396396readYb (tr_handshake * handshake, struct evbuffer * inbuf)
    397397{
    398   int isEncrypted;
     398  bool isEncrypted;
    399399  uint8_t yb[KEY_LEN];
    400400  struct evbuffer * outbuf;
     
    404404    return READ_LATER;
    405405
    406   isEncrypted = memcmp (evbuffer_pullup (inbuf, HANDSHAKE_NAME_LEN), HANDSHAKE_NAME, HANDSHAKE_NAME_LEN);
     406  isEncrypted = memcmp (evbuffer_pullup (inbuf, HANDSHAKE_NAME_LEN), HANDSHAKE_NAME, HANDSHAKE_NAME_LEN) != 0;
    407407  if (isEncrypted)
    408408    {
     
    493493}
    494494
    495 static int
     495static ReadState
    496496readVC (tr_handshake    * handshake,
    497497        struct evbuffer * inbuf)
     
    527527}
    528528
    529 static int
     529static ReadState
    530530readCryptoSelect (tr_handshake    * handshake,
    531531                  struct evbuffer * inbuf)
     
    562562}
    563563
    564 static int
     564static ReadState
    565565readPadD (tr_handshake    * handshake,
    566566          struct evbuffer * inbuf)
     
    587587***/
    588588
    589 static int
     589static ReadState
    590590readHandshake (tr_handshake    * handshake,
    591591               struct evbuffer * inbuf)
     
    700700}
    701701
    702 static int
     702static ReadState
    703703readPeerId (tr_handshake    * handshake,
    704704            struct evbuffer * inbuf)
     
    727727}
    728728
    729 static int
     729static ReadState
    730730readYa (tr_handshake    * handshake,
    731731        struct evbuffer * inbuf)
     
    761761}
    762762
    763 static int
     763static ReadState
    764764readPadA (tr_handshake * handshake, struct evbuffer * inbuf)
    765765{
     
    783783}
    784784
    785 static int
     785static ReadState
    786786readCryptoProvide (tr_handshake    * handshake,
    787787                   struct evbuffer * inbuf)
     
    853853}
    854854
    855 static int
     855static ReadState
    856856readPadC (tr_handshake    * handshake,
    857857          struct evbuffer * inbuf)
     
    877877}
    878878
    879 static int
     879static ReadState
    880880readIA (tr_handshake    * handshake,
    881881        struct evbuffer * inbuf)
     
    955955}
    956956
    957 static int
     957static ReadState
    958958readPayloadStream (tr_handshake    * handshake,
    959959                   struct evbuffer * inbuf)
    960960{
    961   int i;
     961  handshake_parse_err_t i;
    962962  const size_t needlen = HANDSHAKE_SIZE;
    963963
     
    10941094}
    10951095
    1096 static int
     1096static ReadState
    10971097tr_handshakeDone (tr_handshake * handshake, bool isOK)
    10981098{
  • trunk/libtransmission/inout.c

    r14355 r14476  
    293293  while (bytesLeft)
    294294    {
    295       const int len = MIN (bytesLeft, buflen);
     295      const size_t len = MIN (bytesLeft, buflen);
    296296      success = !tr_cacheReadBlock (tor->session->cache, tor, pieceIndex, offset, len, buffer);
    297297      if (!success)
  • trunk/libtransmission/log.c

    r14450 r14476  
    140140
    141141char*
    142 tr_logGetTimeStr (char * buf, int buflen)
     142tr_logGetTimeStr (char * buf, size_t buflen)
    143143{
    144144  char tmp[64];
  • trunk/libtransmission/log.h

    r14369 r14476  
    122122
    123123/** @brief set the buffer with the current time formatted for deep logging. */
    124 char* tr_logGetTimeStr (char * buf, int buflen) TR_GNUC_NONNULL (1);
     124char* tr_logGetTimeStr (char * buf, size_t buflen) TR_GNUC_NONNULL (1);
    125125
    126126#ifdef __cplusplus
  • trunk/libtransmission/peer-io.c

    r14382 r14476  
    11781178
    11791179        default:
    1180             assert (0);
     1180            assert (false);
    11811181    }
    11821182}
Note: See TracChangeset for help on using the changeset viewer.