fix: PVS-Studio V522 mark false

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov
2024-08-03 23:00:10 +03:00
committed by Pugemon
parent 4efa574eec
commit 3621e7ce1b
18 changed files with 81 additions and 81 deletions
+6 -6
View File
@@ -122,8 +122,8 @@ static int l_get_x(lua::State* L) {
if (vox == nullptr) {
return lua::pushivec3_stack(L, 1, 0, 0);
}
auto def = level->content->getIndices()->blocks.get(vox->id);
if (!def->rotatable) {
auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer
if (!def->rotatable) { //-V522
return lua::pushivec3_stack(L, 1, 0, 0);
} else {
const CoordSystem& rot = def->rotations.variants[vox->state.rotation];
@@ -139,8 +139,8 @@ static int l_get_y(lua::State* L) {
if (vox == nullptr) {
return lua::pushivec3_stack(L, 0, 1, 0);
}
auto def = level->content->getIndices()->blocks.get(vox->id);
if (!def->rotatable) {
auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer
if (!def->rotatable) { //-V522
return lua::pushivec3_stack(L, 0, 1, 0);
} else {
const CoordSystem& rot = def->rotations.variants[vox->state.rotation];
@@ -156,8 +156,8 @@ static int l_get_z(lua::State* L) {
if (vox == nullptr) {
return lua::pushivec3_stack(L, 0, 0, 1);
}
auto def = level->content->getIndices()->blocks.get(vox->id);
if (!def->rotatable) {
auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer
if (!def->rotatable) { //-V522
return lua::pushivec3_stack(L, 0, 0, 1);
} else {
const CoordSystem& rot = def->rotations.variants[vox->state.rotation];
+8 -8
View File
@@ -53,34 +53,34 @@ static DocumentNode getDocumentNode(lua::State* L, int idx = 1) {
static int l_menu_back(lua::State* L) {
auto node = getDocumentNode(L);
auto menu = dynamic_cast<Menu*>(node.node.get());
menu->back();
auto menu = dynamic_cast<Menu*>(node.node.get()); //FIXME: Potentional null pointer
menu->back(); //-V522
return 0;
}
static int l_menu_reset(lua::State* L) {
auto node = getDocumentNode(L);
auto menu = dynamic_cast<Menu*>(node.node.get());
menu->reset();
auto menu = dynamic_cast<Menu*>(node.node.get()); //FIXME: Potentional null pointer
menu->reset(); //-V522
return 0;
}
static int l_textbox_paste(lua::State* L) {
auto node = getDocumentNode(L);
auto box = dynamic_cast<TextBox*>(node.node.get());
auto box = dynamic_cast<TextBox*>(node.node.get()); //FIXME: Potentional null pointer
auto text = lua::require_string(L, 2);
box->paste(util::str2wstr_utf8(text));
box->paste(util::str2wstr_utf8(text)); //-V522
return 0;
}
static int l_container_add(lua::State* L) {
auto docnode = getDocumentNode(L);
auto node = dynamic_cast<Container*>(docnode.node.get());
auto node = dynamic_cast<Container*>(docnode.node.get()); //FIXME: Potentional null pointer
auto xmlsrc = lua::require_string(L, 2);
try {
auto subnode =
guiutil::create(xmlsrc, docnode.document->getEnvironment());
node->add(subnode);
node->add(subnode); //-V522
UINode::getIndices(subnode, docnode.document->getMapWriteable());
} catch (const std::exception& err) {
throw std::runtime_error(err.what());
+1 -1
View File
@@ -51,7 +51,7 @@ static int l_hud_open_block(lua::State* L) {
}
auto def = content->getIndices()->blocks.get(vox->id);
auto assets = engine->getAssets();
auto layout = assets->get<UiDocument>(def->uiLayout);
auto layout = assets->get<UiDocument>(def->uiLayout);//FIXME: Potentional null pointer //-V522
if (layout == nullptr) {
throw std::runtime_error("block '" + def->name + "' has no ui layout");
}