AI review of 2026-11-22_10-09-55-d16a499e2c54-results.txt PR: #9016 https://github.com/cppcheck-opensource/cppcheck/pull/9016 Tested: d16a499e2c546f4a32016a9a06112a67d2947223 Merge base: 415be9ca7e74488abc8788169d8ec7f2a8ce11da Reviewed: 2026-11-22 20:27:19 UTC Model: claude-opus-5-5 (effort high) Results: 50 reviewed of 400 in the report (random sample) Verdicts: 48 improvement, 2 regression Tokens: 225321 input, 115056 cache read, 7344 cache write, 38434 output The verdicts are written by AI and can be wrong. ---- 1 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/a/anfo/anfo_0.98.orig.tar.gz Result: your anfo-0.98/src/anfo-elk.cc:177:15: style: Variable 'o' can be declared as pointer to const [constVariablePointer] Explanation: The loop only reads through `o`: `*o` is passed by value to `obj_to_stream(Object o)`, and only the pointer itself is incremented. Declaring it `const Object *o = argv` would compile and behave the same, so the warning is a true positive. Main missed it because `isVariableChanged` did not subtract the dereference when checking the function argument. The PR fixes that, so this is a newly found true positive. ---- 2 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/a/anfo/anfo_0.98.orig.tar.gz Result: your anfo-0.98/src/anfo-elk.cc:373:15: style: Variable 'o' can be declared as pointer to const [constVariablePointer] Explanation: In p_tee, `o` walks over `argv` and is only dereferenced to pass `*o` to `obj_to_stream`. The sibling call `obj_to_stream( inpo )` passes a plain `Object`, and `fn` inside that function is used as a value (`TYPE(fn)`, `Get_Integer(fn)`, `Truep(fn)`). So the parameter is very likely `Object` by value. If so, `const Object *o` compiles fine: assigning from `argv` and comparing against `argv+argc` both work. The PR now checks the dereferenced pointee at the right indirection level, so by-value use is no longer wrongly treated as modification. This looks like a new true positive. Confidence is medium because the signature of `obj_to_stream` is not shown. ---- 3 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/a/anfo/anfo_0.98.orig.tar.gz Result: your anfo-0.98/src/anfo-elk.cc:384:15: style: Variable 'o' can be declared as pointer to const [constVariablePointer] Explanation: In the loop, `o` is only compared, incremented, and dereferenced as `*o` to pass an `Object` to `obj_to_stream`. In Elk code, `Object` is normally passed by value, as the WRAP signatures in this file show. So `*o` is never modified, and `o` can be declared as `const Object *`. The PR now subtracts the dereference count when checking indirection for function arguments, which lets Cppcheck see this. The warning is probably a new true positive. The caveat: `obj_to_stream`'s signature is not shown; if it took a non-const `Object&`, the warning would be a false positive. ---- 4 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/b/blupimania/blupimania_1.6.3.orig.tar.gz Result: your blupimania-1.6.3/src/argtable3/argtable3.c:4246:60: style: Parameter 'node' can be declared as pointer to const [constParameterPointer] Explanation: In trex_matchnode, `node` is only read (`node->type`, `node->left`, `node->right`, `node->next`). The recursive calls and the trex_matchclass calls receive `&exp->_nodes[node->left]`, not `node` itself; `node->left` is only an index into `exp->_nodes`. Before the PR, the dereference inside that index expression made Cppcheck think `node`'s pointee could be modified. The PR now subtracts the dereferences, which fixes that. From the shown code and the known trex implementation, `node` is never written through, so it can be `const TRexNode*`. The new warning is therefore a true positive. Confidence is medium because the rest of the function is not shown. ---- 5 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/chibicc/chibicc_1.0.25.orig.tar.gz Result: your chibicc-1.0.25/parse.c:2073:11: style: Variable 'mem' can be declared as pointer to const [constVariablePointer] Explanation: In struct_initializer1, 'mem' is only reassigned (from init->ty->members, struct_designator() and mem->next), compared against NULL, and read through (mem->idx, mem->next). Nothing is ever written through the pointer. Assigning a Member* to a const Member* is valid C, so 'const Member *mem' would compile. The new constVariablePointer warning is a true positive that the corrected indirection handling in isVariableChanged now finds. ---- 6 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/c/chibicc/chibicc_1.0.25.orig.tar.gz Result: your chibicc-1.0.25/parse.c:2106:86: style: Parameter 'mem' can be declared as pointer to const [constParameterPointer] Explanation: In struct_initializer2, 'mem' is only used to read members: mem->next for the loop advance and mem->idx as an array index. Reassigning the pointer itself (mem = mem->next) does not modify the pointee, and Member* converts implicitly to const Member*. So the parameter can indeed be 'const Member *mem', and the new warning is a true positive. Before the PR, the read of mem->idx inside the argument init->children[mem->idx] passed to initializer2 was wrongly treated as a possible modification. The PR now subtracts the dereference count when checking whether the variable is changed, which removes this false negative. ---- 7 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/c/clementine/clementine_1.4.1+git27-g658f34ec4+dfsg.orig.tar.xz Result: your Clementine-1.4.1-27-g658f34ec4/src/ui/albumcovermanager.cpp:505:27: style: Variable 'item' can be declared as pointer to const [constVariablePointer] Explanation: Inside the loop, `item` is only dereferenced as `*item` and passed to `ItemHasCover`. In Clementine that function takes `const QListWidgetItem&`, so nothing is changed through the pointer and `const QListWidgetItem* item` would compile. The PR now subtracts the dereference count when checking whether the variable is changed. Passing `*item` to a const reference is therefore no longer treated as a modification of the pointee, so the new constVariablePointer warning looks like a true positive. Confidence is medium because the signature of `ItemHasCover` is not shown here. ---- 8 / 50 ---- Verdict: REGRESSION (low confidence) Package: https://ftp.debian.org/debian/pool/main/d/dicom3tools/dicom3tools_1.00~20240118131615.orig.tar.bz2 Result: your dicom3tools_1.00.snapshot.20240118131615/appsrc/dcfile/dccidump.cc:44:40: style: Parameter 'list' can be declared as pointer to const [constParameterPointer] Explanation: `list` is only used as `(*list)[tag]`, i.e. through `AttributeList::operator[]`, and the returned `Attribute*` is passed to a non-const parameter. The warning is only correct if `operator[]` is a const member function. This codebase uses almost no const (non-const `Attribute*` and `ElementDictionary*` parameters everywhere), so `operator[]` is quite possibly non-const. In that case, changing `list` to a pointer to const would not compile. The PR now computes the indirection as `indirect - derefs`, so `*list` is checked at indirection 0. When the class definition is not visible, the operator call is no longer treated as a possible modification. Before the PR, Cppcheck was conservative here. The new warning is therefore likely a false positive, though the `AttributeList` header is not shown. ---- 9 / 50 ---- Verdict: IMPROVEMENT (low confidence) Package: https://ftp.debian.org/debian/pool/main/d/dicom3tools/dicom3tools_1.00~20240118131615.orig.tar.bz2 Result: your dicom3tools_1.00.snapshot.20240118131615/appsrc/dcfile/dcsrdump.cc:28:40: style: Parameter 'list' can be declared as pointer to const [constParameterPointer] Explanation: processCodeSequenceItem only reads from the list: it calls (*list)[Tag] three times and passes each result to a logging function. The list itself is never modified. The PR now subtracts the dereference count when checking the member call on (*list), so `*list` is no longer treated as modified just because it is dereferenced. If dicom3tools' AttributeList::operator[] is const (as a lookup accessor normally is, returning Attribute*), the parameter can be `const AttributeList*` and the new warning is a true positive. The class header is not shown, so the const-ness of operator[] could not be checked; hence low confidence. ---- 10 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/f/freerdp2/freerdp2_2.11.7+dfsg1.orig.tar.xz Result: your FreeRDP-2.11.7/libfreerdp/gdi/gdi.c:535:40: style: Parameter 'context' can be declared as pointer to const. However it seems that 'gdi_set_bounds' is a callback function, if 'context' is declared with const you might also need to cast function pointer(s). [constParameterCallback] FreeRDP-2.11.7/libfreerdp/gdi/gdi.c:1147:22: note: You might need to cast the function pointer here FreeRDP-2.11.7/libfreerdp/gdi/gdi.c:535:40: note: Parameter 'context' can be declared as pointer to const Explanation: In gdi_set_bounds, 'context' is only read: it is null-checked and its 'gdi' member is copied into a local 'rdpGdi*'. The modifications (setting the clip region) happen through gdi->drawing->hdc, which is reached through pointers stored in the context, not through the rdpContext object itself. With 'const rdpContext* context', 'context->gdi' is 'rdpGdi* const', so 'rdpGdi* gdi = context->gdi;' still compiles. The parameter can therefore be declared pointer to const, so this is a true positive. The PR's change to subtract derefs in isVariableChanged stops writes through dereferenced members from counting as changes to the parameter. The message also correctly notes that the function is used as a callback. ---- 11 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/f/freerdp2/freerdp2_2.11.7+dfsg1.orig.tar.xz Result: your FreeRDP-2.11.7/libfreerdp/gdi/graphics.c:324:45: style: Parameter 'context' can be declared as pointer to const. However it seems that 'gdi_Glyph_SetBounds' is a callback function, if 'context' is declared with const you might also need to cast function pointer(s). [constParameterCallback] FreeRDP-2.11.7/libfreerdp/gdi/graphics.c:428:20: note: You might need to cast the function pointer here FreeRDP-2.11.7/libfreerdp/gdi/graphics.c:324:45: note: Parameter 'context' can be declared as pointer to const Explanation: In gdi_Glyph_SetBounds, 'context' is only read: it is null-checked, and the pointer member context->gdi is copied into a local. The later modification through gdi->drawing->hdc in gdi_SetClipRgn changes objects reached through that pointer member, not *context itself. In C, 'const rdpContext*' still lets you write 'rdpGdi* gdi = context->gdi'. So the parameter could be pointer to const, and the callback note about the function-pointer cast is accurate. The PR changes isVariableChanged to subtract the number of dereferences from the indirection level, which removes the over-approximation that previously hid this warning. This is a new true positive. ---- 12 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/f/freerdp2/freerdp2_2.11.7+dfsg1.orig.tar.xz Result: your FreeRDP-2.11.7/libfreerdp/gdi/graphics.c:393:43: style: Parameter 'context' can be declared as pointer to const. However it seems that 'gdi_Glyph_EndDraw' is a callback function, if 'context' is declared with const you might also need to cast function pointer(s). [constParameterCallback] FreeRDP-2.11.7/libfreerdp/gdi/graphics.c:427:18: note: You might need to cast the function pointer here FreeRDP-2.11.7/libfreerdp/gdi/graphics.c:393:43: note: Parameter 'context' can be declared as pointer to const Explanation: In gdi_Glyph_EndDraw, 'context' is only read: it checks 'context->gdi', copies it to 'gdi', and calls gdi_SetNullClipRgn(gdi->drawing->hdc). The only modification happens through further pointer dereferences (gdi->drawing->hdc), not to the rdpContext object itself. Because C constness is shallow, 'const rdpContext* context' would still compile. The PR's change to isVariableChanged (subtracting derefs from the indirect level) makes Cppcheck correctly see that the pointee of 'context' is not modified. The new constParameterCallback warning is therefore a true positive, and it correctly notes the callback assignment at line 427. ---- 13 / 50 ---- Verdict: IMPROVEMENT (low confidence) Package: https://ftp.debian.org/debian/pool/main/g/golang-github-pzhin-go-sophia/golang-github-pzhin-go-sophia_0.0~git20250609.a1b0f01.orig.tar.xz Result: your sophia/database/sd_read.h:45:38: style: Parameter 'ref' can be declared as pointer to const [constParameterPointer] Explanation: The source file was not available, so this verdict relies partly on recall of the upstream Sophia code. The column (38) matches the expected signature `sd_read_page(sdread *i, sdindexpage *ref)`. In that function `ref` appears only to be read: fields such as `ref->size`, `ref->offset` and `ref->sizeorigin` are passed by value into calls. Before the PR, these dereferenced members were checked with the full indirection level, so passing them by value counted as a possible modification of `*ref`. The PR subtracts the derefs, which is the same fix as the `v.push_back(*p)` test case in the PR. The new constParameterPointer warning is therefore most likely a true positive. Confidence is low because the code could not be checked here. ---- 14 / 50 ---- Verdict: IMPROVEMENT (low confidence) Package: https://ftp.debian.org/debian/pool/main/g/golang-github-pzhin-go-sophia/golang-github-pzhin-go-sophia_0.0~git20250609.a1b0f01.orig.tar.xz Result: your sophia/std/ss_buf.h:152:18: style: Parameter 'b' can be declared as pointer to const [constParameterPointer] Explanation: The source was not available, so this relies on recalling sophia's ss_buf.h. Line 152, column 18 most likely matches `ss_bufset(ssbuf *b, int size, int i, char *buf, int bufsize)`. That function only asserts on `b->s`/`b->p` and calls `memcpy(b->s + size * i, buf, bufsize)`. This writes through the member pointer `b->s` but never modifies the struct `*b`. Declaring the parameter `const ssbuf *b` would still compile, because `b->s` becomes `char * const` and its target stays writable. So the new constParameterPointer warning looks like a true positive. The PR's change to `pindirect` (subtracting derefs) is what stops a write through a member pointer from counting as a change to `*b`. Confidence is low because the code could not be checked directly. ---- 15 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/l/lugaru/lugaru_1.2.orig.tar.xz Result: your lugaru-1.2/Source/Math/XYZ.cpp:230:68: style: Parameter 'n' can be declared as pointer to const [constParameterPointer] Explanation: Inside this `LineFacetd` overload, `n` is only read. It is dereferenced as `n->x`, `n->y` and `n->z`, and `*n` is passed to `PointInTriangle`. Line 224 calls `PointInTriangle(p, n, ...)` with a non-pointer `XYZ`, so the normal parameter is taken by value. Passing `*n` therefore cannot modify the pointee. The PR now accounts for the dereference when checking whether the variable is changed, so it correctly finds that `n` can be `const XYZ*`. This is a new true positive. ---- 16 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/madlib/madlib_1.3.0.orig.tar.gz Result: your madlib-1.3.0/Adapt/utils/NodalDataManager.cc:428:26: style: Variable 'vec' can be declared as pointer to const [constVariablePointer] Explanation: `vec` is only dereferenced to pass `*vec` to `result->push_back`, which takes a const reference, so `vec` can be `const vector*`. This is the same pattern as the PR's new test (`v.push_back(*p)`). Before the PR, `isVariableChanged` did not subtract the dereference when checking the container method call, so the use counted as a modification and the warning was missed. The new warning is a true positive. ---- 17 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/magic/magic_8.3.703.orig.tar.gz Result: your magic-8.3.703/lef/lefRead.c:2490:15: style: Parameter 'lefl' can be declared as pointer to const [constParameterPointer] Explanation: In the visible part of `LefGrowVia`, `lefl` is only read, through `lefl->type`, which is used as an index into `DBTypeLongNameTbl` for a `LefError` message. The rest of the function appears to change only `currect`. So `lefl` could be `const lefLayer *`, and the new warning looks like a true positive. The PR stops counting reads through a dereference as possible changes to the pointer's target (`indirect - derefs`), which fixes this kind of false negative. Confidence is medium because the end of the function is not shown. ---- 18 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/magic/magic_8.3.703.orig.tar.gz Result: your magic-8.3.703/utils/malloc.c:206:36: style: Parameter 'm1' can be declared as pointer to const [constParameterPointer] Explanation: `freeMagic1_end` only reads `*m1` and passes that pointer value to `free()` or `freeMagicLegacy()`. It never assigns to `*m1`. Freeing the pointee does not modify `*m1` itself, so `m1` could be declared as `free_magic1_t const *` (pointer to const) and the code would still compile. Before the PR, the dereference was counted at the wrong indirection level, so `free(*m1)` was treated as a write to `*m1`. The PR subtracts the dereference count, which fixes this, and the new warning is a true positive. Users may still keep the signature non-const for symmetry with `freeMagic1`, but the diagnostic itself is correct. ---- 19 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-connector-odbc/mariadb-connector-odbc_3.2.9.orig.tar.gz Result: your mariadb-connector-odbc-3.2.9/driver/ma_typeconv.cpp:769:11: style: Variable 'IndicatorPtr' can be declared as pointer to const [constVariablePointer] Explanation: `IndicatorPtr` is only assigned from a cast and then read: it is null-checked and dereferenced as `*IndicatorPtr` to pass a value to `MADB_ProcessIndicator`. That function appears to take `SQLLEN` by value, and the pointee is never written through. So the pointer could be `const SQLLEN *`, and the new constVariablePointer warning is a true positive. The PR now subtracts the dereference count when computing indirection in `isVariableChanged`, so passing `*p` by value no longer counts as modifying the pointer. This new warning is a direct result of that fix. ---- 20 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mlterm/mlterm_3.9.4.orig.tar.gz Result: your mlterm-3.9.4/vtemu/vt_line.c:1288:45: style: Parameter 'line' can be declared as pointer to const [constParameterPointer] Explanation: `vt_convert_char_index_to_col` only reads `line->num_chars` and `line->num_filled_chars`, and passes `line->chars + count` to `vt_char_cols`. If `line` were `const vt_line_t *`, `line->chars` would become `vt_char_t * const`. The pointee is still non-const, so passing it to a non-const pointer parameter still compiles, and `*line` itself is never modified. The PR's fix to the pointer indirection in `isVariableChanged` stops treating this member-pointer argument as a write to `*line`. The new warning is therefore a valid true positive. ---- 21 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mlterm/mlterm_3.9.4.orig.tar.gz Result: your mlterm-3.9.4/vtemu/vt_line.c:1325:45: style: Parameter 'line' can be declared as pointer to const [constParameterPointer] Explanation: vt_convert_col_to_char_index only reads members of 'line': num_chars, num_filled_chars, and the pointer value line->chars. The only possible write is through line->chars, but that member is a pointer (vt_char_t *chars). Passing line->chars + char_index to vt_char_cols can only change the pointed-to chars, not *line itself. With 'const vt_line_t *line', line->chars still has type vt_char_t*, so the code compiles unchanged. The PR now drops the extra indirection level when the variable is reached through a member access, which makes this warning a correct new true positive. ---- 22 / 50 ---- Verdict: REGRESSION (low confidence) Package: https://ftp.debian.org/debian/pool/main/m/mlterm/mlterm_3.9.4.orig.tar.gz Result: your mlterm-3.9.4/vtemu/vt_line.c:1757:38: style: Parameter 'line' can be declared as pointer to const [constParameterPointer] Explanation: `vt_line_clear_picture` changes the line's character cells. It gets a cell via `vt_get_picture_char(line->chars + count)` and overwrites it with `vt_char_copy`. Making `line` const would still compile, because only the data behind the member pointer `chars` is written. Cppcheck normally avoids this warning when the object's owned data is modified through it, and main did not report it. The new warning appears to be a side effect of the `pindirect`/`derefs` change in `isVariableChanged`, not the targeted fix (`v.push_back(*p)`). It is misleading: the function semantically mutates the line. ---- 23 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/mptp/mptp_0.2.5.orig.tar.gz Result: your mptp-0.2.5/src/auto.c:215:14: style: Variable 'query' can be declared as pointer to const [constVariablePointer] Explanation: `query` is only null-checked and read via `query->index`. The array element `tipnodes[query->index]` is what gets passed to the modifying function, not `*query`, so `query` can be `const pair_t *` (in C, assigning the `void*` result to it is fine). The PR's derefs fix in isVariableChanged correctly stops treating the indexed use as a modification of `*query`. This is a new true positive. ---- 24 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/n/netradiant/netradiant_1.5.0+git20260429+dfsg.orig.tar.xz Result: your netradiant-1.5.0+git20260429/libs/picomodel/picomodel.c:1868:16: style: Variable 'i' can be declared as pointer to const [constVariablePointer] Explanation: `i` iterates over `indices.data` and is only read through: `*i <= maxIndex`, `maxIndex = *i`, `vertices.indices.data[*i]`, plus `i != indices.last` and `i - indices.data`. Nothing is written through `*i`. The only write is to `normals[i - indices.data]`, which uses `i` merely to compute an index. Declaring it `const picoIndex_t* i` compiles fine in C, including the assignment, the comparison and the pointer subtraction. The new constVariablePointer warning is a true positive that main missed, because it wrongly treated the write to `normals[...]` as a change of `*i`. ---- 25 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/netradiant/netradiant_1.5.0+git20260429+dfsg.orig.tar.xz Result: your netradiant-1.5.0+git20260429/radiant/scenegraph.cpp:215:31: style: Either there is a missing override/final keyword, or the parameter 'instance' can be declared as pointer to const [constParameterPointer] Explanation: `insert()` only dereferences `instance` to pass `*instance` to `graph_tree_model_insert()`. In netradiant that function takes `const scene::Instance&` (from `treemodel.h`, which this file includes), so nothing is written through the pointer. Before the PR, the deref was checked at the wrong indirection level, so the pointer was wrongly treated as modified. That is exactly the case the PR fixes (compare the `push_back(*p)` test). The method is really an override of a virtual in `Instantiable::Observer`, but the base class is not visible to cppcheck. Cppcheck therefore uses its hedged wording, which correctly points out the missing `override` keyword as the alternative. This is a newly found true positive with an appropriate message. ---- 26 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/netradiant/netradiant_1.5.0+git20260429+dfsg.orig.tar.xz Result: your netradiant-1.5.0+git20260429/radiant/scenegraph.cpp:219:30: style: Either there is a missing override/final keyword, or the parameter 'instance' can be declared as pointer to const [constParameterPointer] Explanation: `erase()` only dereferences `instance` and passes `*instance` to `graph_tree_model_erase()`. In NetRadiant that function appears to take a `const scene::Instance&`, so the pointee is never modified. This is the same pattern as the PR's new test (`v.push_back(*p)`). The fix stops counting the dereference twice when checking whether the argument is changed, so this is a former false negative now reported. Since `erase()` likely overrides a virtual in `Instantiable::Observer`, the message correctly says the real issue may be a missing `override` keyword. I could not verify the callee's signature from the code shown, so confidence is medium. ---- 27 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/ngtcp2/ngtcp2_1.24.0.orig.tar.xz Result: your ngtcp2-1.24.0/lib/ngtcp2_ksl.c:46:68: style: Parameter 'blk' can be declared as pointer to const [constParameterPointer] Explanation: `blk->keys` is a pointer member: line 82 assigns to it, so it cannot be an array. `memcpy(blk->keys + ..., key, ...)` writes only through that pointer and never modifies the `ngtcp2_ksl_blk` object itself. With `const ngtcp2_ksl_blk *blk`, `blk->keys` would have type `uint8_t * const`, which is still a valid writable destination for `memcpy`. The code would therefore compile, so the new constParameterPointer warning is technically a true positive. The PR's derefs adjustment lets Cppcheck see that the write goes through the member pointer rather than to the struct. One could argue the key buffer is logically owned by `blk`, but by Cppcheck's rules this warning is correct. ---- 28 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/p/pd-cyclone/pd-cyclone_0.9.4+ds.orig.tar.xz Result: your porres-pd-cyclone-173ea9f/cyclone_objects/binaries/audio/delay.c:125:14: style: Variable 'in2' can be declared as pointer to const [constVariablePointer] Explanation: `in2` is a signal-inlet pointer that is only read in the code shown: `*in2` is compared at line 132 and passed by value (as `t_floatarg`) to `delay_delay` at line 134. Nothing in the visible code writes through it, so declaring it `const t_float *` is valid. Before the PR, the dereferenced argument was checked at the wrong indirection level, so the pointer looked modified. Subtracting the derefs fixes that and exposes this true positive. The rest of the function is not shown, which limits confidence, though delay-time inlets are normally read-only. ---- 29 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/p/pd-cyclone/pd-cyclone_0.9.4+ds.orig.tar.xz Result: your porres-pd-cyclone-173ea9f/cyclone_objects/binaries/control/funbuff.c:684:24: style: Variable 'c' can be declared as pointer to const [constVariablePointer] Explanation: In funbuff_cut, 'c' is only read through: `c->c_pairsz` is read, and `c->c_pairs+i` is passed to funbuff_delete. The clipboard has a variable size and the code tracks allocation, so c_pairs is most likely a `t_atom *` pointer member. If so, declaring `const t_funbuffcom *c` only makes the pointer member itself const, not the atoms it points to. Passing it to a non-const `t_atom*` parameter still compiles and nothing is modified through 'c'. The PR now subtracts the dereferences when tracking indirection through member access, so this new warning is likely a true positive (a former false negative). Confidence is medium because the struct definition is not shown: if c_pairs were an array member, the warning would be a false positive. ---- 30 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize32/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:24167:84: style: Variable 'arg3' can be declared as pointer to const [constVariablePointer] Explanation: In this SWIG wrapper, 'arg3' is a pointer to a boost::shared_ptr. It is assigned from either a cast of jarg3 or &tempnull3. Its only other use is '(boost::shared_ptr<...> const &)*arg3', which passes the pointee as a const reference. The pointee is never modified, so declaring 'arg3' as a pointer to const would compile and is correct. The PR fixed how dereferences are counted in isVariableChanged, which exposes this true positive. The code is generated, so users may not act on it, but the warning itself is accurate. ---- 31 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize32/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:25547:86: style: Variable 'arg3' can be declared as pointer to const [constVariablePointer] Explanation: `arg3` is a `value_type*` that is assigned once and then only dereferenced and cast to `boost::shared_ptr<...> const &` before being passed to `doAdd`. Nothing is ever modified through the pointer. Declaring it as `const value_type*` would compile, since both `&tempnull3` and the cast pointer convert implicitly. The PR now accounts for the dereference (`indirect - derefs`) when checking whether the pointee is changed, so this new warning is a true positive. The code is SWIG-generated, but the warning itself is correct. ---- 32 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize32/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:38400:86: style: Variable 'arg3' can be declared as pointer to const [constVariablePointer] Explanation: 'arg3' is only assigned the address of a local (&temp3 or &tempnull3). Its only other use is '*arg3', cast to 'intrusive_ptr<...> const &' and passed by const reference. The pointee is never modified, so 'arg3' could be declared as a pointer to const and the code would still compile. Before the PR, the dereference inside the cast was wrongly treated as modifying the pointee, which suppressed the warning. The new warning is a true positive. ---- 33 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize32/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:77717:67: style: Variable 'arg3' can be declared as pointer to const [constVariablePointer] Explanation: `arg3` is assigned from a cast of `jarg3`, null-checked, and then only dereferenced as `(RobotRaconteur::ServiceInfo2Wrapped const &)*arg3` when passed to the doAdd helper. Nothing is ever modified through it, so declaring it `const value_type *arg3` would compile and be correct. The PR's `pindirect = indirect - derefs` fix stops treating a dereferenced pointer passed by const reference as a possible modification of the pointer. That turns a previously missed `constVariablePointer` into a true positive. ---- 34 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize32/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:80297:48: style: Variable 'arg2' can be declared as pointer to const [constVariablePointer] Explanation: `arg2` is assigned once from `jarg2`, checked for null, and then used only as `(RobotRaconteur::ServiceSubscriptionClientID const &)*arg2` when calling the helper. Nothing is ever modified through the pointer, so it really can be declared as a pointer to const. Before the PR, `isVariableChanged` passed the pointer's indirection level to the function-call check without subtracting the dereference in `*arg2`. That made the call look like it might modify the pointee, which hid this warning. The fix subtracts the derefs, so this is a new true positive. ---- 35 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize32/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:85582:55: style: Variable 'arg2' can be declared as pointer to const [constVariablePointer] Explanation: `arg2` is assigned from a cast, null-checked, and then only used as `(ServiceSubscriptionFilterAttribute const &)*arg2` when passed to setValue. The pointee is never modified, so `arg2` can be declared as a pointer to const; assigning a `T*` to it still compiles. The PR fixes the indirection handling when a dereferenced pointer is used. This is a newly found true positive. ---- 36 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize64/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:19356:85: style: Variable 'arg3' can be declared as pointer to const [constVariablePointer] Explanation: `arg3` is only dereferenced and passed as `(boost::shared_ptr<...> const &)*arg3` to the doAdd helper. It is never written through. Both values assigned to it, a reinterpreted `value_type*` and `&tempnull3`, convert implicitly to a `const value_type*`. So `arg3` can be declared as pointer to const, and the new warning is correct. The PR's fix to pindirect (subtracting the deref count) lets Cppcheck see that the dereferenced value is only bound to a const reference. The code is SWIG-generated, but the diagnostic is still accurate. ---- 37 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize64/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:22454:78: style: Variable 'arg3' can be declared as pointer to const [constVariablePointer] Explanation: `arg3` is assigned from `jarg3`, null-checked, and then only dereferenced and explicitly cast to `ConstantDefinition_StructField const &` before being passed to the function. Nothing is ever written through it, so it could be declared as a pointer to const. Assigning the non-const pointer obtained from the cast to it would still compile. The PR fixes the indirection count when a dereferenced pointer is passed to a function (`pindirect = indirect - derefs`). Cppcheck therefore no longer wrongly treats `*arg3` as possibly modified, and this is a newly found true positive. ---- 38 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize64/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:77734:67: style: Variable 'arg3' can be declared as pointer to const [constVariablePointer] Explanation: `arg3` is assigned once from `jarg3` and then only read: it is null-checked and dereferenced as `(RobotRaconteur::ServiceInfo2Wrapped const &)*arg3` when passed to `doAdd`. Nothing is modified through the pointer, so declaring it `const value_type *` would compile, since assigning a `value_type*` to it is allowed. The PR now subtracts dereferences when computing the indirection level, so it no longer mistakes `*arg3` passed by const reference for a modification. This is a new true positive, even though the file is SWIG-generated code. ---- 39 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize64/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:80314:48: style: Variable 'arg2' can be declared as pointer to const [constVariablePointer] Explanation: In this function, 'arg2' is assigned from the cast of jarg2, checked for null, and then only used as '(RobotRaconteur::ServiceSubscriptionClientID const &)*arg2'. The pointee is never modified, so declaring it 'const RobotRaconteur::ServiceSubscriptionClientID *' would compile and is correct. The PR now subtracts the dereference count when checking whether the variable is changed, so this true positive is no longer missed. The code is SWIG-generated, so users may not act on it, but the warning itself is accurate. ---- 40 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize64/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:81813:105: style: Variable 'arg3' can be declared as pointer to const [constVariablePointer] Explanation: In this SWIG-generated function, `arg3` is assigned once (from a cast of `jarg3` or `&tempnull3`). After that it is only dereferenced as `(boost::shared_ptr<...> const &)*arg3` and passed to the doAdd helper. Nothing is ever written through the pointer, so `arg3` could be declared as a pointer to const; the assignment from a non-const pointer would still compile. Main missed this, and the PR's change to the indirection handling after dereferences now catches it. The new warning is a true positive. It is in generated code, which users rarely edit, but the diagnostic itself is correct. ---- 41 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/Java/swigwordsize64/com/robotraconteur/RobotRaconteurJavaJAVA_wrap.cxx:85145:82: style: Variable 'arg3' can be declared as pointer to const [constVariablePointer] Explanation: In this SWIG wrapper, `arg3` is assigned from a `value_type **` cast, null-checked, and then used only as `(RobotRaconteur::ServiceSubscriptionFilterAttribute const &)*arg3` in the call. Nothing writes through `arg3`, so declaring it `const value_type *arg3` would compile and behave the same, and the warning is a true positive. Main probably missed it because it did not subtract the dereference when checking whether the pointer is changed in a function call, which the PR fixes. The warning lands in generated code, but it is still correct. ---- 42 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/NET/swigwordsize64/RobotRaconteurNETCSHARP_wrap.cxx:53866:37: style: Variable 'arg1' can be declared as pointer to const [constVariablePointer] Explanation: `arg1` points to the local `tmpDur1`. Its only later use is `(boost::posix_time::time_duration const &)*arg1`, passed to `new_RobotRaconteur_WallTimer`. The pointee is never modified, so `arg1` could be declared `const boost::posix_time::time_duration*`. The PR now subtracts the dereference count when checking whether the variable is changed, so Cppcheck correctly sees that `*arg1` is only read. This is a new true positive. ---- 43 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/r/robotraconteur/robotraconteur_1.2.9.orig.tar.gz Result: your robotraconteur-1.2.9/generated_src/NET/swigwordsize64/RobotRaconteurNETCSHARP_wrap.cxx:77846:30: style: Variable 'arg1' can be declared as pointer to const [constVariablePointer] Explanation: `arg1` is only null-checked and then dereferenced, and the result is cast to `NodeInfo2 const&` before being passed to the Repeat helper. Nothing is written through the pointer, so declaring it `const RobotRaconteur::NodeInfo2 *` compiles fine. Main likely missed this because `isVariableChanged` did not subtract the dereference from the indirection level. The new constVariablePointer warning is a true positive, although the file is SWIG-generated. ---- 44 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/sympow/sympow_2.023.7.orig.tar.bz2 Result: your sympow-2.023.7/QD.c:485:30: style: Parameter 'v' can be declared as pointer to const [constParameterPointer] Explanation: In sympow, QDpoly is a struct holding `int deg` and a heap pointer `QD *coeff`; initQDpoly allocates `coeff` and delQDpoly frees it. QDpoly_intround only reads `(*v).deg` and `(*v).coeff`, then writes through `coeff[i]` into the heap buffer. It never changes the struct that `v` points to, so `const QDpoly *v` compiles and does not change behaviour. The new warning is therefore a technically correct true positive, consistent with how Cppcheck treats shallow const for pointer members. Confidence is medium because the struct definition is not shown, and because some users may find it odd that a function which modifies the polynomial's data is flagged. ---- 45 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/x/xwayland/xwayland_24.1.15.orig.tar.xz Result: your xwayland-24.1.15/Xext/xselinux_ext.c:154:20: style: Variable 'pSid' can be declared as pointer to const [constVariablePointer] Explanation: In ProcSELinuxGetCreateContext, 'pSid' is only read. It is assigned from a cast, then '*pSid' is passed by value to SELinuxSendContextReply. Nothing is ever written through 'pSid', so it can be declared as 'const security_id_t *'. The PR stops treating a dereferenced argument '*p' as if 'p' itself were passed with full indirection. That correctly finds this true positive, which was missed before. ---- 46 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/x/xwayland/xwayland_24.1.15.orig.tar.xz Result: your xwayland-24.1.15/render/picture.c:861:48: style: Parameter 'color' can be declared as pointer to const [constParameterPointer] Explanation: In CreateSolidPicture, 'color' is only read. '*color' is passed by value to xRenderColorToCard32, and 'color' is the source argument of memcpy. The pointee is never modified, so the parameter could be 'const xRenderColor *'. The PR's change to isVariableChanged subtracts dereferences when passing '*color' to a function, so a by-value use is no longer treated as a possible modification. That makes this a newly found true positive. ---- 47 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/z/zoitechat/zoitechat_2.19.1.orig.tar.xz Result: your zoitechat-2.19.1/src/fe-gtk/setup.c:1396:43: style: Parameter 'set' can be declared as pointer to const. However it seems that 'setup_entry_cb' is a callback function, if 'set' is declared with const you might also need to cast function pointer(s). [constParameterCallback] zoitechat-2.19.1/src/fe-gtk/setup.c:1456:9: note: You might need to cast the function pointer here zoitechat-2.19.1/src/fe-gtk/setup.c:1396:43: note: Parameter 'set' can be declared as pointer to const Explanation: In `setup_entry_cb`, `set` is only read: `set->extra` is used in comparisons, and `set` is passed to `setup_set_str`. The neighbouring helpers in this file take `const setting *`, and Cppcheck would treat `set` as modified if `setup_set_str` took a non-const pointer. So `set` is most likely never written through, and the pointer-to-const suggestion is correct. The message also correctly notes that the function is used as a callback (line 1456), so a cast may be needed. The PR fixes a dereference-counting false negative in `isVariableChanged`, which explains why this true positive now appears. Confidence is medium because the signature of `setup_set_str` is not shown. ---- 48 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/z/zsv/zsv_1.4.4.orig.tar.gz Result: your zsv-1.4.4/app/external/sqlite3/sqlite3.c:119780:49: style: Parameter 'pTab' can be declared as pointer to const [constParameterPointer] Explanation: `sqlite3FkReferences` only reads through `pTab`. It passes `&pTab->pSchema->fkeyHash` and `pTab->zName` to `sqlite3HashFind(const Hash*, const char*)`. `pSchema` is a pointer member, so the `fkeyHash` it points to is not part of `*pTab`. Declaring the parameter `const Table *pTab` therefore compiles and changes nothing. The PR's deref-aware indirection fix lets Cppcheck see this, so the new warning is a true positive. ---- 49 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/z/zsv/zsv_1.4.4.orig.tar.gz Result: your zsv-1.4.4/app/external/sqlite3/sqlite3.c:137004:39: style: Parameter 'pTrigger' can be declared as pointer to const [constParameterPointer] Explanation: `tableOfTrigger` only reads `pTrigger->pTabSchema` and `pTrigger->table`. It passes `&pTrigger->pTabSchema->tblHash` to `sqlite3HashFind(const Hash*, const char*)`. That address is reached through the `pTabSchema` pointer member, so it is not part of the Trigger object. Declaring the parameter `const Trigger *pTrigger` would therefore compile and change nothing. The new constParameterPointer warning is a true positive, made possible by the more precise dereference-aware indirection in `isVariableChanged`. ---- 50 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/z/zsv/zsv_1.4.4.orig.tar.gz Result: your zsv-1.4.4/app/external/sqlite3/sqlite3.c:69757:12: style: Variable 'pPage' can be declared as pointer to const [constVariablePointer] Explanation: In moveToLeftmost, pPage is assigned from pCur->pPage and then only read: `->leaf`, `->nCell`, and `findCell(pPage, ...)`. `findCell` is a macro that reads `aData`, `maskPage` and `aCellIdx`. Its result goes to get4byte, which takes `const u8*`. Nothing is written through pPage, and assigning `MemPage*` to `const MemPage*` is valid C, so declaring it `const MemPage *pPage` would compile. The new constVariablePointer warning is a true positive. Main probably missed it because the old indirection handling treated the member access through the pointer as a modification.