Skip to content

Commit 4888ae5

Browse files
zmurbjornmu
authored andcommitted
Bug#35847193 Cluster code fails to compile on Ubuntu23.10
Fix alloc-size-larger-than warning in Qmgr by explicitly only allocate non-zero sized array. Compiler can not deduce that that is actually always the case. The confusing warning fixed is: storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp: In member function 'initData': storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp:204:60: warning: argument 1 value '18446744073709551615' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=] 204 | receivedProcessInfo = new ProcessInfo[numOfApiAndMgmNodes]; | ^ /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/new:128:26: note: in a call to allocation function 'operator new []' declared here 128 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^ Change-Id: Ie7aea5e8681db1c420d2a0e80d1cda8319f74a2b
1 parent 4b994b0 commit 4888ae5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ class Qmgr : public SimulatedBlock {
618618
Timer ka_send_timer;
619619

620620
Int16 processInfoNodeIndex[MAX_NODES];
621-
ProcessInfo * receivedProcessInfo;
621+
ProcessInfo * receivedProcessInfo = nullptr;
622622
Uint16 max_api_node_id;
623623

624624
NdbNodeBitmask cfailedNodes;

storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,15 @@ void Qmgr::initData()
201201
break;
202202
}
203203
}
204-
receivedProcessInfo = new ProcessInfo[numOfApiAndMgmNodes];
204+
/*
205+
* In reality there must be at least one MGM, API, and, DB node.
206+
* And numOfApiAndMgmNodes will be betweeen 2 and 254 (MAX_NODES - 2).
207+
*
208+
* If in future one can have DB only cluster it is ok to leave
209+
* receivedProcessInfo as nullptr since it is only used for MGM and API.
210+
*/
211+
if (likely(numOfApiAndMgmNodes > 0))
212+
receivedProcessInfo = new ProcessInfo[numOfApiAndMgmNodes];
205213
}//Qmgr::initData()
206214

207215
void Qmgr::initRecords()

0 commit comments

Comments
 (0)