incorrect MP, PIC rendering?
The code for both plugin/core/gvrender_core_mp.c and plugin/core/gvrender_core_pic.c contains this curious snippet:
for (int i = 0; i < count; i++) {
gvprintf(job, " %d", i % (count + 1) ? 1 : 0); /* -1 on all */
}
I say curious because the mod operation here is a no-op. i % (count + 1)
is equivalent to i
because we know i < count
due to the loop guard.
The MP, PIC, and FIG code from the core plugin is near-identical in parts, seemingly having been copy-pasted from each other. Yet the FIG code has instead:
for (int i = 0; i < count; i++) {
gvprintf(job, " %d", i % (count - 1) ? 1 : 0); /* -1 on all */
}
Looking at the history, 372085cc altered the MP and PIC code, but not the FIG code. The commit message is imprecise but I think it is referencing !1316 (closed), !1317 (closed), and #1576 (closed). Of these, !1316 (closed) is responsible for this change. But without the author quoting the scan-build
logs, I don’t know what problem this is supposed to address. scan-build
is a static analysis tool, but this change appears to have altered the code from something vaguely reasonable to something that actually would be flagged by a static analyzer.
@truenorth do you recall what all this was about?