Skip to content

Commit

Permalink
mongodb: Fix type mitmatch found with clang16
Browse files Browse the repository at this point in the history
Use std::size to avoid explicit typecasting

Signed-off-by: Khem Raj <[email protected]>
  • Loading branch information
kraj committed Mar 4, 2023
1 parent c20ae41 commit dd42a62
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 81eabea4e4da55cddfe8bcfcbc3759fa90948254 Mon Sep 17 00:00:00 2001
From: Khem Raj <[email protected]>
Date: Fri, 3 Mar 2023 14:13:29 -0800
Subject: [PATCH] Fix type mismatch on 32bit arches

std::set::size returns an unsigned integral type.
std::max call therefore gets (unsigned int, unsigned long) here.
Type of both arguments is not same, so its ambigous
and there is no matching std::max implementation for mismatching
arguments. std::max expects both input variables to be of
same type, max(int,int) etc..

Fixes
src/mongo/util/processinfo_linux.cpp:424:16: error: no matching function for call to 'max'
return std::max(socketIds.size(), 1ul);

Upstream-Status: Submitted [https://jira.mongodb.org/browse/SERVER-74633]
Signed-off-by: Khem Raj <[email protected]>
---
src/mongo/util/processinfo_linux.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/src/mongo/util/processinfo_linux.cpp
+++ b/src/mongo/util/processinfo_linux.cpp
@@ -421,7 +421,7 @@ public:

// On ARM64, the "physical id" field is unpopulated, causing there to be 0 sockets found. In
// this case, we default to 1.
- return std::max(socketIds.size(), 1ul);
+ return std::max(static_cast<unsigned long>(socketIds.size()), 1ul);
}

/**
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ SRC_URI = "git://github.com/mongodb/mongo.git;branch=v4.4;protocol=https \
file://0001-The-std-lib-unary-binary_function-base-classes-are-d.patch \
file://0001-free_mon-Include-missing-cstdint.patch \
file://0001-apply-msvc-workaround-for-clang-16.patch \
file://0001-Fix-type-mismatch-on-32bit-arches.patch \
"
SRC_URI:append:libc-musl ="\
file://0001-Mark-one-of-strerror_r-implementation-glibc-specific.patch \
Expand Down

0 comments on commit dd42a62

Please sign in to comment.