Changeset 14721


Ignore:
Timestamp:
Mar 29, 2016, 3:04:54 AM (5 years ago)
Author:
jordan
Message:

fix a handful of minor compiler warnings, mostly in the unit tests, eg field width shortening or implicit signed/unsigned conversions

Location:
trunk/libtransmission
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/crypto-test.c

    r14429 r14721  
    2323  tr_crypto a;
    2424  uint8_t hash[SHA_DIGEST_LENGTH];
    25   int i;
     25  uint8_t i;
    2626
    2727  for (i = 0; i < SHA_DIGEST_LENGTH; ++i)
     
    7171
    7272  for (i = 0; i < SHA_DIGEST_LENGTH; ++i)
    73     hash[i] = i;
     73    hash[i] = (uint8_t)i;
    7474
    7575  tr_cryptoConstruct (&a, hash, false);
     
    216216  size_t len;
    217217  char * in, * out;
    218   int i;
     218  size_t i;
    219219
    220220  out = tr_base64_encode_str ("YOYO!", &len);
    221   check_int_eq (strlen (out), len);
     221  check_uint_eq (strlen (out), len);
    222222  check (base64_eq ("WU9ZTyE=", out));
    223223  in = tr_base64_decode_str (out, &len);
    224   check_int_eq (5, len);
     224  check_uint_eq (5, len);
    225225  check_streq ("YOYO!", in);
    226226  tr_free (in);
     
    228228
    229229  out = tr_base64_encode ("", 0, &len);
    230   check_int_eq (0, len);
     230  check_uint_eq (0, len);
    231231  check_streq ("", out);
    232232  tr_free (out);
    233233  out = tr_base64_decode ("", 0, &len);
    234   check_int_eq (0, len);
     234  check_uint_eq (0, len);
    235235  check_streq ("", out);
    236236  tr_free (out);
    237237
    238238  out = tr_base64_encode (NULL, 0, &len);
    239   check_int_eq (0, len);
     239  check_uint_eq (0, len);
    240240  check (out == NULL);
    241241  out = tr_base64_decode (NULL, 0, &len);
    242   check_int_eq (0, len);
     242  check_uint_eq (0, len);
    243243  check (out == NULL);
    244244
     
    247247  for (i = 1; i <= MAX_BUF_SIZE; ++i)
    248248    {
    249       int j;
     249      size_t j;
    250250      char buf[MAX_BUF_SIZE + 1];
    251251
    252252      for (j = 0; j < i; ++j)
    253         buf[j] = tr_rand_int_weak (256);
     253        buf[j] = (char) tr_rand_int_weak (256);
    254254
    255255      out = tr_base64_encode (buf, j, &len);
    256       check_int_eq (strlen (out), len);
     256      check_uint_eq (strlen (out), len);
    257257      in = tr_base64_decode (out, len, &len);
    258       check_int_eq (j, len);
     258      check_uint_eq (j, len);
    259259      check (memcmp (in, buf, len) == 0);
    260260      tr_free (in);
     
    262262
    263263      for (j = 0; j < i; ++j)
    264         buf[j] = 1 + tr_rand_int_weak (255);
     264        buf[j] = (char)(1 + tr_rand_int_weak (255));
    265265      buf[j] = '\0';
    266266
    267267      out = tr_base64_encode_str (buf, &len);
    268       check_int_eq (strlen (out), len);
     268      check_uint_eq (strlen (out), len);
    269269      in = tr_base64_decode_str (out, &len);
    270       check_int_eq (j, len);
     270      check_uint_eq (j, len);
    271271      check_streq (in, buf);
    272272      tr_free (in);
  • trunk/libtransmission/file-test.c

    r14717 r14721  
    121121        slashPos = p + strlen (p) - 1;
    122122
    123       pathPart = tr_strndup (path, slashPos - path + 1);
     123      pathPart = tr_strndup (path, (size_t)(slashPos - path + 1));
    124124
    125125      if (!tr_sys_path_get_info (pathPart, TR_SYS_PATH_NO_FOLLOW, &info, NULL) ||
     
    184184  check (err == NULL);
    185185  check_int_eq (TR_SYS_PATH_IS_FILE, info.type);
    186   check_int_eq (4, info.size);
     186  check_uint_eq (4, info.size);
    187187  check (info.last_modified_at >= t && info.last_modified_at <= time (NULL));
    188188
     
    193193  check (err == NULL);
    194194  check_int_eq (TR_SYS_PATH_IS_FILE, info.type);
    195   check_int_eq (4, info.size);
     195  check_uint_eq (4, info.size);
    196196  check (info.last_modified_at >= t && info.last_modified_at <= time (NULL));
    197197  tr_sys_file_close (fd, NULL);
     
    225225      check (err == NULL);
    226226      check_int_eq (TR_SYS_PATH_IS_FILE, info.type);
    227       check_int_eq (4, info.size);
     227      check_uint_eq (4, info.size);
    228228      check (info.last_modified_at >= t && info.last_modified_at <= time (NULL));
    229229
     
    234234      check (err == NULL);
    235235      check_int_eq (TR_SYS_PATH_IS_FILE, info.type);
    236       check_int_eq (4, info.size);
     236      check_uint_eq (4, info.size);
    237237      check (info.last_modified_at >= t && info.last_modified_at <= time (NULL));
    238238      tr_sys_file_close (fd, NULL);
     
    10111011  tr_error_clear (&err);
    10121012  tr_sys_path_get_info (path1, TR_SYS_PATH_NO_FOLLOW, &info, NULL);
    1013   check_int_eq (4, info.size);
     1013  check_uint_eq (4, info.size);
    10141014
    10151015  /* Pointer is at the end of file */
    10161016  tr_sys_path_get_info (path1, TR_SYS_PATH_NO_FOLLOW, &info, NULL);
    1017   check_int_eq (4, info.size);
     1017  check_uint_eq (4, info.size);
    10181018  fd = tr_sys_file_open (path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_APPEND, 0600, &err);
    10191019  check (fd != TR_BAD_SYS_FILE);
     
    10211021  tr_sys_file_write (fd, "s", 1, NULL, NULL); /* On *NIX, pointer is positioned on each write but not initially */
    10221022  tr_sys_file_seek (fd, 0, TR_SEEK_CUR, &n, NULL);
    1023   check_int_eq (5, n);
     1023  check_uint_eq (5, n);
    10241024  tr_sys_file_close (fd, NULL);
    10251025
    10261026  /* File gets truncated */
    10271027  tr_sys_path_get_info (path1, TR_SYS_PATH_NO_FOLLOW, &info, NULL);
    1028   check_int_eq (5, info.size);
     1028  check_uint_eq (5, info.size);
    10291029  fd = tr_sys_file_open (path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_TRUNCATE, 0600, &err);
    10301030  check (fd != TR_BAD_SYS_FILE);
    10311031  check (err == NULL);
    10321032  tr_sys_file_get_info (fd, &info, NULL);
    1033   check_int_eq (0, info.size);
     1033  check_uint_eq (0, info.size);
    10341034  tr_sys_file_close (fd, NULL);
    10351035  tr_sys_path_get_info (path1, TR_SYS_PATH_NO_FOLLOW, &info, NULL);
    1036   check_int_eq (0, info.size);
     1036  check_uint_eq (0, info.size);
    10371037
    10381038  /* TODO: symlink and hardlink tests */
     
    10621062  check (tr_sys_file_seek (fd, 0, TR_SEEK_CUR, &n, &err));
    10631063  check (err == NULL);
    1064   check_int_eq (0, n);
     1064  check_uint_eq (0, n);
    10651065
    10661066  check (tr_sys_file_write (fd, "test", 4, &n, &err));
    10671067  check (err == NULL);
    1068   check_int_eq (4, n);
     1068  check_uint_eq (4, n);
    10691069
    10701070  check (tr_sys_file_seek (fd, 0, TR_SEEK_CUR, &n, &err));
    10711071  check (err == NULL);
    1072   check_int_eq (4, n);
     1072  check_uint_eq (4, n);
    10731073
    10741074  check (tr_sys_file_seek (fd, 0, TR_SEEK_SET, &n, &err));
    10751075  check (err == NULL);
    1076   check_int_eq (0, n);
     1076  check_uint_eq (0, n);
    10771077
    10781078  check (tr_sys_file_read (fd, buf, sizeof (buf), &n, &err));
    10791079  check (err == NULL);
    1080   check_int_eq (4, n);
     1080  check_uint_eq (4, n);
    10811081
    10821082  check_int_eq (0, memcmp (buf, "test", 4));
     
    10841084  check (tr_sys_file_seek (fd, -3, TR_SEEK_CUR, &n, &err));
    10851085  check (err == NULL);
    1086   check_int_eq (1, n);
     1086  check_uint_eq (1, n);
    10871087
    10881088  check (tr_sys_file_write (fd, "E", 1, &n, &err));
    10891089  check (err == NULL);
    1090   check_int_eq (1, n);
     1090  check_uint_eq (1, n);
    10911091
    10921092  check (tr_sys_file_seek (fd, -2, TR_SEEK_CUR, &n, &err));
    10931093  check (err == NULL);
    1094   check_int_eq (0, n);
     1094  check_uint_eq (0, n);
    10951095
    10961096  check (tr_sys_file_read (fd, buf, sizeof (buf), &n, &err));
    10971097  check (err == NULL);
    1098   check_int_eq (4, n);
     1098  check_uint_eq (4, n);
    10991099
    11001100  check_int_eq (0, memcmp (buf, "tEst", 4));
     
    11021102  check (tr_sys_file_seek (fd, 0, TR_SEEK_END, &n, &err));
    11031103  check (err == NULL);
    1104   check_int_eq (4, n);
     1104  check_uint_eq (4, n);
    11051105
    11061106  check (tr_sys_file_write (fd, " ok", 3, &n, &err));
    11071107  check (err == NULL);
    1108   check_int_eq (3, n);
     1108  check_uint_eq (3, n);
    11091109
    11101110  check (tr_sys_file_seek (fd, 0, TR_SEEK_SET, &n, &err));
    11111111  check (err == NULL);
    1112   check_int_eq (0, n);
     1112  check_uint_eq (0, n);
    11131113
    11141114  check (tr_sys_file_read (fd, buf, sizeof (buf), &n, &err));
    11151115  check (err == NULL);
    1116   check_int_eq (7, n);
     1116  check_uint_eq (7, n);
    11171117
    11181118  check_int_eq (0, memcmp (buf, "tEst ok", 7));
     
    11201120  check (tr_sys_file_write_at (fd, "-", 1, 4, &n, &err));
    11211121  check (err == NULL);
    1122   check_int_eq (1, n);
     1122  check_uint_eq (1, n);
    11231123
    11241124  check (tr_sys_file_read_at (fd, buf, 5, 2, &n, &err));
    11251125  check (err == NULL);
    1126   check_int_eq (5, n);
     1126  check_uint_eq (5, n);
    11271127
    11281128  check_int_eq (0, memcmp (buf, "st-ok", 5));
     
    11541154  check (err == NULL);
    11551155  tr_sys_file_get_info (fd, &info, NULL);
    1156   check_int_eq (10, info.size);
     1156  check_uint_eq (10, info.size);
    11571157
    11581158  check (tr_sys_file_truncate (fd, 20, &err));
    11591159  check (err == NULL);
    11601160  tr_sys_file_get_info (fd, &info, NULL);
    1161   check_int_eq (20, info.size);
     1161  check_uint_eq (20, info.size);
    11621162
    11631163  check (tr_sys_file_truncate (fd, 0, &err));
    11641164  check (err == NULL);
    11651165  tr_sys_file_get_info (fd, &info, NULL);
    1166   check_int_eq (0, info.size);
     1166  check_uint_eq (0, info.size);
    11671167
    11681168  check (tr_sys_file_truncate (fd, 50, &err));
     
    11721172
    11731173  tr_sys_path_get_info (path1, 0, &info, NULL);
    1174   check_int_eq (50, info.size);
     1174  check_uint_eq (50, info.size);
    11751175
    11761176  fd = tr_sys_file_open (path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE, 0600, NULL);
     
    11821182
    11831183  tr_sys_path_get_info (path1, 0, &info, NULL);
    1184   check_int_eq (25, info.size);
     1184  check_uint_eq (25, info.size);
    11851185
    11861186  tr_sys_path_remove (path1, NULL);
     
    12091209      check (err == NULL);
    12101210      tr_sys_file_get_info (fd, &info, NULL);
    1211       check_int_eq (50, info.size);
     1211      check_uint_eq (50, info.size);
    12121212    }
    12131213  else
     
    12281228      check (err == NULL);
    12291229      tr_sys_file_get_info (fd, &info, NULL);
    1230       check_int_eq (500 * 1024 * 1024, info.size);
     1230      check_uint_eq (500 * 1024 * 1024, info.size);
    12311231    }
    12321232  else
  • trunk/libtransmission/json-test.c

    r14640 r14721  
    162162    check ((ids = tr_variantDictFind (args, TR_KEY_ids)));
    163163    check (tr_variantIsList (ids));
    164     check_int_eq (2, tr_variantListSize (ids));
     164    check_uint_eq (2, tr_variantListSize (ids));
    165165    check (tr_variantGetInt (tr_variantListChild (ids, 0), &i));
    166166    check_int_eq (7, i);
  • trunk/libtransmission/libtransmission-test.c

    r14718 r14721  
    8585    else
    8686      fprintf (stderr, "FAIL %s:%d, expected \"%"PRId64"\", got \"%"PRId64"\"\n", file, line, expected, actual);
     87  }
     88
     89  return pass;
     90}
     91
     92bool
     93check_uint_eq_impl (const char * file, int line, uint64_t expected, uint64_t actual)
     94{
     95  const bool pass = expected == actual;
     96
     97  if (should_print (pass)) {
     98    if (pass)
     99      fprintf (stderr, "PASS %s:%d\n", file, line);
     100    else
     101      fprintf (stderr, "FAIL %s:%d, expected \"%"PRIu64"\", got \"%"PRIu64"\"\n", file, line, expected, actual);
    87102  }
    88103
     
    195210
    196211#define MEM_K 1024
    197 #define MEM_B_STR   "B"
    198212#define MEM_K_STR "KiB"
    199213#define MEM_M_STR "MiB"
     
    202216
    203217#define DISK_K 1000
    204 #define DISK_B_STR  "B"
    205218#define DISK_K_STR "kB"
    206219#define DISK_M_STR "MB"
     
    209222
    210223#define SPEED_K 1000
    211 #define SPEED_B_STR  "B/s"
    212224#define SPEED_K_STR "kB/s"
    213225#define SPEED_M_STR "MB/s"
  • trunk/libtransmission/libtransmission-test.h

    r14382 r14721  
    2626
    2727bool check_condition_impl (const char * file, int line, bool condition);
    28 bool check_int_eq_impl (const char * file, int line, int64_t expected, int64_t actual);
    29 bool check_ptr_eq_impl (const char * file, int line, const void * expected, const void * actual);
    30 bool check_streq_impl (const char * file, int line, const char * expected, const char * actual);
     28bool check_int_eq_impl    (const char * file, int line, int64_t      expected, int64_t      actual);
     29bool check_uint_eq_impl   (const char * file, int line, uint64_t     expected, uint64_t     actual);
     30bool check_ptr_eq_impl    (const char * file, int line, const void * expected, const void * actual);
     31bool check_streq_impl     (const char * file, int line, const char * expected, const char * actual);
    3132
    3233/***
     
    5253    ++current_test; \
    5354    if (!check_int_eq_impl (__FILE__, __LINE__, (expected), (actual))) \
     55      return current_test; \
     56  } while (0)
     57
     58#define check_uint_eq(expected, actual) \
     59  do { \
     60    ++current_test; \
     61    if (!check_uint_eq_impl (__FILE__, __LINE__, (expected), (actual))) \
    5462      return current_test; \
    5563  } while (0)
  • trunk/libtransmission/move-test.c

    r14587 r14721  
    6969test_incomplete_dir_impl (const char * incomplete_dir, const char * download_dir)
    7070{
    71   size_t i;
     71  tr_file_index_t file_index;
    7272  tr_session * session;
    7373  tr_torrent * tor;
     
    9494  check_file_location (tor, 0, tr_strdup_printf("%s/%s.part", incomplete_dir, tor->info.files[0].name));
    9595  check_file_location (tor, 1, tr_buildPath(incomplete_dir, tor->info.files[1].name, NULL));
    96   check_int_eq (tor->info.pieceSize, tr_torrentStat(tor)->leftUntilDone);
     96  check_uint_eq (tor->info.pieceSize, tr_torrentStat(tor)->leftUntilDone);
    9797
    9898  completeness = completeness_unset;
     
    101101  /* now finish writing it */
    102102  {
     103    tr_block_index_t block_index;
    103104    tr_block_index_t first, last;
    104105    char * zero_block = tr_new0 (char, tor->blockSize);
     
    111112
    112113    tr_torGetPieceBlockRange (tor, data.pieceIndex, &first, &last);
    113     for (i=first; i<=last; ++i)
     114    for (block_index=first; block_index<=last; ++block_index)
    114115      {
    115116        evbuffer_add (data.buf, zero_block, tor->blockSize);
    116         data.block = i;
     117        data.block = block_index;
    117118        data.done = false;
    118119        data.offset = data.block * tor->blockSize;
     
    126127
    127128  libttest_blockingTorrentVerify (tor);
    128   check_int_eq (0, tr_torrentStat(tor)->leftUntilDone);
     129  check_uint_eq (0, tr_torrentStat(tor)->leftUntilDone);
    129130
    130131  while ((completeness==completeness_unset) && (time(NULL)<=deadline))
     
    132133
    133134  check_int_eq (TR_SEED, completeness);
    134   for (i=0; i<tor->info.fileCount; ++i)
    135     check_file_location (tor, i, tr_buildPath (download_dir, tor->info.files[i].name, NULL));
     135  for (file_index=0; file_index<tor->info.fileCount; ++file_index)
     136    check_file_location (tor, file_index, tr_buildPath (download_dir, tor->info.files[file_index].name, NULL));
    136137
    137138  /* cleanup */
     
    168169test_set_location (void)
    169170{
    170   size_t i;
     171  tr_file_index_t file_index;
    171172  int state;
    172173  char * target_dir;
     
    184185  libttest_zero_torrent_populate (tor, true);
    185186  libttest_blockingTorrentVerify (tor);
    186   check_int_eq (0, tr_torrentStat(tor)->leftUntilDone);
     187  check_uint_eq (0, tr_torrentStat(tor)->leftUntilDone);
    187188
    188189  /* now move it */
     
    195196  /* confirm the torrent is still complete after being moved */
    196197  libttest_blockingTorrentVerify (tor);
    197   check_int_eq (0, tr_torrentStat(tor)->leftUntilDone);
     198  check_uint_eq (0, tr_torrentStat(tor)->leftUntilDone);
    198199
    199200  /* confirm the filest really got moved */
    200201  libttest_sync ();
    201   for (i=0; i<tor->info.fileCount; ++i)
    202     check_file_location (tor, i, tr_buildPath (target_dir, tor->info.files[i].name, NULL));
     202  for (file_index=0; file_index<tor->info.fileCount; ++file_index)
     203    check_file_location (tor, file_index, tr_buildPath (target_dir, tor->info.files[file_index].name, NULL));
    203204
    204205  /* cleanup */
  • trunk/libtransmission/net.h

    r14574 r14721  
    2727#endif
    2828
    29 #ifndef _TR_NET_H_
    30 #define _TR_NET_H_
     29#ifndef TR_NET_H
     30#define TR_NET_H
    3131
    3232#ifdef _WIN32
     
    175175const unsigned char *tr_globalIPv6 (void);
    176176
    177 #endif /* _TR_NET_H_ */
     177#endif /* TR_NET_H */
  • trunk/libtransmission/platform.h

    r14532 r14721  
    5555/** @brief Return nonzero if this function is being called from `thread'
    5656    @param thread the thread being tested */
    57 bool tr_amInThread (const tr_thread *);
     57bool tr_amInThread (const tr_thread * thread);
    5858
    5959/***
  • trunk/libtransmission/ptrarray.h

    r14241 r14721  
    1212#endif
    1313
    14 #ifndef _TR_PTR_ARRAY_H_
    15 #define _TR_PTR_ARRAY_H_
     14#ifndef TR_PTR_ARRAY_H
     15#define TR_PTR_ARRAY_H
    1616
    1717#include <assert.h>
  • trunk/libtransmission/quark-test.c

    r14669 r14721  
    2525      const char * str;
    2626
    27       str = tr_quark_get_string (i, &len);
    28       check_int_eq (strlen(str), len);
     27      str = tr_quark_get_string ((tr_quark)i, &len);
     28      check_uint_eq (strlen(str), len);
    2929      check (tr_quark_lookup (str, len, &q));
    30       check_int_eq (i, q);
     30      check_int_eq (i, (int)q);
    3131    }
    3232
     
    3636      const char *str1, *str2;
    3737
    38       str1 = tr_quark_get_string (i, &len1);
    39       str2 = tr_quark_get_string (i+1, &len2);
     38      str1 = tr_quark_get_string ((tr_quark)i, &len1);
     39      str2 = tr_quark_get_string ((tr_quark)(i+1), &len2);
    4040
    4141      check (strcmp (str1, str2) < 0);
     
    4343
    4444  const tr_quark q = tr_quark_new (NULL, TR_BAD_SIZE);
    45   check_int_eq (TR_KEY_NONE, q);
     45  check_int_eq (TR_KEY_NONE, (int)q);
    4646  check_streq ("", tr_quark_get_string (q, NULL));
    4747
  • trunk/libtransmission/rename-test.c

    r14718 r14721  
    3030#define check_have_none(tor, totalSize) \
    3131  do { \
    32     const tr_stat * st = tr_torrentStat(tor); \
    33     check_int_eq (TR_STATUS_STOPPED, st->activity); \
    34     check_int_eq (TR_STAT_OK, st->error); \
    35     check_int_eq (totalSize, st->sizeWhenDone); \
    36     check_int_eq (totalSize, st->leftUntilDone); \
    37     check_int_eq (totalSize, tor->info.totalSize); \
    38     check_int_eq (0, st->haveValid); \
     32    const tr_stat * tst = tr_torrentStat(tor); \
     33    check_int_eq (TR_STATUS_STOPPED, tst->activity); \
     34    check_int_eq (TR_STAT_OK, tst->error); \
     35    check_uint_eq (totalSize, tst->sizeWhenDone); \
     36    check_uint_eq (totalSize, tst->leftUntilDone); \
     37    check_uint_eq (totalSize, tor->info.totalSize); \
     38    check_uint_eq (0, tst->haveValid); \
    3939  } while (0)
    4040
     
    158158  check_int_eq (TR_STATUS_STOPPED, st->activity);
    159159  check_int_eq (TR_STAT_OK, st->error);
    160   check_int_eq (0, st->leftUntilDone);
    161   check_int_eq (0, st->haveUnchecked);
    162   check_int_eq (0, st->desiredAvailable);
    163   check_int_eq (totalSize, st->sizeWhenDone);
    164   check_int_eq (totalSize, st->haveValid);
     160  check_uint_eq (0, st->leftUntilDone);
     161  check_uint_eq (0, st->haveUnchecked);
     162  check_uint_eq (0, st->desiredAvailable);
     163  check_uint_eq (totalSize, st->sizeWhenDone);
     164  check_uint_eq (totalSize, st->haveValid);
    165165
    166166  /**
     
    298298  /* sanity check the info */
    299299  check_streq (tor->info.name, "Felidae");
    300   check_int_eq (totalSize, tor->info.totalSize);
    301   check_int_eq (4, tor->info.fileCount);
     300  check_uint_eq (totalSize, tor->info.totalSize);
     301  check_uint_eq (4, tor->info.fileCount);
    302302  for (i=0; i<4; ++i)
    303303    check_streq (expected_files[i], files[i].name);
     
    315315  check_int_eq (TR_STATUS_STOPPED, st->activity);
    316316  check_int_eq (TR_STAT_OK, st->error);
    317   check_int_eq (0, st->leftUntilDone);
    318   check_int_eq (0, st->haveUnchecked);
    319   check_int_eq (0, st->desiredAvailable);
    320   check_int_eq (totalSize, st->sizeWhenDone);
    321   check_int_eq (totalSize, st->haveValid);
     317  check_uint_eq (0, st->leftUntilDone);
     318  check_uint_eq (0, st->haveUnchecked);
     319  check_uint_eq (0, st->desiredAvailable);
     320  check_uint_eq (totalSize, st->sizeWhenDone);
     321  check_uint_eq (totalSize, st->haveValid);
    322322
    323323
     
    507507
    508508  tor = libttest_zero_torrent_init (session);
    509   check_int_eq (totalSize, tor->info.totalSize);
    510   check_int_eq (pieceSize, tor->info.pieceSize);
    511   check_int_eq (pieceCount, tor->info.pieceCount);
     509  check_uint_eq (totalSize, tor->info.totalSize);
     510  check_uint_eq (pieceSize, tor->info.pieceSize);
     511  check_uint_eq (pieceCount, tor->info.pieceCount);
    512512  check_streq ("files-filled-with-zeroes/1048576", tor->info.files[0].name);
    513513  check_streq ("files-filled-with-zeroes/4096",    tor->info.files[1].name);
     
    516516  libttest_zero_torrent_populate (tor, false);
    517517  fst = tr_torrentFiles (tor, NULL);
    518   check_int_eq (length[0] - pieceSize, fst[0].bytesCompleted);
    519   check_int_eq (length[1],             fst[1].bytesCompleted);
    520   check_int_eq (length[2],             fst[2].bytesCompleted);
     518  check_uint_eq (length[0] - pieceSize, fst[0].bytesCompleted);
     519  check_uint_eq (length[1],             fst[1].bytesCompleted);
     520  check_uint_eq (length[2],             fst[2].bytesCompleted);
    521521  tr_torrentFilesFree (fst, tor->info.fileCount);
    522522  st = tr_torrentStat (tor);
    523   check_int_eq (totalSize, st->sizeWhenDone);
    524   check_int_eq (pieceSize, st->leftUntilDone);
     523  check_uint_eq (totalSize, st->sizeWhenDone);
     524  check_uint_eq (pieceSize, st->leftUntilDone);
    525525
    526526  /***
  • trunk/libtransmission/rpc-test.c

    r14633 r14721  
    4747  check (tr_variantIsString (&top));
    4848  check (tr_variantGetStr (&top, &str, &len));
    49   check_int_eq (4, len);
     49  check_uint_eq (4, len);
    5050  check_streq ("asdf", str);
    5151  tr_variantFree (&top);
  • trunk/libtransmission/session-test.c

    r14718 r14721  
    3737        for (j = 8; j < PEER_ID_LEN; ++j)
    3838        {
    39             char tmp[2] = { peer_id[j], '\0' };
     39            char tmp[2] = { (char)peer_id[j], '\0' };
    4040            val += strtoul (tmp, NULL, 36);
    4141        }
  • trunk/libtransmission/session.h

    r14581 r14721  
    304304toMemBytes (unsigned int MB) { uint64_t B = tr_mem_K * tr_mem_K; B *= MB; return B; }
    305305static inline int
    306 toMemMB  (uint64_t B)      { return B / (tr_mem_K * tr_mem_K); }
     306toMemMB  (uint64_t B)      { return (int)(B / (tr_mem_K * tr_mem_K)); }
    307307
    308308/**
  • trunk/libtransmission/tr-utp.h

    r13625 r14721  
    2626#endif
    2727
    28 #ifndef _TR_UTP_H_
    29 #define _TR_UTP_H_
     28#ifndef TR_UTP_H
     29#define TR_UTP_H
    3030
    3131int tr_utpPacket (const unsigned char *buf, size_t buflen,
     
    3838                  const struct sockaddr *to, socklen_t tolen);
    3939
    40 #endif /* #ifndef _TR_UTP_H_ */
     40#endif /* #ifndef TR_UTP_H */
  • trunk/libtransmission/transmission.h

    r14645 r14721  
    1919#ifdef __cplusplus
    2020extern "C" {
     21#endif
     22
     23#if defined(__GNUC__)
     24 #define TR_DEPRECATED __attribute__((deprecated))
     25#elif defined(__clang__)
     26 #define TR_DEPRECATED __attribute__((gnu::deprecated))
     27#else
     28 #define TR_DEPRECATED
    2129#endif
    2230
     
    146154 * @endcode
    147155 *
    148  * @param initme pointer to a tr_variant dictionary
     156 * @param setme_dictionary pointer to a tr_variant dictionary
    149157 * @see tr_sessionLoadSettings ()
    150158 * @see tr_sessionInit ()
    151159 * @see tr_getDefaultConfigDir ()
    152160 */
    153 void tr_sessionGetDefaultSettings (struct tr_variant * dictionary);
     161void tr_sessionGetDefaultSettings (struct tr_variant * setme_dictionary);
    154162
    155163/**
     
    158166 * FIXME: this probably belongs in libtransmissionapp
    159167 *
    160  * @param session
    161  * @param dictionary
     168 * @param session          the session to query
     169 * @param setme_dictionary the dictionary to populate
    162170 * @see tr_sessionGetDefaultSettings ()
    163171 */
    164 void tr_sessionGetSettings (tr_session *, struct tr_variant * dictionary);
     172void tr_sessionGetSettings (tr_session * session,
     173                            struct tr_variant * setme_dictionary);
    165174
    166175/**
     
    188197 * FIXME: this belongs in libtransmissionapp
    189198 *
    190  * @param session
    191  * @param dictionary
     199 * @param session    the session to save
     200 * @param configDir  the directory to write to
     201 * @param dictionary the dictionary to save
    192202 * @see tr_sessionLoadSettings ()
    193203 */
    194204void tr_sessionSaveSettings (tr_session              * session,
    195205                             const char              * configDir,
    196                              const struct tr_variant * dictonary);
     206                             const struct tr_variant * dictionary);
    197207
    198208/**
     
    356366 * @brief Specify which base URL to use.
    357367 *
    358  * @detail The RPC API is accessible under <url>/rpc, the web interface under
    359  * <url>/web.
     368 * @param session the session to set
     369 * @param url     the base url to use. The RPC API is accessible under <url>/rpc, the web interface under * <url>/web.
    360370 *
    361371 *  @see tr_sessionGetRPCUrl
     
    896906
    897907/** @brief Create a torrent constructor object used to instantiate a tr_torrent
    898     @param session the tr_session. This is required if you're going to call
    899                    tr_torrentNew (), but you can use NULL for tr_torrentParse ().
     908    @param session_or_NULL the tr_session.
     909                           This is required if you're going to call tr_torrentNew (),
     910                           but you can use NULL for tr_torrentParse ().
    900911    @see tr_torrentNew (), tr_torrentParse () */
    901912tr_ctor* tr_ctorNew (const tr_session * session_or_NULL);
     
    10131024 *         TR_PARSE_DUPLICATE if parsing succeeded but it's a duplicate.
    10141025 *
    1015  * @param setme_info If parsing is successful and setme_info is non-NULL,
    1016  *                   the parsed metainfo is stored there and sould be freed
    1017  *                   by calling tr_metainfoFree () when no longer needed.
     1026 * @param setme_info_or_NULL If parsing is successful and setme_info is non-NULL,
     1027 *                           the parsed metainfo is stored there and sould be freed
     1028 *                           by calling tr_metainfoFree () when no longer needed.
    10181029 *
    10191030 * Notes:
     
    10391050 * Returns a pointer to the torrent on success, or NULL on failure.
    10401051 *
    1041  * @param setme_error: TR_PARSE_ERR if the parsing failed;
    1042  *                     TR_PARSE_OK if parsing succeeded and it's not a duplicate;
    1043  *                     TR_PARSE_DUPLICATE if parsing succeeded but it's a duplicate.
    1044  *
    1045  * @param setme_duplicate_id: when setmeError is TR_PARSE_DUPLICATE,
    1046  *                            this field is set to the duplicate torrent's id.
     1052 * @param ctor               the builder struct
     1053 * @param setme_error        TR_PARSE_ERR if the parsing failed;
     1054 *                           TR_PARSE_OK if parsing succeeded and it's not a duplicate;
     1055 *                           TR_PARSE_DUPLICATE if parsing succeeded but it's a duplicate.
     1056 * @param setme_duplicate_id when setmeError is TR_PARSE_DUPLICATE,
     1057 *                           this field is set to the duplicate torrent's id.
    10471058 */
    10481059tr_torrent * tr_torrentNew (const tr_ctor   * ctor,
     
    10831094 * @brief Rename a file or directory in a torrent.
    10841095 *
    1085  * @tor: the torrent whose path will be renamed.
    1086  * @oldpath: the path to the file or folder that will be renamed
    1087  * @newname: the file or folder's new name
    1088  * @callback: the callback invoked when the renaming finishes, or NULL
    1089  * @callback_data: the pointer to pass in the callback's user_data arg
     1096 * @param tor           the torrent whose path will be renamed
     1097 * @param oldpath      the path to the file or folder that will be renamed
     1098 * @param newname      the file or folder's new name
     1099 * @param callback      the callback invoked when the renaming finishes, or NULL
     1100 * @param callback_data the pointer to pass in the callback's user_data arg
    10901101 *
    10911102 * As a special case, renaming the root file in a torrent will also
     
    11251136                           const char                  * newname,
    11261137                           tr_torrent_rename_done_func   callback,
    1127                            void                        * callback_user_data);
     1138                           void                        * callback_data);
    11281139
    11291140enum
     
    11811192 * @param fileNum the fileIndex, in [0...tr_info.fileCount)
    11821193 */
    1183 char* tr_torrentFindFile (const tr_torrent * tor, tr_file_index_t fileNo);
     1194char* tr_torrentFindFile (const tr_torrent * tor, tr_file_index_t fileNum);
    11841195
    11851196
     
    17111722 *                such as tr_torrentStop() or tr_torrentSetLocation()
    17121723 *                being called during verification.
    1713  * @param callback_data the user-defined pointer from tr_torrentVerify()
     1724 * @param user_data the user-defined pointer from tr_torrentVerify()
    17141725 */
    17151726typedef void (*tr_verify_done_func)(tr_torrent  * torrent,
     
    20312042/** @deprecated */
    20322043void tr_torrentSetAddedDate (tr_torrent * torrent,
    2033                              time_t       addedDate);
     2044                             time_t       addedDate) TR_DEPRECATED;
    20342045
    20352046/** @deprecated */
    20362047void tr_torrentSetActivityDate (tr_torrent * torrent,
    2037                                 time_t       activityDate);
     2048                                time_t       activityDate) TR_DEPRECATED;
    20382049
    20392050/** @deprecated */
    2040 void tr_torrentSetDoneDate (tr_torrent * torrent, time_t doneDate);
     2051void tr_torrentSetDoneDate (tr_torrent * torrent, time_t doneDate) TR_DEPRECATED;
    20412052
    20422053/** @} */
  • trunk/libtransmission/utils-test.c

    r14678 r14721  
    302302test_array (void)
    303303{
    304   int i;
    305   int array[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    306   int n = sizeof (array) / sizeof (array[0]);
    307 
    308   tr_removeElementFromArray (array, 5u, sizeof (int), n--);
     304  size_t i;
     305  size_t array[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
     306  size_t n = sizeof (array) / sizeof (array[0]);
     307
     308  tr_removeElementFromArray (array, 5u, sizeof (size_t), n--);
    309309  for (i=0; i<n; ++i)
    310310    check_int_eq ((i<5 ? i : i+1), array[i]);
    311311
    312   tr_removeElementFromArray (array, 0u, sizeof (int), n--);
     312  tr_removeElementFromArray (array, 0u, sizeof (size_t), n--);
    313313  for (i=0; i<n; ++i)
    314314    check_int_eq ((i<4 ? i+1 : i+2), array[i]);
    315315
    316   tr_removeElementFromArray (array, n-1, sizeof (int), n); n--;
     316  tr_removeElementFromArray (array, n-1, sizeof (size_t), n); n--;
    317317  for (i=0; i<n; ++i)
    318318    check_int_eq ((i<4 ? i+1 : i+2), array[i]);
  • trunk/libtransmission/utils.h

    r14641 r14721  
    165165/**
    166166 * @brief Convenience wrapper around timer_add () to have a timer wake up in a number of seconds and microseconds
    167  * @param timer
    168  * @param seconds
    169  * @param microseconds
     167 * @param timer         the timer to set
     168 * @param seconds       seconds to wait
     169 * @param microseconds  microseconds to wait
    170170 */
    171171void tr_timerAdd (struct event * timer, int seconds, int microseconds) TR_GNUC_NONNULL (1);
     
    173173/**
    174174 * @brief Convenience wrapper around timer_add () to have a timer wake up in a number of milliseconds
    175  * @param timer
    176  * @param milliseconds
     175 * @param timer         the timer to set
     176 * @param milliseconds  milliseconds to wait
    177177 */
    178178void tr_timerAddMsec (struct event * timer, int milliseconds) TR_GNUC_NONNULL (1);
     
    330330
    331331/** @brief Convenience wrapper around strerorr () guaranteed to not return NULL
    332     @param errno */
    333 const char* tr_strerror (int);
     332    @param errnum the error number to describe */
     333const char* tr_strerror (int errnum);
    334334
    335335/** @brief strips leading and trailing whitspace from a string
     
    413413
    414414/**
    415  * @param buf the buffer to write the string to
    416  * @param buflef buf's size
    417  * @param ratio the ratio to convert to a string
    418  * @param the string represntation of "infinity"
     415 * @param buf      the buffer to write the string to
     416 * @param bufle buf's size
     417 * @param ratio    the ratio to convert to a string
     418 * @param infinity the string represntation of "infinity"
    419419 */
    420420char* tr_strratio (char * buf, size_t buflen, double ratio, const char * infinity) TR_GNUC_NONNULL (1,4);
     
    495495
    496496/* format a memory size from MB into a user-readable string. */
    497 static inline char* tr_formatter_mem_MB (char * buf, double MBps, size_t buflen) { return tr_formatter_mem_B (buf, MBps * tr_mem_K * tr_mem_K, buflen); }
     497static inline char* tr_formatter_mem_MB (char * buf, double MBps, size_t buflen) { return tr_formatter_mem_B (buf, (int64_t)(MBps * tr_mem_K * tr_mem_K), buflen); }
    498498
    499499/* format a file size from bytes into a user-readable string. */
  • trunk/libtransmission/variant-test.c

    r14718 r14721  
    104104  err = tr_bencParseStr (buf, buf+n, &end, &str, &len);
    105105  check_int_eq (EILSEQ, err);
    106   check_int_eq (0, len);
     106  check_uint_eq (0, len);
    107107  check (str == NULL);
    108108  check (end == NULL);
     
    113113  err = tr_bencParseStr (buf, buf+n, &end, &str, &len);
    114114  check_int_eq (0, err);
    115   check_int_eq (4, len);
     115  check_uint_eq (4, len);
    116116  check (strncmp ((const char*)str, "boat", len) == 0);
    117117  check (end == buf + 6);
     
    123123  err = tr_bencParseStr (buf, buf+(n-1), &end, &str, &len);
    124124  check_int_eq (EILSEQ, err);
    125   check_int_eq (0, len);
     125  check_uint_eq (0, len);
    126126  check (str == NULL);
    127127  check (end == NULL);
     
    132132  err = tr_bencParseStr (buf, buf+n, &end, &str, &len);
    133133  check_int_eq (0, err);
    134   check_int_eq (0, len);
     134  check_uint_eq (0, len);
    135135  check (!*str);
    136136  check (end == buf + 2);
     
    143143  err = tr_bencParseStr (buf, buf+n, &end, &str, &len);
    144144  check_int_eq (0, err);
    145   check_int_eq (3, len);
     145  check_uint_eq (3, len);
    146146  check (strncmp ((const char*)str, "boa", len) == 0);
    147147  check (end == buf + 5);
     
    179179      saved = tr_variantToStr (&val, TR_VARIANT_FMT_BENC, &savedLen);
    180180      check_streq (str, saved);
    181       check_int_eq (savedLen, len);
     181      check_uint_eq (savedLen, len);
    182182      tr_free (saved);
    183183      tr_variantFree (&val);
     
    415415  check_int_eq (-35, i);
    416416  check (tr_variantDictFindStr (&dest, s5, &s, &len));
    417   check_int_eq (3, len);
     417  check_uint_eq (3, len);
    418418  check_streq ("abc", s);
    419419  check (tr_variantDictFindStr (&dest, s6, &s, &len));
    420   check_int_eq (3, len);
     420  check_uint_eq (3, len);
    421421  check_streq ("xyz", s);
    422422  check (tr_variantDictFindStr (&dest, s7, &s,  &len));
    423   check_int_eq (9, len);
     423  check_uint_eq (9, len);
    424424  check_streq ("127.0.0.1", s);
    425425  check (tr_variantDictFindStr (&dest, s8, &s, &len));
    426   check_int_eq (3, len);
     426  check_uint_eq (3, len);
    427427  check_streq ("ghi", s);
    428428
     
    535535  check (boolVal == true);
    536536  check (tr_variantDictFindStr (&top, key_str, &strVal, &strLen));
    537   check_int_eq (16, strLen);
     537  check_uint_eq (16, strLen);
    538538  check_streq ("this-is-a-string", strVal);
    539539  check (tr_variantDictFindReal (&top, key_real, &realVal));
  • trunk/libtransmission/watchdir-test.c

    r14675 r14721  
    3232#define CB_DATA_STATIC_INIT { NULL, NULL, 0 }
    3333
    34 struct event_base * ev_base = NULL;
     34static struct event_base * ev_base = NULL;
    3535
    3636extern struct timeval tr_watchdir_generic_interval;
     
    3939extern struct timeval tr_watchdir_retry_max_interval;
    4040
    41 const struct timeval FIFTY_MSEC       = { 0,  50000 };
    42 const struct timeval ONE_HUNDRED_MSEC = { 0, 100000 };
    43 const struct timeval TWO_HUNDRED_MSEC = { 0, 200000 };
     41static const struct timeval FIFTY_MSEC       = { 0,  50000 };
     42static const struct timeval ONE_HUNDRED_MSEC = { 0, 100000 };
     43static const struct timeval TWO_HUNDRED_MSEC = { 0, 200000 };
    4444
    4545static void
Note: See TracChangeset for help on using the changeset viewer.