Blender, Monitoring, First Hit

Recently, we wrote an article Just for Fun: PVS-Studio Team Came Up With Monitoring Quality of Some Open Source Projects. Now it’s time to write about the errors found. I will not write about all shortcomings that I notice, but only about the interesting ones. My goal is to promote static analysis methodology rather than to describe as many warnings as possible.

What we have today is a simple typical error about a pointless check in code. PVS-Studio reports it as follows: V547: Expression ‘sad == NULL’ is always false. screen_ops.c 1339.

static int area_dupli_invoke(
bContext *C, wmOperator *op, const wmEvent *event)
{
ScrArea *area = CTX_wm_area(C);
if (event && event->customdata) {
sActionzoneData *sad = event->customdata;
if (sad == NULL) {
return OPERATOR_PASS_THROUGH;
}
area = sad->sa1;
}
....
}

The nested condition of another condition is never met, as this pointer has already been checked before. As a result, the function will never return the OPERATOR_PASS_THROUGH status. It’s hard for me to say how crucial this bug is. However, if the authors wanted to return this status, it is unlikely that they wanted it to be dead code :).

Co-founder of the PVS-Studio project. Microsoft MVP in the ‘Developer Technologies’ nomination and PhD in Physics and Mathematics.