AI review of 2026-11-21_12-21-02-a3ddba5531b5-results.txt PR: #9016 https://github.com/cppcheck-opensource/cppcheck/pull/9016 Tested: a3ddba5531b5a95f7af9998227343b5de5ee2153 Merge base: 415be9ca7e74488abc8788169d8ec7f2a8ce11da Reviewed: 2026-11-21 19:57:09 UTC Model: claude-opus-5-5 (effort high) Results: 50 reviewed of 135 in the report (random sample) Verdicts: 48 improvement, 2 unclear Tokens: 155097 input, 77616 cache read, 1584 cache write, 38089 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/at-spi2-core/at-spi2-core_2.62.1.orig.tar.xz Result: your at-spi2-core-2.62.1/tests/at-spi2-atk/atk_test_accessible.c:391:48: style: Parameter 'obj' can be declared as pointer to const [constParameterPointer] Explanation: `atk_test_check_cache_cleared` only reads through `obj`. It compares `obj->cached_properties` and copies the pointer value `obj->children` into a local `GPtrArray *`. Copying the pointer is still allowed when `obj` points to const. The recursive call passes array elements, not `obj`, and the function is static and called directly. So `obj` can be declared `const AtspiAccessible *`. The new warning is a true positive that the corrected indirection handling now finds. ---- 2 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/d/darkplaces/darkplaces_0~20180908~beta1+git20260122.orig.tar.xz Result: your darkplaces-0~20180908~beta1+git20260122/prvm_edict.c:2979:10: style: Variable 'global' can be declared as pointer to const [constVariablePointer] Explanation: In PRVM_Global_f, 'global' is only read: it is null-checked, and global->type and global->ofs are read to build the arguments for PRVM_ValueString. global->ofs is an integer used as an offset into prog->globals, so the pointer passed on does not point into *global. Nothing writes through 'global', so it can be declared 'const mdef_t *'. The warning is a true positive. The PR now subtracts dereferences when tracking indirection through member access, so Cppcheck no longer wrongly treats this use as a modification. ---- 3 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/d/darkplaces/darkplaces_0~20180908~beta1+git20260122.orig.tar.xz Result: your darkplaces-0~20180908~beta1+git20260122/prvm_edict.c:903:11: style: Variable 'def' can be declared as pointer to const [constVariablePointer] Explanation: In PRVM_ED_WriteGlobals, 'def' is assigned &prog->globaldefs[i] and is then only read through: def->type, def->s_name, and def->ofs (as an array index). Nothing is ever written through 'def', so declaring it 'const mdef_t *' is valid. Main probably treated the use of def->ofs inside the non-const cast expression '(prvm_eval_t *)&prog->globals.fp[def->ofs]' as a possible modification. The PR fixes how indirection is counted for member access, so this true positive is now reported. ---- 4 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/d/dav-text/dav-text_0.9.0.orig.tar.gz Result: your dav-text_0.9.0.orig/features.c:109:16: style: Variable 'l' can be declared as pointer to const [constVariablePointer] Explanation: In `replace()`, `l` is only reassigned (`l = l->next`, `l = currentBuffer->head->next`), compared against `cursor.l`, `tail` and `currentLine->next`, and used to read `l->data`. `data` is a `char*` member, so writing through `t` (which points into `l->data`) does not modify the `struct line` itself. Declaring `l` as `const struct line *` would therefore compile. The PR now subtracts dereferences from the indirection level, so access through `l->data` is no longer treated as changing `*l`. This makes the new constVariablePointer warning a plausible true positive. Confidence is medium because the rest of the function after line 149 is not shown and could still assign to a member of `*l`. ---- 5 / 50 ---- Verdict: IMPROVEMENT (low confidence) Package: https://ftp.debian.org/debian/pool/main/d/dav-text/dav-text_0.9.0.orig.tar.gz Result: your dav-text_0.9.0.orig/features.c:34:16: style: Variable 'l' can be declared as pointer to const [constVariablePointer] Explanation: In `search()`, `l` is a `struct line *` used to walk the line list. In the visible code it is only read through: `l->length`, `l->data + offset` passed to `strstr` (whose argument is `const char*`), and `l->next`. It is also reassigned itself and compared, none of which changes the pointee. The PR changes `isVariableChanged` to subtract dereferences when computing the indirection level for member access, so `main` no longer wrongly treats these reads as modifying `*l`. The new constVariablePointer warning therefore looks like a recovered true positive. Confidence is low because the rest of the function (after line 74) is not shown and could write through `l` or assign it to a non-const pointer. ---- 6 / 50 ---- Verdict: UNCLEAR (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: The function `processCodeSequenceItem` only reads from `list` through `(*list)[Tag]` and passes the returned `Attribute*` on. Whether `list` can really be a pointer to const depends on whether `AttributeList::operator[]` is a const member function. That class is declared in a dicom3tools header that is not shown here, and Cppcheck may not have seen it either. The codebase is generally not const-correct, so a non-const `operator[]` is plausible; in that case the new warning would be a false positive. If the operator is const, the warning is a valid new true positive, like the `v.push_back(*p)` case the PR targets. There is not enough information to decide. ---- 7 / 50 ---- Verdict: UNCLEAR (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: The function only uses `list` through `(*list)[Tag]` lookups, and passes the returned `Attribute*` to another function. Whether `list` can really be pointer to const depends on whether `AttributeList::operator[]` is a const member. That class is declared in a dicom3tools header that is not shown. The PR now subtracts the dereference count when checking whether the pointer is changed. So the `*list` object is checked at indirection 0, and the operator call is presumably no longer treated as a modification. If `operator[]` is const, this is a correct new warning. If it is non-const, or Cppcheck simply cannot see the class, this is a false positive. The shown code is not enough to decide. ---- 8 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/d/dpdk/dpdk_25.11.4.orig.tar.xz Result: your dpdk-stable-25.11.4/drivers/net/gve/base/gve_adminq.c:296:54: style: Parameter 'priv' can be declared as pointer to const [constParameterPointer] Explanation: `gve_adminq_wait_for_cmd` only reads through `priv`: it calls `ioread32be(&priv->reg_bar0->adminq_event_counter)`. `reg_bar0` is a pointer member. Making `priv` a pointer to const only makes the pointer `priv->reg_bar0` itself const; the registers it points to stay writable. So `&priv->reg_bar0->...` keeps the same type, and `const struct gve_priv *priv` compiles. The function never modifies `*priv`, so the new constParameterPointer warning is a true positive. Main missed it because it handled the dereference level wrongly when the member access is followed by a dereference. ---- 9 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/d/dpdk/dpdk_25.11.4.orig.tar.xz Result: your dpdk-stable-25.11.4/drivers/net/hinic/base/hinic_pmd_mbox.c:271:54: style: Parameter 'mbox' can be declared as pointer to const [constParameterPointer] Explanation: `mbox_copy_header` only reads `mbox->data` and passes it to `__raw_writel`, which writes to the memory that pointer points to. It never modifies the `hinic_send_mbox` struct itself. If `mbox` were `const struct hinic_send_mbox *`, the member `data` would become a const pointer to non-const data, so the write would still compile. `mbox` can therefore be declared as pointer to const, and the new warning is a true positive. ---- 10 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/d/dpdk/dpdk_25.11.4.orig.tar.xz Result: your dpdk-stable-25.11.4/drivers/net/intel/ice/base/ice_common.c:6706:37: style: Parameter 'hw' can be declared as pointer to const [constParameterPointer] Explanation: `ice_get_port_max_cgd` only uses `hw` in `rd32(hw, GLGEN_MAC_LINK_TOPO)`. In DPDK's ice osdep, that macro expands to a read via `(char *)(hw)->hw_addr + reg`. This reads the `hw_addr` member and writes through it, but it never modifies `*hw` itself. So `hw` could be declared `const struct ice_hw *`. The PR fixes how dereferences reduce the indirection level in isVariableChanged, which lets Cppcheck see this. The new warning is a true positive. ---- 11 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/d/dpdk/dpdk_25.11.4.orig.tar.xz Result: your dpdk-stable-25.11.4/drivers/net/intel/ice/base/ice_dcb.c:147:39: style: Parameter 'hw' can be declared as pointer to const [constParameterPointer] Explanation: `ice_get_dcbx_status` only uses `hw` in `rd32(hw, PRTDCB_GENS)`. In DPDK's ice osdep, `rd32` reads through `(char *)(hw)->hw_addr + reg`. That reads the `hw_addr` member and dereferences the pointer it holds, but never writes through `hw` itself. With `const struct ice_hw *hw`, `hw->hw_addr` is still a non-const `u8 *` (only the member is const), so the code would still compile. The new constParameterPointer warning is therefore a true positive. Main missed it because the indirection level was not adjusted for the dereference inside the member access, which is exactly what the pull request fixes. ---- 12 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/d/dpdk/dpdk_25.11.4.orig.tar.xz Result: your dpdk-stable-25.11.4/drivers/net/intel/ice/base/ice_ptp_hw.c:978:49: style: Parameter 'hw' can be declared as pointer to const [constParameterPointer] Explanation: In DPDK's ice osdep, `wr32(hw, reg, val)` and `ice_flush(hw)` expand to MMIO accesses through `(char *)(hw)->hw_addr + reg`. They read the `hw_addr` member and write through the memory it points to (`rte_write32`/`rte_read32`); the `struct ice_hw` object itself is never modified. If `hw` were `const struct ice_hw *`, `hw->hw_addr` would become `u8 * const`, which still points to non-const data, so the code would compile unchanged. The PR now takes the dereference count into account when checking whether the variable is changed, so cppcheck no longer wrongly treats the write through the member pointer as modifying `*hw`. The new constParameterPointer warning is therefore technically correct: a true positive that main missed. ---- 13 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/d/dpdk/dpdk_25.11.4.orig.tar.xz Result: your dpdk-stable-25.11.4/drivers/net/intel/ice/ice_ethdev.c:1394:35: style: Parameter 'hw' can be declared as pointer to const [constParameterPointer] Explanation: In DPDK, `ICE_WRITE_REG`, `ICE_READ_REG` and `ice_flush` are macros. They expand to `rte_write32`/`rte_read32` on `(volatile uint32_t *)((char *)(hw)->hw_addr + reg)`. The function only reads the `hw_addr` member and writes through that pointer. It never modifies the `struct ice_hw` object itself. So `const struct ice_hw *hw` would compile, and the warning is technically correct. The PR subtracts the dereference count from the indirection level, which stops Cppcheck from wrongly treating the write through the pointed-to member as a change of `*hw`. This is a new true positive, consistent with how Cppcheck handles writes through pointer members. One caveat: register writes are semantically a mutation, so some users may not want this suggestion. ---- 14 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/d/dpdk/dpdk_25.11.4.orig.tar.xz Result: your dpdk-stable-25.11.4/drivers/net/intel/ice/ice_ethdev.c:4146:17: style: Variable 'hw' can be declared as pointer to const [constVariablePointer] Explanation: In `__vsi_queues_bind_intr`, `hw` is only passed to `ICE_WRITE_REG`. In DPDK's ice osdep, that macro writes through `(char *)(hw)->hw_addr + reg` using `rte_write32`. The write goes through the pointer stored in the `hw_addr` member; the `struct ice_hw` itself is never modified. Declaring `const struct ice_hw *hw` therefore compiles, because `hw->hw_addr` becomes `u8 * const` and casting it to `char *` is still allowed. The PR subtracts dereferences when it computes the indirection for member/function-argument uses, and that correctly stops treating this as a change to `*hw`. The new constVariablePointer warning is a valid (if stylistic) true positive. ---- 15 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/d/dpdk/dpdk_25.11.4.orig.tar.xz Result: your dpdk-stable-25.11.4/examples/vhost_blk/blk.c:42:50: style: Parameter 'bdev' can be declared as pointer to const [constParameterPointer] Explanation: In `vhost_bdev_blk_readwrite`, `bdev` is only used as `bdev->data + offset`, either as the memcpy destination or as its source. In DPDK's vhost_blk.h, `data` is declared as `uint8_t *data`, a pointer member rather than an array. With `const struct vhost_block_dev *bdev`, `bdev->data` becomes `uint8_t * const`, so the bytes it points to can still be written. Writing through `bdev->data` therefore does not modify `*bdev` itself. The function is static and called directly, not used as a callback, so making the parameter const compiles and is valid. Main missed this because it propagated the full indirection through the member dereference. The PR fixes that, so this is a newly found true positive. ---- 16 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/e/extundelete/extundelete_0.2.4.orig.tar.bz2 Result: your extundelete-0.2.4/src/extundelete.cc:1656:62: style: Parameter 'blocknr' can be declared as pointer to const. However it seems that 'first_block_is_allocated' is a callback function, if 'blocknr' is declared with const you might also need to cast function pointer(s). [constParameterCallback] extundelete-0.2.4/src/extundelete.cc:1691:79: note: You might need to cast the function pointer here extundelete-0.2.4/src/extundelete.cc:1656:62: note: Parameter 'blocknr' can be declared as pointer to const Explanation: In `first_block_is_allocated`, `blocknr` is only read: it is compared with `*blocknr != 0` and passed by value as `*blocknr` to `extundelete_test_block_bitmap`. Nothing is written through the pointer, so it could be `const blk64_t*`. Before the PR, Cppcheck did not subtract the dereference when the dereferenced pointer was passed as a function argument, so it wrongly treated the pointer as possibly modified. This is the same pattern as the PR's new test (#15203). The warning correctly uses the callback variant (`constParameterCallback`) and points to where the function pointer is used. This is a new true positive. ---- 17 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/k/knot-resolver/knot-resolver_6.5.0.orig.tar.xz Result: your knot-resolver-6.5.0/contrib/libngtcp2/ngtcp2/lib/ngtcp2_ksl.c:47:68: style: Parameter 'blk' can be declared as pointer to const [constParameterPointer] Explanation: `blk->keys` is a pointer member: line 84 assigns `blk->keys = (uint8_t *)blk + sizeof(*blk)`. `ksl_set_nth_key` only reads that pointer and passes it to `memcpy`, which writes into the memory it points to. The struct `*blk` itself is never modified. Declaring the parameter as `const ngtcp2_ksl_blk *blk` would therefore compile, so the new warning is technically correct. The PR now subtracts the `->` dereference when computing the indirection, so a write through the member's pointee no longer counts as a change to `*blk`. Some users may find it debatable, because the keys buffer lives in the same allocation as the block. ---- 18 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/k/knot-resolver/knot-resolver_6.5.0.orig.tar.xz Result: your knot-resolver-6.5.0/lib/cache/cdb_lmdb.c:822:18: style: Parameter 'key' can be declared as pointer to const. However it seems that 'cdb_match' is a callback function, if 'key' is declared with const you might also need to cast function pointer(s). [constParameterCallback] knot-resolver-6.5.0/lib/cache/cdb_lmdb.c:1043:3: note: You might need to cast the function pointer here knot-resolver-6.5.0/lib/cache/cdb_lmdb.c:822:18: note: Parameter 'key' can be declared as pointer to const Explanation: In `cdb_match`, `key` is only read. It is dereferenced once by value (`val_knot2mdb(*key)`), and `key->len` and `key->data` are read for the prefix check. Nothing writes through it in the shown code, and as far as I recall the rest of the function in knot-resolver is just cursor iteration and close, which does not touch `key`. Before the PR, passing `*key` by value was wrongly treated as a possible change to the pointer target, because the dereference was not subtracted from the indirection level. Now that is corrected, so the new constParameterCallback warning is a true positive. The note about the function-pointer cast is appropriate, since `cdb_match` is used as a callback. ---- 19 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/k/knot-resolver/knot-resolver_6.5.0.orig.tar.xz Result: your knot-resolver-6.5.0/lib/zonecut.c:66:41: style: Parameter 'v' can be declared as pointer to const. However it seems that 'free_addr_set_cb' is a callback function, if 'v' is declared with const you might also need to cast function pointer(s). [constParameterCallback] knot-resolver-6.5.0/lib/zonecut.c:273:25: note: You might need to cast the function pointer here knot-resolver-6.5.0/lib/zonecut.c:66:41: note: Parameter 'v' can be declared as pointer to const Explanation: `v` is a `trie_val_t*` (a `void**`). The function only reads `*v` and passes that value on to `free_addr_set`. That frees the memory `*v` points to, but `*v` itself is never written. So `v` could be `const trie_val_t *` (`void * const *`). Before the PR, passing `*p` to a non-const pointer parameter was wrongly treated as modifying the pointee of `p`. The PR now subtracts the dereference count, so this case is handled correctly. The warning is technically valid, and the constParameterCallback wording correctly notes the function-pointer cast needed for `trie_apply`. ---- 20 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/libc/libcgns/libcgns_4.5.0.orig.tar.gz Result: your CGNS-4.5.0/src/cg_ftoc.c:387:44: style: Parameter 'elementDataSize' can be declared as pointer to const [constParameterPointer] Explanation: In cg_section_general_write_f, 'elementDataSize' is only read: it is dereferenced and the value is passed to cg_section_general_write. Passing the dereferenced value does not modify the pointer target, so the parameter can be declared as pointer to const. Before the PR, isVariableChanged ignored the dereference when it checked the function call argument, which suppressed this warning. The PR fixes that by subtracting the derefs, so this is a new true positive. It is a Fortran binding, so changing the signature may matter little in practice, but the warning is technically correct. ---- 21 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/libc/libcgns/libcgns_4.5.0.orig.tar.gz Result: your CGNS-4.5.0/src/cg_ftoc.c:425:44: style: Parameter 'start' can be declared as pointer to const [constParameterPointer] Explanation: In cg_section_partial_write_f, 'start' is only dereferenced to pass its value (*start) by value to cg_section_partial_write. The pointee is never modified, so the parameter could be const cgsize_t*. Before the PR, Cppcheck treated '*start' as a function argument with the wrong indirection and assumed it might be changed. The PR now subtracts the derefs, which fixes that false negative. This is a true positive, the same pattern as the new test case #15203. Callers are Fortran bindings, but the warning is still technically correct. ---- 22 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/libc/libcgns/libcgns_4.5.0.orig.tar.gz Result: your CGNS-4.5.0/src/cg_ftoc.c:455:12: style: Parameter 'rmax' can be declared as pointer to const [constParameterPointer] Explanation: 'rmax' is only dereferenced and its value (*rmax) is passed by value to cg_elements_general_write. The pointee is never modified, so the parameter could be 'const cgsize_t *rmax'. The PR now subtracts the dereferences when computing the indirection level, so passing '*rmax' is no longer treated as a possible modification of the pointer target. This is a new true positive, matching the PR's test case (#15203). Because this is a Fortran binding the signature is fixed by convention, but adding const to the C side is still valid. ---- 23 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/libc/libcgns/libcgns_4.5.0.orig.tar.gz Result: your CGNS-4.5.0/src/cg_ftoc.c:467:12: style: Parameter 'rmax' can be declared as pointer to const [constParameterPointer] Explanation: 'rmax' is only dereferenced and its value (*rmax) is passed by value to cg_poly_elements_partial_write, so the pointee is never modified. The PR now subtracts the dereference count when checking whether the passed argument is changed, so Cppcheck correctly sees this as a read-only use and reports a valid constParameterPointer warning. This matches the new test case (#15203). Whether the Fortran-binding signature can be changed is a separate API concern; the diagnostic itself is correct. ---- 24 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/libc/libcgns/libcgns_4.5.0.orig.tar.gz Result: your CGNS-4.5.0/src/cg_ftoc.c:477:12: style: Parameter 'rmax' can be declared as pointer to const [constParameterPointer] Explanation: The parameter 'rmax' is only dereferenced, and its value '*rmax' is passed by value to cg_poly_elements_general_write. The pointee is never modified, so 'rmax' can be declared as 'const cgsize_t *' and the warning is a true positive. The PR now subtracts the deref count when it checks function arguments, so '*rmax' passed as an argument is no longer treated as a possible change through the pointer. The same pattern was ignored for fn, B, Z and S, which are already reported or excluded for other reasons. It is a Fortran-binding wrapper where const may be unusual, but the warning is technically correct. ---- 25 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/libc/libcgns/libcgns_4.5.0.orig.tar.gz Result: your CGNS-4.5.0/src/cg_ftoc.c:488:12: style: Parameter 'rmax' can be declared as pointer to const [constParameterPointer] Explanation: `rmax` is only dereferenced and passed by value (`*rmax`) to `cg_parent_data_partial_write`. The pointee is never modified, so it could be `const cgsize_t *`. The PR correctly subtracts the dereference count when checking whether the argument is changed, so this new constParameterPointer warning is a true positive. Fixing it may be impractical in a Fortran wrapper, but the warning is technically correct. ---- 26 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/libc/libcgns/libcgns_4.5.0.orig.tar.gz Result: your CGNS-4.5.0/src/cg_ftoc.c:498:12: style: Parameter 'rmax' can be declared as pointer to const [constParameterPointer] Explanation: In cg_elements_partial_read_f, 'rmax' is only dereferenced and its value (*rmax) is passed by value to cg_elements_partial_read. Nothing writes through the pointer, so it could be declared const cgsize_t*. Before the PR, Cppcheck did not subtract the dereference when checking the function-call argument, so it wrongly treated the pointee as possibly changed and stayed silent. The PR fixes this, matching its new test (v.push_back(*p)). The new warning is a correct true positive. A Fortran binding wrapper may keep a non-const signature for style reasons, but the diagnostic itself is accurate. ---- 27 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/libc/libcgns/libcgns_4.5.0.orig.tar.gz Result: your CGNS-4.5.0/src/cg_ftoc.c:900:12: style: Parameter 'npnts' can be declared as pointer to const [constParameterPointer] Explanation: In cg_subreg_ptset_write_f, 'npnts' is only read: it is dereferenced and passed by value (*npnts) to cg_subreg_ptset_write, and nothing is ever written through it. Declaring it as 'const cgsize_t *' is therefore valid, and the new constParameterPointer warning is a true positive. Before the PR, the dereference in the function-call argument was wrongly treated as a possible modification of the pointer. The PR fixes this by subtracting the dereferences from the indirection level. ---- 28 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/libi/libimager-perl/libimager-perl_1.040+dfsg.orig.tar.xz Result: your Imager-1.040/quant.c:958:33: style: Parameter 'quant' can be declared as pointer to const [constParameterPointer] Explanation: In the visible code, hbsetup only reads from `quant`: it uses `quant->mc_count` and passes `quant->mc_colors+i` to `ceucl_d`. `mc_colors` is itself a pointer member. Declaring `quant` as `const i_quantize *` only makes that pointer const, not the colours it points to, so passing it to a non-const `i_color*` parameter still compiles. The PR now subtracts the dereference count when checking member access through `->`. This correctly recognises that passing a pointer member's value does not modify the struct `quant` points to. The new constParameterPointer warning is therefore a true positive. Confidence is medium because the rest of the function (the non-HB_SORT branch) is not shown. ---- 29 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-10.5/mariadb-10.5_10.5.23.orig.tar.gz Result: your mariadb-10.5.23/mysys/my_bitmap.c:663:29: style: Variable 'end' can be declared as pointer to const [constVariablePointer] Explanation: `end` is initialized from `map->last_word_ptr` and is only used for comparisons (`data_ptr == end`, `data_ptr < end`) and reads (`*end & ~mask`, `get_first_set(*end, word_pos)`). `get_first_set` takes the word by value, so nothing is ever written through `end`, and it could be declared `const my_bitmap_map *`. Main missed this because it treated the dereferenced argument `*end` passed to a function as a possible modification. The PR now subtracts the dereference count, which matches the added test case `v.push_back(*p)`. The new warning is a true positive. ---- 30 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-10.5/mariadb-10.5_10.5.23.orig.tar.gz Result: your mariadb-10.5.23/storage/columnstore/columnstore/dbcon/joblist/tuple-bps.cpp:3194:63: style: Variable 'extentsPtr' can be declared as pointer to const [constVariablePointer] Explanation: `extentsPtr` is only assigned addresses (`&extentsMap[OID]`, `&mref`) and dereferenced once, as `*extentsPtr` passed to `LBIDList::GetMinMax`. In ColumnStore, that overload appears to take `const std::tr1::unordered_map&`, but the header is not shown here, hence medium confidence. If so, nothing is modified through the pointer, and it could be declared `const tr1::unordered_map<...>*`. The PR subtracts dereferences from the indirection level when checking a dereferenced variable. This lets Cppcheck see that passing `*p` to a const-reference parameter does not change what `p` points to. The new warning is therefore likely a true positive. ---- 31 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-10.5/mariadb-10.5_10.5.23.orig.tar.gz Result: your mariadb-10.5.23/storage/columnstore/columnstore/utils/multicast/impl.cpp:2109:18: style: Variable 'fifo' can be declared as pointer to const [constVariablePointer] Explanation: In transmitDataBlock, 'fifo' is only read: it is used to compute 'fifo->dataBuffer + offset' and to read 'fifo->dataBufSize'. In udpcast-derived code, 'struct fifo' declares 'dataBuffer' as a pointer member ('unsigned char *dataBuffer'), not an array. With 'const struct fifo*', that member becomes 'unsigned char* const', so it still converts to the non-const 'unsigned char*' parameter of sendRawData. Nothing is written through 'fifo', so it can be declared as pointer to const. The PR now subtracts the dereference count when deciding whether the pointer variable itself is modified, so this new warning looks like a true positive. Confidence is medium because the struct definition is not shown; if 'dataBuffer' were an array member, the warning would be wrong. ---- 32 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-10.5/mariadb-10.5_10.5.23.orig.tar.gz Result: your mariadb-10.5.23/storage/columnstore/columnstore/writeengine/shared/we_dbfileop.cpp:62:20: style: Variable 'curBuf' can be declared as pointer to const [constVariablePointer] Explanation: In flushCache, `curBuf` is only assigned from the map and read through `(*curBuf)`. Its uses are passing `cb.file.pFile` (a pointer member, and const-ness of the struct doesn't make the pointee const), `block.data`, and `block.lbid` to `writeDBFile`. As far as I recall, `writeDBFile(IDBDataFile*, const unsigned char*, uint64_t, ...)` takes the buffer as `const unsigned char*`, but its declaration is not shown, so this part is not verified. If so, nothing is modified through `curBuf`, and `const BlockBuffer* curBuf` would compile. The PR fixes the indirection handling for explicit `(*p).member` dereferences, which previously made Cppcheck treat this as a possible modification. The new warning is therefore likely a true positive. ---- 33 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-10.5/mariadb-10.5_10.5.23.orig.tar.gz Result: your mariadb-10.5.23/storage/rocksdb/rocksdb/java/rocksjni/rocksjni.cc:1052:9: style: Variable 'write_options' can be declared as pointer to const [constVariablePointer] Explanation: `write_options` is only dereferenced and passed as `*write_options` to `rocksdb_delete_range_helper`. That helper takes the WriteOptions by const reference, which is confirmed by line 1032 passing the `static const default_write_options` to it. The pointee is never modified, so `const WriteOptions*` is valid. Before the PR, the dereference at the call site was treated as a possible modification. This is a new true positive. ---- 34 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-10.5/mariadb-10.5_10.5.23.orig.tar.gz Result: your mariadb-10.5.23/storage/rocksdb/rocksdb/java/rocksjni/rocksjni.cc:1225:9: style: Variable 'write_options' can be declared as pointer to const [constVariablePointer] Explanation: `write_options` is only dereferenced and passed to `rocksdb_merge_helper`. That parameter must be a const reference (or by value), because line 1190 passes the `static const default_write_options` to the same position. The pointee is never modified, so `const WriteOptions*` is valid. This is a true positive enabled by the PR's correct handling of the dereference count when the result is passed to a function. ---- 35 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-10.5/mariadb-10.5_10.5.23.orig.tar.gz Result: your mariadb-10.5.23/storage/rocksdb/rocksdb/java/rocksjni/rocksjni.cc:564:9: style: Variable 'write_options' can be declared as pointer to const [constVariablePointer] Explanation: `write_options` is only dereferenced and passed to `rocksdb_put_helper`. That parameter must be a const reference, because line 544 passes the `static const WriteOptions default_write_options` to the same position. The pointee is never modified, so the variable can be `const WriteOptions*`. Before the PR, Cppcheck treated `*write_options` as if the pointer itself were passed, which hid this warning. The PR subtracts the dereference count, so the new warning is a true positive. ---- 36 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-10.5/mariadb-10.5_10.5.23.orig.tar.gz Result: your mariadb-10.5.23/storage/rocksdb/rocksdb/java/rocksjni/rocksjni.cc:715:9: style: Variable 'write_options' can be declared as pointer to const [constVariablePointer] Explanation: `write_options` is only dereferenced and passed to `rocksdb_delete_helper`. That helper must take a const reference to WriteOptions, because the same function also calls it with the `static const` object `default_write_options`. The pointee is never modified, so it can be declared `const ROCKSDB_NAMESPACE::WriteOptions*`. The PR fixed the indirection handling for dereferenced arguments, which let Cppcheck detect this. This is a new true positive. ---- 37 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/mariadb-10.5/mariadb-10.5_10.5.23.orig.tar.gz Result: your mariadb-10.5.23/storage/spider/spd_db_conn.cc:11656:10: style: Parameter 'length' can be declared as pointer to const [constParameterPointer] Explanation: `length` is only read: `*length` appears in an arithmetic expression for `reserve()` and is passed by value to `q_append()`. The pointee is never modified, so `const ulong *length` is valid and the warning is a true positive. The PR now subtracts the dereference when checking function arguments, so passing `*length` by value no longer counts as a possible modification of the pointee. ---- 38 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/navit/navit_0.5.7+dfsg.1.orig.tar.xz Result: your navit-0.5.7/navit/graphics/sdl/raster.c:1773:61: style: Parameter 'vx' can be declared as pointer to const [constParameterPointer] Explanation: In raster_aapolygon, vx is only read: it is assigned to the const Sint16* pointers px1/px2 and then read through them and by indexing. Nothing writes through vx, so it could be `const int16_t *vx`. The PR now subtracts dereferences from the indirection level in isVariableChanged. That stops reads such as `func(*p)` or `vx[i]` passed by value from being treated as modifying the pointee. The new warning is therefore a likely true positive. The rest of the function body is not shown, so confidence is medium. ---- 39 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/n/navit/navit_0.5.7+dfsg.1.orig.tar.xz Result: your navit-0.5.7/navit/graphics/sdl/raster.c:1773:74: style: Parameter 'vy' can be declared as pointer to const [constParameterPointer] Explanation: In raster_aapolygon, 'vy' only appears to be read. It is assigned to 'const Sint16 *py1/py2' and indexed or dereferenced for reading (e.g. passed by value as '*vy' to the line-drawing helpers, 'vy[i]' comparisons). Nothing writes through it. The PR fixes isVariableChanged so that a dereference like '*p' passed as a by-value argument no longer counts as modifying the pointee. That removes a false negative, so the new constParameterPointer warning is a true positive. ---- 40 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/n/netgen-lvs/netgen-lvs_1.5.133.orig.tar.gz Result: your netgen-1.5.133/base/netfile.c:741:9: style: Variable 'ch' can be declared as pointer to const [constVariablePointer] Explanation: In InputParseError, 'ch' only walks over 'line' and reads '*ch'. It is used in '*ch != ...', in 'isprint(*ch)', and passed by value as '*ch' to the variadic Fprintf. The pointee is never written, so 'ch' can be declared 'const char *ch'. Assigning a 'char*' to a 'const char*' is valid. Before the PR, passing the dereferenced '*ch' to the unknown function counted as a possible modification of the pointee. Subtracting the deref count fixes that, so this new warning is a correct true positive. ---- 41 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/starpu/starpu_1.4.10+dfsg.orig.tar.gz Result: your starpu-1.4.10+dfsg/min-dgels/base/BLAS/WRAP/cblaswr.c:217:20: style: Parameter 'CA' can be declared as pointer to const [constParameterPointer] Explanation: This is a C file. `f2c_crotg` passes `*CA`, `*CB` and `*C` by value to `cblas_crotg`. C has no references, so the callee cannot modify the pointed-to `complex` objects through these arguments. The parameters are never written through anywhere else in the function, so they could be pointers to const. The PR now subtracts the dereference count when checking whether a member or struct-type dereference may change the variable. That fixes the old over-approximation, which treated `*CA` as possibly modified. This makes struct-typed parameters behave the same as the scalar parameters (`a`, `b`, `S`), none of which show up in the diff. The warning is a new true positive, unless `cblas_crotg` is a macro that takes addresses, which is not indicated here. ---- 42 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/starpu/starpu_1.4.10+dfsg.orig.tar.gz Result: your starpu-1.4.10+dfsg/min-dgels/base/BLAS/WRAP/cblaswr.c:218:20: style: Parameter 'CB' can be declared as pointer to const [constParameterPointer] Explanation: This is a C file. `CB` is only used as `*CB`, which passes the `complex` value by value to `cblas_crotg`. A by-value argument cannot modify the pointee, so `CB` could be pointer to const. Before the PR, cppcheck ignored the dereference when deciding whether the pointed-to data could change. It then treated passing `*CB` to the function as a possible modification. The PR now subtracts the dereference count, which is the intended fix (see #15203). Confidence is only medium because the definition of `cblas_crotg` is not visible. If it were a macro that takes the address of its argument, the warning would be wrong. ---- 43 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/starpu/starpu_1.4.10+dfsg.orig.tar.gz Result: your starpu-1.4.10+dfsg/min-dgels/base/BLAS/WRAP/cblaswr.c:219:20: style: Parameter 'C' can be declared as pointer to const [constParameterPointer] Explanation: This is a C file. `f2c_crotg` passes `*C` by value to `cblas_crotg(*CA, *CB, *C, *S)`. A by-value argument in C cannot modify the pointee, so nothing writes through `C` and `complex *C` can be `const`. Before the PR, Cppcheck kept indirection 1 even after the dereference and wrongly treated the pointee as possibly changed. The fix subtracts the dereference and gets this right, matching the PR's new test with `push_back(*p)`. One caveat: `cblas_crotg` is not visible here. If it were a macro that takes the address of its arguments, the warning would be wrong, but from the code shown it is valid. ---- 44 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/starpu/starpu_1.4.10+dfsg.orig.tar.gz Result: your starpu-1.4.10+dfsg/min-dgels/base/BLAS/WRAP/cblaswr.c:236:26: style: Parameter 'CA' can be declared as pointer to const [constParameterPointer] Explanation: In `f2c_zrotg`, `CA` is only used as `*CA`, which is passed by value to `cblas_zrotg` in a C file. C has no reference parameters, so the callee cannot modify the pointee through that argument. `CA` could therefore be declared as `const doublecomplex*`. The PR makes `isVariableChanged` account for the dereference when the argument is passed to a function, as in its `v.push_back(*p)` test case. That lets Cppcheck report this warning, which matches how the code actually behaves. The wrapper looks semantically odd, since rotg normally writes its outputs, but as written nothing is modified through `CA`. One doubt: `S`, and the parameters of the similar real-valued wrappers, are not flagged. That inconsistency hints at other heuristics, which lowers confidence somewhat. ---- 45 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/starpu/starpu_1.4.10+dfsg.orig.tar.gz Result: your starpu-1.4.10+dfsg/min-dgels/base/BLAS/WRAP/cblaswr.c:237:26: style: Parameter 'CB' can be declared as pointer to const [constParameterPointer] Explanation: This is a C file. `f2c_zrotg` passes `*CB` by value to `cblas_zrotg`. A by-value struct argument in C cannot change the caller's `*CB`, so `CB` is never written through and could be declared `const doublecomplex*`. The PR makes `isVariableChanged` account for the dereference, so passing `*p` by value no longer counts as changing the pointee. That is exactly the case fixed for #15203, so this new warning is correct. Confidence is medium because the declaration of `cblas_zrotg` is not shown. If it were a macro that writes through its arguments, the warning would be wrong. ---- 46 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/starpu/starpu_1.4.10+dfsg.orig.tar.gz Result: your starpu-1.4.10+dfsg/min-dgels/base/BLAS/WRAP/cblaswr.c:238:26: style: Parameter 'C' can be declared as pointer to const [constParameterPointer] Explanation: In `f2c_zrotg`, the parameter `C` is only used as `*C`, which is passed by value to `cblas_zrotg`. This is C code, so there are no references, and passing the dereferenced struct cannot modify the object `C` points to. Declaring the parameter as `const doublecomplex*` would therefore be valid. This is the same pattern the PR fixes (`v.push_back(*p)`): the dereference level is now taken into account when checking whether the pointer target is changed. The warning looks like a true positive. The wrapper may have been meant to forward output arguments, but as written it does not modify them. ---- 47 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/starpu/starpu_1.4.10+dfsg.orig.tar.gz Result: your starpu-1.4.10+dfsg/mpi/src/mpi_failure_tolerance/starpu_mpi_checkpoint_template.c:428:77: style: Parameter 'cp_template' can be declared as pointer to const [constParameterPointer] Explanation: `starpu_mpi_checkpoint_template_t` is a pointer typedef. The parameter `cp_template` is a pointer to that pointer. The function only reads `*cp_template` and passes that value by copy to `_starpu_mpi_checkpoint_template_freeze`. That callee may modify the struct (a second dereference), but it can never change `*cp_template` itself. So the parameter could be declared `const starpu_mpi_checkpoint_template_t*`, i.e. `struct ... * const *`, without breaking anything. Before the PR, the extra dereference was not counted, so passing `*p` to a non-const parameter was wrongly treated as modifying `p`. This new warning is a correct true positive, matching the added test case for #15203. ---- 48 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/u/uftp/uftp_5.0.3.orig.tar.gz Result: your uftp-5.0.3/client_announce.c:1099:69: style: Parameter 'src' can be declared as pointer to const [constParameterPointer] Explanation: In the visible code, `src` is only read. It is used in `group->replyaddr = *src`, cast to `const struct sockaddr *` for getnameinfo, and dereferenced as `family_len(*src)`, where the dereferenced value is passed by value. None of these modify `*src`. The PR fixes how dereferenced arguments are counted, which matches the new `push_back(*p)` test case. That lets Cppcheck see that `*src` passed by value is not modified. The new constParameterPointer warning is therefore a true positive. Confidence is medium because the rest of the function is not shown, but `src` is most likely not used to write anywhere. ---- 49 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/x/xilinx-bootgen/xilinx-bootgen_2024.2.orig.tar.gz Result: your xilinx-bootgen-2024.2/imageheadertable-versal.cpp:2517:25: style: Variable 'elfPrgHeader' can be declared as pointer to const [constVariablePointer] Explanation: In the visible code, `elfPrgHeader` is only used to read the struct: `p_type`, `p_paddr`, `p_filesz` and `p_flags` are read, and `elfPrgHeader->data` is passed as the source argument of `memcpy`. No member of the pointed-to struct is written. Even if later code passes `elfPrgHeader->data` to a non-const function, `data` is a pointer member, so the struct can still be const. Declaring the variable as `const Elf32ProgramHeader*` therefore looks valid. The PR fixes the indirection count for member access through `->`, so the use of `elfPrgHeader->data` is no longer wrongly treated as modifying the pointee. That removes a false negative, and the new warning is a true positive. Confidence is medium because the rest of the function is not shown. ---- 50 / 50 ---- Verdict: IMPROVEMENT (low confidence) Package: https://ftp.debian.org/debian/pool/main/x/xilinx-bootgen/xilinx-bootgen_2024.2.orig.tar.gz Result: your xilinx-bootgen-2024.2/imageheadertable-versal.cpp:3080:16: style: Variable 'golden_value' can be declared as pointer to const [constVariablePointer] Explanation: `golden_value` is a `uint32_t*` that is reset to NULL and later filled from the golden CDO data. The PR's intended fix (#15203) is that dereferenced reads such as `golden_cdo_write.push_back(*golden_value)` or `push_back(golden_value[j])` no longer count as modifying the pointee. That is very likely how `golden_value` is used here, since it feeds the `std::vector golden_cdo_write`. If so, the pointee is only read and the new constVariablePointer warning is a true positive. The rest of the function is not shown, so a write through the pointer or a call like `free()` cannot be ruled out. Hence low confidence.