|
| 1 | +From: Sergio Durigan Junior <sergio.durigan@canonical.com> |
| 2 | +Date: Tue, 9 Aug 2022 17:49:23 -0400 |
| 3 | +Subject: Fix -Werror=alloc-size-larger-than on GCC 12 |
| 4 | + |
| 5 | +Author: Sergio Durigan Junior <sergiodj@ubuntu.com> |
| 6 | +Forwarded: yes, https://github.com/squid-cache/squid/pull/1118 |
| 7 | +--- |
| 8 | + src/SquidConfig.h | 2 +- |
| 9 | + src/pconn.cc | 2 +- |
| 10 | + src/pconn.h | 2 +- |
| 11 | + src/store/Disks.cc | 2 +- |
| 12 | + 4 files changed, 4 insertions(+), 4 deletions(-) |
| 13 | + |
| 14 | +diff --git a/src/SquidConfig.h b/src/SquidConfig.h |
| 15 | +index feabdf1..6b3cca5 100644 |
| 16 | +--- a/src/SquidConfig.h |
| 17 | ++++ b/src/SquidConfig.h |
| 18 | +@@ -61,7 +61,7 @@ public: |
| 19 | + ~DiskConfig() { delete[] swapDirs; } |
| 20 | + |
| 21 | + RefCount<SwapDir> *swapDirs = nullptr; |
| 22 | +- int n_allocated = 0; |
| 23 | ++ unsigned int n_allocated = 0; |
| 24 | + int n_configured = 0; |
| 25 | + /// number of disk processes required to support all cache_dirs |
| 26 | + int n_strands = 0; |
| 27 | +diff --git a/src/pconn.cc b/src/pconn.cc |
| 28 | +index 62e5411..d30726d 100644 |
| 29 | +--- a/src/pconn.cc |
| 30 | ++++ b/src/pconn.cc |
| 31 | +@@ -167,7 +167,7 @@ IdleConnList::clearHandlers(const Comm::ConnectionPointer &conn) |
| 32 | + void |
| 33 | + IdleConnList::push(const Comm::ConnectionPointer &conn) |
| 34 | + { |
| 35 | +- if (size_ == capacity_) { |
| 36 | ++ if ((unsigned int) size_ == capacity_) { |
| 37 | + debugs(48, 3, "growing idle Connection array"); |
| 38 | + capacity_ <<= 1; |
| 39 | + const Comm::ConnectionPointer *oldList = theList_; |
| 40 | +diff --git a/src/pconn.h b/src/pconn.h |
| 41 | +index 85e44e5..b8f07d9 100644 |
| 42 | +--- a/src/pconn.h |
| 43 | ++++ b/src/pconn.h |
| 44 | +@@ -80,7 +80,7 @@ private: |
| 45 | + Comm::ConnectionPointer *theList_; |
| 46 | + |
| 47 | + /// Number of entries theList can currently hold without re-allocating (capacity). |
| 48 | +- int capacity_; |
| 49 | ++ unsigned int capacity_; |
| 50 | + ///< Number of in-use entries in theList |
| 51 | + int size_; |
| 52 | + |
| 53 | +diff --git a/src/store/Disks.cc b/src/store/Disks.cc |
| 54 | +index 4e8710a..f9c3171 100644 |
| 55 | +--- a/src/store/Disks.cc |
| 56 | ++++ b/src/store/Disks.cc |
| 57 | +@@ -685,7 +685,7 @@ allocate_new_swapdir(Store::DiskConfig *swap) |
| 58 | + swap.swapDirs = new SwapDir::Pointer[swap.n_allocated]; |
| 59 | + } |
| 60 | + |
| 61 | +- if (swap.n_allocated == swap.n_configured) { |
| 62 | ++ if (swap.n_allocated == (size_t) swap.n_configured) { |
| 63 | + swap.n_allocated <<= 1; |
| 64 | + const auto tmp = new SwapDir::Pointer[swap.n_allocated]; |
| 65 | + for (int i = 0; i < swap.n_configured; ++i) { |
0 commit comments