Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings (-Wsign-compare) when building with DEBUG_ADDRMAN #11577

Merged
merged 1 commit into from Jan 29, 2018

Conversation

practicalswift
Copy link
Contributor

Fix warnings when building with DEBUG_ADDRMAN.

Warnings prior to this commit:

addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (vRandom.size() != nTried + nNew)
        ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
        if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
                                   ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (setTried.size() != nTried)
        ~~~~~~~~~~~~~~~ ^  ~~~~~~
addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (mapNew.size() != nNew)
        ~~~~~~~~~~~~~ ^  ~~~~
4 warnings generated.

Warnings prior to this commit:

```
addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (vRandom.size() != nTried + nNew)
        ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
        if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
                                   ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (setTried.size() != nTried)
        ~~~~~~~~~~~~~~~ ^  ~~~~~~
addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (mapNew.size() != nNew)
        ~~~~~~~~~~~~~ ^  ~~~~
4 warnings generated.
```
@promag
Copy link
Member

promag commented Nov 5, 2017

Other options are to cast (int) mapNew.size() or to change nNew and nTried types.

@practicalswift
Copy link
Contributor Author

Anyone willing to review? :-)

@sipa
Copy link
Member

sipa commented Nov 22, 2017

Concept ACK

@practicalswift
Copy link
Contributor Author

Any chance of merge or should I close? :-)

@laanwj
Copy link
Member

laanwj commented Jan 29, 2018

utACK 6eddd43

@laanwj laanwj merged commit 6eddd43 into bitcoin:master Jan 29, 2018
laanwj added a commit that referenced this pull request Jan 29, 2018
…ADDRMAN

6eddd43 Fix warnings when building with DEBUG_ADDRMAN (practicalswift)

Pull request description:

  Fix warnings when building with `DEBUG_ADDRMAN`.

  Warnings prior to this commit:

  ```
  addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (vRandom.size() != nTried + nNew)
          ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
  addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
          if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
                                     ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
  addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (setTried.size() != nTried)
          ~~~~~~~~~~~~~~~ ^  ~~~~~~
  addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (mapNew.size() != nNew)
          ~~~~~~~~~~~~~ ^  ~~~~
  4 warnings generated.
  ```

Tree-SHA512: 0316faecfe95066d2c9a0b6b3960086e43824f21a67086a895ea45fbce1327f8d6df5945fe923c2dbe4efce430bc1384d515d317c3930d97d24965e507cf734d
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 26, 2020
… DEBUG_ADDRMAN

6eddd43 Fix warnings when building with DEBUG_ADDRMAN (practicalswift)

Pull request description:

  Fix warnings when building with `DEBUG_ADDRMAN`.

  Warnings prior to this commit:

  ```
  addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (vRandom.size() != nTried + nNew)
          ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
  addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
          if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
                                     ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
  addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (setTried.size() != nTried)
          ~~~~~~~~~~~~~~~ ^  ~~~~~~
  addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (mapNew.size() != nNew)
          ~~~~~~~~~~~~~ ^  ~~~~
  4 warnings generated.
  ```

Tree-SHA512: 0316faecfe95066d2c9a0b6b3960086e43824f21a67086a895ea45fbce1327f8d6df5945fe923c2dbe4efce430bc1384d515d317c3930d97d24965e507cf734d
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 31, 2020
…UG_ADDRMAN

Summary:
6eddd43 Fix warnings when building with DEBUG_ADDRMAN (practicalswift)

Pull request description:

  Fix warnings when building with `DEBUG_ADDRMAN`.

  Warnings prior to this commit:

  ```
  addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (vRandom.size() != nTried + nNew)
          ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
  addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
          if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
                                     ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
  addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (setTried.size() != nTried)
          ~~~~~~~~~~~~~~~ ^  ~~~~~~
  addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (mapNew.size() != nNew)
          ~~~~~~~~~~~~~ ^  ~~~~
  4 warnings generated.
  ```

---

Backport of Core [[bitcoin/bitcoin#11577 | PR11577]]

Test Plan:
`#define DEBUG_ADDRMAN 1` in src/addrman.h
  ninja all check

get no warnings

Reviewers: #bitcoin_abc, PiRK

Reviewed By: PiRK

Differential Revision: https://reviews.bitcoinabc.org/D8206
@practicalswift practicalswift deleted the DEBUG_ADDRMAN-warnings branch April 10, 2021 19:33
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Jun 24, 2021
… DEBUG_ADDRMAN

6eddd43 Fix warnings when building with DEBUG_ADDRMAN (practicalswift)

Pull request description:

  Fix warnings when building with `DEBUG_ADDRMAN`.

  Warnings prior to this commit:

  ```
  addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (vRandom.size() != nTried + nNew)
          ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
  addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
          if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
                                     ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
  addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (setTried.size() != nTried)
          ~~~~~~~~~~~~~~~ ^  ~~~~~~
  addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (mapNew.size() != nNew)
          ~~~~~~~~~~~~~ ^  ~~~~
  4 warnings generated.
  ```

Tree-SHA512: 0316faecfe95066d2c9a0b6b3960086e43824f21a67086a895ea45fbce1327f8d6df5945fe923c2dbe4efce430bc1384d515d317c3930d97d24965e507cf734d
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Feb 11, 2022
… DEBUG_ADDRMAN

6eddd43 Fix warnings when building with DEBUG_ADDRMAN (practicalswift)

Pull request description:

  Fix warnings when building with `DEBUG_ADDRMAN`.

  Warnings prior to this commit:

  ```
  addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (vRandom.size() != nTried + nNew)
          ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
  addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
          if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
                                     ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
  addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (setTried.size() != nTried)
          ~~~~~~~~~~~~~~~ ^  ~~~~~~
  addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (mapNew.size() != nNew)
          ~~~~~~~~~~~~~ ^  ~~~~
  4 warnings generated.
  ```

Tree-SHA512: 0316faecfe95066d2c9a0b6b3960086e43824f21a67086a895ea45fbce1327f8d6df5945fe923c2dbe4efce430bc1384d515d317c3930d97d24965e507cf734d
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants