New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix errors found by professional static code analyzer #10726
Comments
|
I also checked Minetest with TscanCode static analyzer found on Github: https://github.com/Tencent/TscanCode. I think it is appropriate to post some results in this issue. You can see the full log at https://gist.github.com/akozlovskiy119/e7fe6160467a0d2abf2dcb0dff77927d. Interestingly, this analyzer also supports Lua, it may be worth checking minetest_game with it later.
void GenericCAO::step(float dtime, ClientEnvironment *env)
{
...
// Make sure m_is_visible is always applied
scene::ISceneNode *node = getSceneNode();
=> if (node)
node->setVisible(m_is_visible);
...
if (!getParent() && std::fabs(m_prop.automatic_rotate) > 0.001) {
// This is the child node's rotation. It is only used for automatic_rotate.
=> v3f local_rot = node->getRotation();
local_rot.Y = modulo360f(local_rot.Y - dtime * core::RADTODEG *
m_prop.automatic_rotate);
=> node->setRotation(local_rot);
}
...
}
MapBlockMesh::~MapBlockMesh()
{
for (scene::IMesh *m : m_mesh) {
=> if (m_enable_vbo && m)
for (u32 i = 0; i < m->getMeshBufferCount(); i++) {
scene::IMeshBuffer *buf = m->getMeshBuffer(i);
RenderingEngine::get_video_driver()->removeHardwareBuffer(buf);
}
=> m->drop();
m = NULL;
}
delete m_minimap_mapblock;
}
bool TextureSource::generateImagePart(std::string part_of_name,
video::IImage *& baseimg)
{
...
else if (str_starts_with(part_of_name, "[applyfiltersformesh"))
{
/* IMPORTANT: When changing this, getTextureForMesh() needs to be
* updated too. */
// Apply the "clean transparent" filter, if configured.
if (g_settings->getBool("texture_clean_transparent"))
=> imageCleanTransparent(baseimg, 127);
...
}
...
}
void imageCleanTransparent(video::IImage *src, u32 threshold)
{
=> core::dimension2d<u32> dim = src->getDimension();
...
}
void Server::handleCommand_Init2(NetworkPacket* pkt)
{
...
=> RemoteClient *client = getClient(peer_id, CS_InitDone);
// Keep client language for server translations
=> client->setLangCode(lang);
// Send active objects
{
PlayerSAO *sao = getPlayerSAO(peer_id);
=> if (client && sao)
SendActiveObjectRemoveAdd(client, sao);
}
...
// Warnings about protocol version can be issued here
=> if (client->net_proto_version < LATEST_PROTOCOL_VERSION) {
SendChatMessage(peer_id, ChatMessage(CHATMESSAGE_TYPE_SYSTEM,
L"# Server: WARNING: YOUR CLIENT'S VERSION MAY NOT BE FULLY COMPATIBLE "
L"WITH THIS SERVER!"));
}
}
static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer,
const TileSpec &tile, const TileDef &tiledef, video::SColor color,
u8 material_type, u32 shader_id, bool backface_culling,
const TextureSettings &tsettings)
{
...
=> if (use_autoscale && layer->texture) {
...
if (layer->material_flags & MATERIAL_FLAG_ANIMATION) {
...
=> tiledef.animation.determineParams(layer->texture->getOriginalSize(),
&frame_count, &frame_length_ms, NULL);
...
}
...
for (int i = 0; i < frame_count; i++) {
...
tiledef.animation.getTextureModifer(os,
=> layer->texture->getOriginalSize(), i);
...
}
...
}
|
“FT_RENDER_MODE_NORMAL” is by itself a false positive, minetest/src/irrlicht_changes/CGUITTFont.h Lines 359 to 360 in 0750047
|
Not so long ago Minetest was checked by the professional static code analyzer called PVS-Studio. The developers published some of the errors they have found in their blog: https://www.viva64.com/en/b/0751/#ID2E6FF31CDC. I think Minetest developers should take them into account and, if possible, fix them.
Please note that I am not a representative of PVS-Studio. I came across this article by chance and thought I should inform developers about the errors. The blog also recommends a full analysis but I'm not sure Minetest can afford it.
The text was updated successfully, but these errors were encountered: