]> granicus.if.org Git - transmission/commitdiff
Include stdbool.h unconditionally
authorMike Gelfand <mikedld@mikedld.com>
Wed, 24 May 2017 19:53:06 +0000 (22:53 +0300)
committerMike Gelfand <mikedld@mikedld.com>
Wed, 24 May 2017 19:53:06 +0000 (22:53 +0300)
All the compilers should provide the header file by now. Remove `tr_isBool`
sanity checks along the way as compiler should guarantee that bool (_Bool)
values are 0 or 1 and nothing else.

13 files changed:
CMakeLists.txt
configure.ac
libtransmission/blocklist.c
libtransmission/log.c
libtransmission/makemeta.c
libtransmission/peer-io.c
libtransmission/peer-mgr.c
libtransmission/peer-msgs.c
libtransmission/rpc-server.c
libtransmission/session.c
libtransmission/torrent-ctor.c
libtransmission/torrent.c
libtransmission/transmission.h

index fc0d28ccf70496848b98a3779db5b77f816992e8..3774945c7455f063ac67df7d582c26289ef12a7e 100644 (file)
@@ -432,7 +432,6 @@ endif()
 include(LargeFileSupport)
 
 set(NEEDED_HEADERS
-    stdbool.h
     sys/statvfs.h
     xfs/xfs.h
     xlocale.h)
index 18200e76abda29cbc0036586863e2a9a641a19ab..c1a41886a4b70020e4e1564437afe98cf3245992 100644 (file)
@@ -109,7 +109,7 @@ AC_PROG_MKDIR_P
 AC_HEADER_STDC
 AC_HEADER_TIME
 
-AC_CHECK_HEADERS([stdbool.h xlocale.h])
+AC_CHECK_HEADERS([xlocale.h])
 AC_CHECK_FUNCS([iconv pread pwrite lrintf strlcpy daemon dirname basename canonicalize_file_name strcasecmp localtime_r fallocate64 posix_fallocate memmem strsep strtold syslog valloc getpagesize posix_memalign statvfs htonll ntohll mkdtemp uselocale _configthreadlocale])
 AC_PROG_INSTALL
 AC_PROG_MAKE_SET
index b8e4dfa3db798eae6f52735bcb704f00b2fa7c56..0992ecc1b38c85cae968f8ab4d7bfb49619ec7d3 100644 (file)
@@ -184,7 +184,6 @@ bool tr_blocklistFileIsEnabled(tr_blocklistFile* b)
 void tr_blocklistFileSetEnabled(tr_blocklistFile* b, bool isEnabled)
 {
     assert(b != NULL);
-    assert(tr_isBool(isEnabled));
 
     b->isEnabled = isEnabled;
 }
index d8bef40d01826912cd9e165d35789468b0795772..9a8dada4d454681b2a9ab1377a1b646bac53859f 100644 (file)
@@ -97,8 +97,6 @@ void tr_logSetLevel(tr_log_level level)
 
 void tr_logSetQueueEnabled(bool isEnabled)
 {
-    assert(tr_isBool(isEnabled));
-
     myQueueEnabled = isEnabled;
 }
 
index 51c37b3f85f38a99fa04338aa4dfdd1291a84000..99dcc61192a3ef3c226035ae689b042cc7027291 100644 (file)
@@ -560,8 +560,6 @@ void tr_makeMetaInfo(tr_metainfo_builder* builder, char const* outputFile, tr_tr
 {
     tr_lock* lock;
 
-    assert(tr_isBool(isPrivate));
-
     /* free any variables from a previous run */
     for (int i = 0; i < builder->trackerCount; ++i)
     {
index 4b27b5d45e66858935c28a572fdb7a50dced3ab4..5cffa1dfedde6a66f5ebfa7e8f2ee604af34329d 100644 (file)
@@ -619,8 +619,6 @@ static tr_peerIo* tr_peerIoNew(tr_session* session, tr_bandwidth* parent, tr_add
 
     assert(session != NULL);
     assert(session->events != NULL);
-    assert(tr_isBool(isIncoming));
-    assert(tr_isBool(isSeed));
     assert(tr_amInEventThread(session));
     assert((socket == TR_BAD_SOCKET) == (utp_socket != NULL));
 #ifndef WITH_UTP
index ccd7441da74bd13a4189bc09d23d1aca7c55786f..6d19ff3fb5e4cadce39b8342bb1f780114163593 100644 (file)
@@ -575,7 +575,6 @@ static bool isAtomBlocklisted(tr_session* session, struct peer_atom* atom)
         atom->blocklisted = tr_sessionIsAddressBlocked(session, &atom->addr);
     }
 
-    assert(tr_isBool(atom->blocklisted));
     return atom->blocklisted;
 }
 
@@ -2007,7 +2006,6 @@ static bool myHandshakeDoneCB(tr_handshake* handshake, tr_peerIo* io, bool readA
     tr_swarm* s;
 
     assert(io != NULL);
-    assert(tr_isBool(ok));
 
     s = tr_peerIoHasTorrentHash(io) ? getExistingSwarm(manager, tr_peerIoGetTorrentHash(io)) : NULL;
 
index 07293b00068fe7cd9bdfdd133e964350fee231f8..158502e2de73c6bc6732771453509b020698cf25 100644 (file)
@@ -728,7 +728,6 @@ static void sendInterest(tr_peerMsgs* msgs, bool b)
     struct evbuffer* out = msgs->outMessages;
 
     assert(msgs != NULL);
-    assert(tr_isBool(b));
 
     msgs->client_is_interested = b;
     dbgmsg(msgs, "Sending %s", b ? "Interested" : "Not Interested");
@@ -746,8 +745,6 @@ static void updateInterest(tr_peerMsgs* msgs UNUSED)
 
 void tr_peerMsgsSetInterested(tr_peerMsgs* msgs, bool b)
 {
-    assert(tr_isBool(b));
-
     if (msgs->client_is_interested != b)
     {
         sendInterest(msgs, b);
@@ -804,7 +801,6 @@ void tr_peerMsgsSetChoke(tr_peerMsgs* msgs, bool peer_is_choked)
     time_t const fibrillationTime = now - MIN_CHOKE_PERIOD_SEC;
 
     assert(msgs != NULL);
-    assert(tr_isBool(peer_is_choked));
 
     if (msgs->chokeChangedAt > fibrillationTime)
     {
index 80a77228dd6f399d3e1ac3a2f172660d5b9a7221..3cea274c307a5e599a0d1d916ba1f2e52a316ba2 100644 (file)
@@ -879,8 +879,6 @@ char const* tr_rpcGetWhitelist(tr_rpc_server const* server)
 
 void tr_rpcSetWhitelistEnabled(tr_rpc_server* server, bool isEnabled)
 {
-    assert(tr_isBool(isEnabled));
-
     server->isWhitelistEnabled = isEnabled;
 }
 
index c18ff1b21ce3b7e6b4e5e2a7d49ae15b9be5e56b..9a17b80a3e16138b5008bebb9eefefec22adb331 100644 (file)
@@ -1200,7 +1200,6 @@ int64_t tr_sessionGetDirFreeSpace(tr_session* session, char const* dir)
 void tr_sessionSetIncompleteFileNamingEnabled(tr_session* session, bool b)
 {
     assert(tr_isSession(session));
-    assert(tr_isBool(b));
 
     session->isIncompleteFileNamingEnabled = b;
 }
@@ -1238,7 +1237,6 @@ char const* tr_sessionGetIncompleteDir(tr_session const* session)
 void tr_sessionSetIncompleteDirEnabled(tr_session* session, bool b)
 {
     assert(tr_isSession(session));
-    assert(tr_isBool(b));
 
     session->isIncompleteDirEnabled = b;
 }
@@ -1510,8 +1508,6 @@ static void useAltSpeed(tr_session* s, struct tr_turtle_info* t, bool enabled, b
 {
     assert(tr_isSession(s));
     assert(t != NULL);
-    assert(tr_isBool(enabled));
-    assert(tr_isBool(byUser));
 
     if (t->isEnabled != enabled)
     {
@@ -1624,7 +1620,6 @@ void tr_sessionLimitSpeed(tr_session* s, tr_direction d, bool b)
 {
     assert(tr_isSession(s));
     assert(tr_isDirection(d));
-    assert(tr_isBool(b));
 
     s->speedLimitEnabled[d] = b;
 
@@ -1692,7 +1687,6 @@ void tr_sessionUseAltSpeedTime(tr_session* s, bool b)
     struct tr_turtle_info* t = &s->turtle;
 
     assert(tr_isSession(s));
-    assert(tr_isBool(b));
 
     if (t->isClockEnabled != b)
     {
@@ -2214,7 +2208,6 @@ tr_torrent** tr_sessionLoadTorrents(tr_session* session, tr_ctor* ctor, int* set
 void tr_sessionSetPexEnabled(tr_session* session, bool enabled)
 {
     assert(tr_isSession(session));
-    assert(tr_isBool(enabled));
 
     session->isPexEnabled = enabled;
 }
@@ -2251,7 +2244,6 @@ static void toggleDHTImpl(void* data)
 void tr_sessionSetDHTEnabled(tr_session* session, bool enabled)
 {
     assert(tr_isSession(session));
-    assert(tr_isBool(enabled));
 
     if (enabled != session->isDHTEnabled)
     {
@@ -2291,7 +2283,6 @@ static void toggle_utp(void* data)
 void tr_sessionSetUTPEnabled(tr_session* session, bool enabled)
 {
     assert(tr_isSession(session));
-    assert(tr_isBool(enabled));
 
     if (enabled != session->isUTPEnabled)
     {
@@ -2324,7 +2315,6 @@ static void toggleLPDImpl(void* data)
 void tr_sessionSetLPDEnabled(tr_session* session, bool enabled)
 {
     assert(tr_isSession(session));
-    assert(tr_isBool(enabled));
 
     if (enabled != session->isLPDEnabled)
     {
@@ -2560,7 +2550,6 @@ bool tr_blocklistIsEnabled(tr_session const* session)
 void tr_blocklistSetEnabled(tr_session* session, bool isEnabled)
 {
     assert(tr_isSession(session));
-    assert(tr_isBool(isEnabled));
 
     session->isBlocklistEnabled = isEnabled;
 
@@ -2858,7 +2847,6 @@ bool tr_sessionIsTorrentDoneScriptEnabled(tr_session const* session)
 void tr_sessionSetTorrentDoneScriptEnabled(tr_session* session, bool isEnabled)
 {
     assert(tr_isSession(session));
-    assert(tr_isBool(isEnabled));
 
     session->isTorrentDoneScriptEnabled = isEnabled;
 }
@@ -2905,7 +2893,6 @@ void tr_sessionSetQueueEnabled(tr_session* session, tr_direction dir, bool is_en
 {
     assert(tr_isSession(session));
     assert(tr_isDirection(dir));
-    assert(tr_isBool(is_enabled));
 
     session->queueEnabled[dir] = is_enabled;
 }
@@ -2929,7 +2916,6 @@ void tr_sessionSetQueueStalledMinutes(tr_session* session, int minutes)
 void tr_sessionSetQueueStalledEnabled(tr_session* session, bool is_enabled)
 {
     assert(tr_isSession(session));
-    assert(tr_isBool(is_enabled));
 
     session->stalledEnabled = is_enabled;
 }
index 4722f86b177f1e353106da29a6e0a3d1beb85f8e..d7f23914b6037606455169096b414d36ef726491 100644 (file)
@@ -273,8 +273,6 @@ void tr_ctorInitTorrentWanted(tr_ctor const* ctor, tr_torrent* tor)
 
 void tr_ctorSetDeleteSource(tr_ctor* ctor, bool deleteSource)
 {
-    assert(tr_isBool(deleteSource));
-
     ctor->doDelete = deleteSource;
     ctor->isSet_delete = true;
 }
@@ -301,8 +299,6 @@ bool tr_ctorGetDeleteSource(tr_ctor const* ctor, bool* setme)
 
 void tr_ctorSetSave(tr_ctor* ctor, bool saveInOurTorrentsDir)
 {
-    assert(tr_isBool(saveInOurTorrentsDir));
-
     ctor->saveInOurTorrentsDir = saveInOurTorrentsDir;
 }
 
@@ -317,7 +313,6 @@ void tr_ctorSetPaused(tr_ctor* ctor, tr_ctorMode mode, bool isPaused)
 
     assert(ctor != NULL);
     assert(mode == TR_FALLBACK || mode == TR_FORCE);
-    assert(tr_isBool(isPaused));
 
     args = &ctor->optionalArgs[mode];
     args->isSet_paused = true;
index 3e91614007cb1c8500ce16dc628aba1b42bc1b8b..049afe8156684603e567edf6b059b7ae96f5230a 100644 (file)
@@ -3817,7 +3817,6 @@ void tr_torrentsQueueMoveBottom(tr_torrent** torrents_in, int n)
 static void torrentSetQueued(tr_torrent* tor, bool queued)
 {
     assert(tr_isTorrent(tor));
-    assert(tr_isBool(queued));
 
     if (tr_torrentIsQueued(tor) != queued)
     {
index 2a914c3a65e1b5380e4d68073b1b366daf2dce2c..57ed77be5baba773ad3f5ceea04c2f2a2e86d60f 100644 (file)
@@ -34,18 +34,9 @@ extern "C"
 ***/
 
 #include <inttypes.h> /* uintN_t */
+#include <stdbool.h> /* bool */
 #include <time.h> /* time_t */
 
-#if !defined(__cplusplus)
-#ifdef HAVE_STDBOOL_H
-#include <stdbool.h>
-#elif !defined(__bool_true_false_are_defined)
-#define bool uint8_t
-#define true 1
-#define false 0
-#endif
-#endif
-
 #define SHA_DIGEST_LENGTH 20
 #define TR_INET6_ADDRSTRLEN 46
 
@@ -1895,12 +1886,6 @@ static inline bool tr_isDirection(tr_direction d)
     return d == TR_UP || d == TR_DOWN;
 }
 
-/** @brief Sanity checker to test that a bool is true or false */
-static inline bool tr_isBool(bool b)
-{
-    return b == 1 || b == 0;
-}
-
 #ifdef __cplusplus
 }
 #endif