How Do You Assess the Quality of the Blender Code?

Andrey Karpov
2 min readMar 5, 2021

Recently, we have been monitoring changes in the Blender project, or rather, what errors appear in the new code. This compels us to write notes and discuss interesting topics. Here is one question I’d like to cover.

Based on the post “PVS-Studio, Blender: Series of Notes on Advantages of Regular Static Analysis of Code”, one of the readers suggested answering the question: how do you assess the quality of the Blender code?

It’s hard to say. I see a flow of errors and flaws, but I don’t strive to react to all of them. I was waiting for a couple of interesting bugs that will look nice in a note. For example, this time I clicked on one of the recent runs from February 25, 2021. I see 3 warnings. Two of them are unclear to me right off the bat, and I don’t feel like dealing with them. For simplicity, I consider them false positives. The following remains:

typedef enum {
....
T_OVERRIDE_CENTER = 1 << 18,
....
} eTFlag;
....
if (t->flag | T_OVERRIDE_CENTER) {

PVS-Studio warning: V617: Consider inspecting the condition. The ‘T_OVERRIDE_CENTER’ argument of the ‘|’ bitwise operation contains a non-zero value. transform_convert.c. 85

There is an obvious mistake here. The condition will always be true, as authors used the wrong operator. Correct version:

if (t->flag & T_OVERRIDE_CENTER) {

But earlier I looked at this error and closed the report. I’m not going to run around with every such bug and show it to everyone :). I will get bored to describe things like these. What’s more, subscribers will just switch off.

Did I tell the project developers? No. It’s their job to ensure the code quality. I can’t help everyone. There are thousands of open projects around me, where new bugs appear every day. Even if I want to, I won’t fix much. It is much more productive to spread the word about the methodology of static code analysis. Then such errors will immediately be found by the project developers themselves.

If I constantly see more and more errors in Blender, why cannot I say that its code quality is low? Answer: the project is large. The larger the project, the more errors appear in the code. So I don’t presume to judge in this case. Still static analysis won’t hurt this project anyway.

P.S. Let me unleash my inner villain for a moment. This time I won’t urge Blender developers to start using PVS-Studio. Otherwise, I will lose the chance to detect errors in this challenging project, and I will have to look for another one :).

--

--

Andrey Karpov

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