Explictly cast calculation to int, to allow std::min to work. #2695

pull robbak wants to merge 1 commits into bitcoin:master from robbak:init_cpp-explicit_cast changing 1 files +1 −1
  1. robbak commented at 12:44 pm on May 25, 2013: contributor

    When compiling on FreeBSD, the calculation here returns an unsigned int. This causes a compile-time error with std::min, which cannot compare signed with unsigned integers.

    This pull inserts an explicit cast, treating the calculated value as signed, keeping the compiler happy.

  2. Explictly cast calculation to int, to allow std::max to work. 03f498080a
  3. jgarzik commented at 1:13 pm on May 25, 2013: contributor
    ACK
  4. BitcoinPullTester commented at 1:33 pm on May 25, 2013: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/03f498080a813850e1a3addf2c555450aa5e65c1 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
  5. sipa commented at 2:41 am on May 30, 2013: member
    ACK
  6. sipa referenced this in commit d315eb0a76 on May 30, 2013
  7. sipa merged this on May 30, 2013
  8. sipa closed this on May 30, 2013

  9. in src/init.cpp: in 03f498080a
    529@@ -530,7 +530,7 @@ bool AppInit2(boost::thread_group& threadGroup)
    530     // Make sure enough file descriptors are available
    531     int nBind = std::max((int)mapArgs.count("-bind"), 1);
    532     nMaxConnections = GetArg("-maxconnections", 125);
    533-    nMaxConnections = std::max(std::min(nMaxConnections, FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS), 0);
    534+    nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
    


    luke-jr commented at 9:35 pm on July 15, 2013:
    This looks like it will create problems if nBind+MIN_CORE_FILEDESCRIPTORS are > FD_SETSIZE… Not that I see any reason someone should bind more than 1024 ports…
  10. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-30 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me