Bug #55978
closed
rgw_lua_request.cc warning: the address of ‘rgw::IAM::Policy::statements’ will never be NULL
Added by Casey Bodley almost 2 years ago.
Updated almost 2 years ago.
Description
[297/358] Building CXX object src/rgw/CMakeFiles/rgw_a.dir/rgw_lua_request.cc.o
src/rgw/rgw_lua_request.cc: In static member function ‘static int rgw::lua::request::PolicyMetaTable::IndexClosure(lua_State*)’:
src/rgw/rgw_lua_request.cc:497:48: warning: the address of ‘rgw::IAM::Policy::statements’ will never be NULL [-Waddress]
497 | create_metatable<StatementsMetaTable>(L, &(policy->statements));
| ^~~~~~~~~~~~~~~~~~~~~
In file included from src/rgw/rgw_common.h:29,
from src/rgw/rgw_service.h:14,
from src/rgw/services/svc_zone.h:6,
from src/rgw/rgw_lua_request.cc:5:
src/rgw/rgw_iam_policy.h:511:26: note: ‘rgw::IAM::Policy::statements’ declared here
511 | std::vector<Statement> statements;
| ^~~~~~~~~~
this warning is strange, since the code does not check for NULL or nullptr on that pointer.
maybe this is because the upvalues (this pointer is one of them) are used as a template parameter pack?
i see two overloads of this function in rgw_lua_utils.h:
template<typename MetaTable, typename... Upvalues>
void create_metatable(lua_State* L, bool toplevel, Upvalues... upvalues)
template<typename MetaTable>
void create_metatable(lua_State* L, bool toplevel, std::unique_ptr<typename MetaTable::Type>& ptr)
it looks like this warning is complaining that we're passing &(policy->statements)
as bool toplevel
, which (because it never evaluates to NULL) would always evaluate to toplevel = true
ok. in this case it is a bug. the value of "top-level" should just be "false" (since this is not a top-level field).
the pointer should be passed as the first upvalue
- Status changed from New to Fix Under Review
- Pull request ID set to 46617
- Status changed from Fix Under Review to Resolved
Also available in: Atom
PDF