AI review of 2026-11-20_12-59-15-a0076598a29e-results.txt PR: #9016 https://github.com/cppcheck-opensource/cppcheck/pull/9016 Tested: a0076598a29e76e20213c7a7dee56705751855d4 Merge base: 415be9ca7e74488abc8788169d8ec7f2a8ce11da Reviewed: 2026-11-21 10:37:52 UTC Model: claude-opus-5-5 (effort high) Results: 50 reviewed of 56 in the report (random sample) Verdicts: 7 acceptable regression, 41 improvement, 2 regression Tokens: 100759 input, 66144 cache read, 2756 cache write, 27796 output The verdicts are written by AI and can be wrong. ---- 1 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/d/dee/dee_1.2.7+17.10.20170616.orig.tar.gz Result: main src/dee-file-resource-manager.c:122:34: style: Variable 'priv' can be declared as pointer to const [constVariablePointer] Explanation: `priv` is only read here: it is compared against NULL, and `priv->resource_dirs->data` is passed by value to `g_value_set_string`. Nothing is written through `priv`. Declaring it `const DeeFileResourceManagerPrivate *` would compile, because the const would not reach the `GList` member's pointee. So the removed constVariablePointer warning was a true positive. The PR's `indirect - derefs` change suppresses it, which is a new false negative. ---- 2 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/g/gentle/gentle_1.9.5~alpha2+dfsg1.orig.tar.xz Result: your gentle-m-1.9.5.alpha2/src/MyFrame.cpp:400:23: style: Variable 'b' can be declared as pointer to const [constVariablePointer] Explanation: The pointer 'b' is used only as '*b', passed by value or const reference to bitmaps.push_back(). That call copies the bitmap and never modifies the pointee. So 'b' can be declared 'const wxBitmap *'. This matches exactly the #15203 case the PR fixes. The memory leak is unrelated to this check. The new warning is a true positive. ---- 3 / 50 ---- Verdict: IMPROVEMENT (low confidence) Package: https://ftp.debian.org/debian/pool/main/g/gfarm/gfarm_2.8.11+dfsg.orig.tar.xz Result: main gfarm-2.8.11/linux/gfskd/gfskd.c:319:58: warning: Either the condition '(fbufp->f_buf.d_len=lseek(fd,0,2))<0' is redundant or mmap() argument nr 2 can have invalid value. The value is 0 but the valid values are '1:'. [invalidFunctionArg] gfarm-2.8.11/linux/gfskd/gfskd.c:315:59: note: Assuming that condition '(fbufp->f_buf.d_len=lseek(fd,0,2))<0' is not redundant gfarm-2.8.11/linux/gfskd/gfskd.c:319:58: note: Invalid argument Explanation: The removed warning claims mmap() may get length 0 because `d_len = lseek(...)` was only checked for `< 0`. That value comes from Cppcheck's boundary heuristic on the condition; nothing in the code makes 0 especially likely. Even for an empty file, mmap(…, 0, …) just returns MAP_FAILED/EINVAL, and the code checks for that and reports the error. So this is not a real defect, and the warning is at best noise. The PR's change to how `isVariableChanged` tracks indirection, applied to the assignment inside the condition, plausibly explains why it disappeared. However, the removal looks like a side effect rather than a targeted fix, so confidence is low. ---- 4 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/g/gfarm/gfarm_2.8.11+dfsg.orig.tar.xz Result: your gfarm-2.8.11/gftool/gfmv/gfmv.c:32:38: style: Parameter 'a' can be declared as pointer to const [constParameterPointer] Explanation: `alloc_dst` only reads through `a`: it uses `a->srcdirlen` and `a->dstdirlen` in arithmetic, and `a->dstdir` (already a `const char *`) as the source argument of `memcpy`. Nothing is ever written through `a`, so it can be declared `const struct inter_dirquota_arg *`. The caller passes a non-const pointer, which converts to const implicitly. The PR now accounts for dereferences when it checks whether a pointer is changed, so this true positive is newly reported. ---- 5 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/g/gfarm/gfarm_2.8.11+dfsg.orig.tar.xz Result: your gfarm-2.8.11/linux/kernel/gfsk_dir.c:93:27: style: Parameter 'dir' can be declared as pointer to const. However it seems that 'gfsk_lookup' is a callback function, if 'dir' is declared with const you might also need to cast function pointer(s). [constParameterCallback] gfarm-2.8.11/linux/kernel/gfsk_dir.c:273:13: note: You might need to cast the function pointer here gfarm-2.8.11/linux/kernel/gfsk_dir.c:93:27: note: Parameter 'dir' can be declared as pointer to const Explanation: In `gfsk_lookup`, `dir` is only used through `GFSK_CTX_DECLARE_INODE(dir)`. That macro most likely expands to reading `dir->i_sb->s_fs_info` into a context pointer (the header is not shown, hence medium confidence). Copying a pointer obtained through `dir->i_sb` does not modify `*dir`, so `dir` could be `const struct inode *`. Main seems to have treated that member read as a non-const use of `dir` itself. The PR subtracts the dereferences, so `isVariableChanged` no longer counts it as a change. The new message correctly uses `constParameterCallback` and warns that `gfsk_lookup` is a callback whose function pointer would need a cast. It is a valid style finding, consistent with the intended fix (#15203). ---- 6 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/g/gfarm/gfarm_2.8.11+dfsg.orig.tar.xz Result: your gfarm-2.8.11/linux/kernel/gfsk_file.c:476:24: style: Variable 'mapping' can be declared as pointer to const [constVariablePointer] Explanation: `mapping` is only used to read `mapping->host` into `struct inode *inode`. Reading a pointer member through a `const struct address_space *` still yields a `struct inode *` value, so it can be assigned to the non-const `inode`. Later changes go through `inode` (the pointee), not through `*mapping`, so `mapping` can be pointer to const. Main wrongly counted the changes through `inode` as changes to `*mapping`. The PR now subtracts the dereferences when it propagates indirection, so this is a correct new true positive. ---- 7 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/g/gfarm/gfarm_2.8.11+dfsg.orig.tar.xz Result: your gfarm-2.8.11/server/gfmd/host.c:1360:15: style: Variable 'sizep' can be declared as pointer to const [constVariablePointer] Explanation: `sizep` is only dereferenced, and the value is passed to `host_is_disk_available(host, *sizep)`. That function receives a `gfarm_off_t` by value, so the pointee is never modified. Declaring it `const gfarm_off_t *sizep = closure;` is valid C: assigning from `void*` to a `const T*` needs no cast. Before the PR, passing `*sizep` to a function was checked with the wrong indirection level, which suppressed the warning. The PR fixes that by subtracting `derefs`, so this is a newly found true positive. ---- 8 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/g/gfarm/gfarm_2.8.11+dfsg.orig.tar.xz Result: your gfarm-2.8.11/server/gfmd/inode.c:2169:15: style: Variable 'sizep' can be declared as pointer to const [constVariablePointer] Explanation: `sizep` is only read: `*sizep` passes a `gfarm_off_t` value to `host_is_disk_available`. Nothing is written through the pointer, so it can be declared `const gfarm_off_t *` (initialising that from `void *` is fine in C). Before the PR, the dereferenced argument was wrongly treated as possibly modified. The new warning is a true positive, matching the PR's intent (#15203). ---- 9 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/g/ghostscript/ghostscript_10.08.0~dfsg.orig.tar.xz Result: your ghostpdl-10.08.0/base/gdevm16.c:86:30: style: Variable 'mdev' can be declared as pointer to const [constVariablePointer] Explanation: In this function, `mdev` is only read. The macros `setup_rect` and `scan_line_base` read `mdev->line_ptrs[y]` and `mdev->raster`, and `fit_fill` uses `dev`, not `mdev`. The writes go through `dest`, a `byte*` loaded from `line_ptrs[y]`. That memory is the pixel buffer, not the `gx_device_memory` object itself. Declaring `mdev` as `const gx_device_memory * const` would therefore still compile. The PR fixes indirection counting when a dereferenced value is passed (`pindirect = indirect - derefs`), so Cppcheck no longer wrongly treats `mdev` as modified. The new warning is a valid true positive. ---- 10 / 50 ---- Verdict: REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/g/ghostscript/ghostscript_10.08.0~dfsg.orig.tar.xz Result: your ghostpdl-10.08.0/base/gsicc_cache.c:602:36: style: Condition 'curr->validity!=1' is always true [knownConditionTrueFalse] Explanation: Line 602 re-checks `curr->validity` after `gx_monitor_enter(curr->lock)` / `gx_monitor_leave(curr->lock)`. The code waits on the lock so that another thread, the one building the link, can finish and set `validity`. The comment says exactly that it may or may not be valid at this point. So the condition is not always true. After the PR, `isVariableChanged` no longer treats passing `curr->lock` to these external monitor functions as a possible change to `curr`. The value from the loop condition is therefore assumed to still hold, which produces this new false positive. ---- 11 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/g/ghostscript/ghostscript_10.08.0~dfsg.orig.tar.xz Result: your ghostpdl-10.08.0/base/gsptype2.c:303:29: style: Variable 'pinst' can be declared as pointer to const [constVariablePointer] Explanation: In gx_dc_pattern2_get_bbox, 'pinst' is only read through. The code reads pinst->templat.Shading->params.have_BBox, takes &pinst->templat.Shading->params.BBox (reached through the Shading pointer and passed as a const gs_rect*), and casts the pointer member pinst->saved to gs_gstate*. Reading a pointer member and casting it is still legal when pinst is pointer-to-const, so the declaration can be 'const gs_pattern2_instance_t *pinst'. The PR fixes the indirection count in isVariableChanged, which previously treated these dereferenced uses as modifications. This is a new true positive. ---- 12 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/g/ghostscript/ghostscript_10.08.0~dfsg.orig.tar.xz Result: your ghostpdl-10.08.0/pdf/pdf_font1C.c:1415:102: style: Parameter 'offsets' can be declared as pointer to const [constParameterPointer] Explanation: In pdfi_make_name_from_sid, 'offsets' is only read, via 'offsets->strings_off', an integer added to font->cffdata. Nothing is written through it, so it can be 'const cff_font_offsets *'. Before the PR, Cppcheck treated the member access inside an argument to a non-const pointer parameter as a possible modification. The PR fixes the indirection handling, so this true positive is now reported. ---- 13 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/g/ghostscript/ghostscript_10.08.0~dfsg.orig.tar.xz Result: your ghostpdl-10.08.0/pdf/pdf_font1C.c:1438:104: style: Parameter 'offsets' can be declared as pointer to const [constParameterPointer] Explanation: In pdfi_make_string_from_sid, 'offsets' is used only to read 'offsets->strings_off', which is passed by value into pdf arithmetic. Nothing is written through the pointer, so it can be declared 'const cff_font_offsets *'. Before the PR, the derefs/indirect handling made Cppcheck treat this read as a possible modification. The new warning is a true positive. ---- 14 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/g/ghostscript/ghostscript_10.08.0~dfsg.orig.tar.xz Result: your ghostpdl-10.08.0/psi/zfont1.c:660:11: style: Variable 'pdict' can be declared as pointer to const [constVariablePointer] Explanation: `pdict` is only passed to the `dict_mem()` macro. That macro reads the `memory` member and casts its pointer value; it does not modify the dict through `pdict`. The resulting memory pointer goes to `obj_eq()`, which only compares values. So `const dict *pdict` would compile, and the warning is a true positive. Main probably missed it because a member access through the pointer was treated as a write; the PR fixes that by subtracting the dereference count. ---- 15 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/i/intel-gpu-tools/intel-gpu-tools_2.6.orig.tar.xz Result: main igt-gpu-tools-2.6/tools/intel_hdcp.c:300:47: style: Condition '*rest!='\0'' is always true [knownConditionTrueFalse] Explanation: Inside `while (*rest)`, `*rest` is known to be non-zero. `isspace((unsigned char)*rest)` takes the char by value and cannot modify `*rest`, so `*rest != '\0'` really is always true. The removed warning was a true positive. The PR now subtracts derefs from the indirection passed to isVariableChanged, and this apparently makes Cppcheck lose the known value here, causing a new false negative. ---- 16 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/i/isomaster/isomaster_1.3.13.orig.tar.bz2 Result: your isomaster-1.3.13/bk/bkWrite.c:1935:51: style: Parameter 'symlink' can be declared as pointer to const [constParameterPointer] Explanation: writeRockSL() only reads symlink->target: it calls strlen and indexes characters, and the rest of the function apparently passes parts of target to read-only routines such as strchr or copies from it. None of these modify *symlink, so the pointer can be const. The PR now subtracts dereferences when checking whether a member access is changed through a function call. That removes a spurious 'may be changed' result and lets the true constParameterPointer warning appear. The rest of the function is not shown, so confidence is medium. ---- 17 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/i/isomaster/isomaster_1.3.13.orig.tar.bz2 Result: your isomaster-1.3.13/bk/bkWrite.c:405:54: style: Parameter 'file' can be declared as pointer to const [constParameterPointer] Explanation: In bootInfoTableChecksum, 'file' is only read. The visible code reads file->size, file->onImage, file->offset and file->pathAndName, and passes those values (not the pointer) to malloc, memset, bkSeekSet, bkRead and open. The rest of the function is not shown. In this function it most likely only computes the checksum from 'contents' and frees it, which would not modify *file. Declaring the parameter 'const FileToWrite*' is therefore valid. The PR fixes the indirection level used when member values are passed to functions, which removes a false negative. This new warning is likely a true positive. ---- 18 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/j/jansson/jansson_2.15.1.orig.tar.gz Result: your akheron-jansson-1749b18/src/pack_unpack.c:610:47: style: Parameter 'root' can be declared as pointer to const [constParameterPointer] Explanation: In `unpack_array`, `root` appears to be used only read-only. It is passed to `json_is_array`/`json_typeof` (a field read), `type_name(const json_t*)`, `json_array_get(const json_t*, size_t)` and `json_array_size(const json_t*)`. `json_array_get` returns a non-const `json_t*`, so the element passed on to `unpack()` stays non-const even if `root` is const. That makes `const json_t *root` valid, and the new constParameterPointer warning looks like a true positive. The PR fixes the indirection count after dereferences, which plausibly removed a false 'changed' result that had hidden it. Confidence is medium because the shown excerpt ends at line 650, so the rest of the function was not visible. ---- 19 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/libj/libjson-parse-perl/libjson-parse-perl_0.62.orig.tar.gz Result: your JSON-Parse-0.62/json-common.c:1286:19: style: Parameter 'end' can be declared as pointer to const [constParameterPointer] Explanation: In the visible code, `end` is only read. It is null-checked, dereferenced as `*end` and passed by value to the variadic `failbug`, and used in `end - start`. None of these modify the pointee. Before the PR, Cppcheck treated `*end` passed to a function as a possible change at the wrong indirection level, which is the bug the PR fixes. `start` is still not flagged because the pointer itself is passed to `failbug` for `%s`, which is consistent with this. The rest of the function is not shown, so it cannot be fully confirmed that `end` is never used in a non-const way later. Still, the new constParameterPointer warning looks like a correct true positive. ---- 20 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/libo/libopenraw/libopenraw_0.1.2.orig.tar.bz2 Result: your libopenraw-0.1.2/lib/ljpegdecompressor.cpp:697:24: style: Variable 'compptr' can be declared as pointer to const [constVariablePointer] Explanation: `compptr` is only read through `compptr->dcTblNo`, which is used as an array index. `FixHuffTbl` receives `dcPtr->dcHuffTblPtrs[...]`, not `compptr` or its pointee. Assigning a `JpegComponentInfo*` to a `const JpegComponentInfo*` is valid, so the variable can be declared pointer to const. This is a true positive. Before the PR, the dereference inside the argument expression of the non-const call was wrongly treated as a possible modification. The PR fixes that by subtracting `derefs` from the indirection level. ---- 21 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mediastreamer2/mediastreamer2_5.3.105+dfsg.orig.tar.xz Result: your mediastreamer2-5.3.105/src/utils/audiodiff.c:266:30: style: Parameter 'fi2' can be declared as pointer to const [constParameterPointer] Explanation: In the visible code, `fi2` is only read: `fi2->buffer + samples * step` is passed to `_ms_audio_diff_one_chunk`. Declaring `fi2` as `const FileInfo *` only makes the member pointer itself const (`buffer` becomes `T * const`). The data it points to stays mutable, so the call still compiles and `fi2` can be pointer to const. The PR's change to `pindirect` (subtracting derefs) removes a false negative, so the new warning looks like a true positive. The rest of the function is not shown, so a later write through `fi2` cannot be fully ruled out. `fi1` is not flagged, presumably because it is used differently later. ---- 22 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/m/mediastreamer2/mediastreamer2_5.3.105+dfsg.orig.tar.xz Result: your mediastreamer2-5.3.105/src/voip/stun.c:380:10: style: Variable 'tr_id' can be declared as pointer to const [constVariablePointer] Explanation: `tr_id` is assigned from a cast of `decode()`, which returns `const void*`. It is only dereferenced to pass `*tr_id` by value to `ms_stun_message_set_tr_id()`, so the pointee is never modified. Declaring it `const UInt96 *` is valid and would also avoid casting away const. The PR makes Cppcheck subtract the dereference count from the indirection level when the variable is passed to a function. It now sees that `*tr_id` passed by value does not change the pointee, so this new warning is a true positive. ---- 23 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mongo-cxx-driver-legacy/mongo-cxx-driver-legacy_1.1.3.orig.tar.gz Result: main mongo-cxx-driver-legacy-1.1.3/src/third_party/jsoncpp/jsoncpp.cpp:2963:49: style: Parameter 'itInArg' can be declared as reference to const [constParameterReference] Explanation: In `addPathInArg`, `itInArg` is only compared against `in.end()` and dereferenced (`(*itInArg)->kind_`, `**itInArg`). It is never incremented or assigned, so it could be a reference to const. The removed warning was a true positive; it even hints at a missing `++` compared with upstream jsoncpp. The PR now subtracts `derefs` from `indirect`. For `args_.push_back(**itInArg)` this gives `pindirect = 0 - 2`, a negative indirection, which apparently makes Cppcheck treat the iterator as possibly changed. That suppresses a correct warning, so this is a new false negative. ---- 24 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mothur/mothur_1.48.6.orig.tar.gz Result: main mothur-1.48.6/source/utils.cpp:2299:36: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm] Explanation: The loop walks a string with a const_iterator and returns false on the first non-ASCII character. That is a textbook case for an STL algorithm (std::all_of / std::any_of), so the useStlAlgorithm warning was a true positive. The loop variable `it` is never modified; it is only dereferenced as `*it` and passed by value to isascii. The PR now computes `pindirect = indirect - derefs`, which can become negative (0 - 1) for `*it` passed to a function. That likely makes isVariableChanged treat the iterator as possibly changed, so the warning is suppressed. Losing this valid warning is a new false negative, apparently an unintended side effect of the change. ---- 25 / 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 read: it is null-checked, and `query->index` is used as an array index into `tipnodes`. The object it points to is never modified; `set_encode_sequence` modifies `tipnodes[...]`, not `*query`. Declaring it `const pair_t *` is valid, and since this is C, the `void*` returned by `hashtable_find` converts implicitly. Before the PR, Cppcheck did not subtract the dereference when following the member access through the function argument, so it treated `query` as possibly changed. The new constVariablePointer warning is a true positive. ---- 26 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/m/mrmpi/mrmpi_1.0~20140404.orig.tar.gz Result: your mrmpi-1.0~20140404/oink/sssp.cpp:363:35: style: Parameter 'key' can be declared as pointer to const. However it seems that 'get_good_sources' is a callback function, if 'key' is declared with const you might also need to cast function pointer(s). [constParameterCallback] mrmpi-1.0~20140404/oink/sssp.cpp:70:20: note: You might need to cast the function pointer here mrmpi-1.0~20140404/oink/sssp.cpp:363:35: note: Parameter 'key' can be declared as pointer to const Explanation: In get_good_sources, 'key' is only read: it is cast to VERTEX*, dereferenced, and the value is passed to push_back, which takes a const reference. Nothing the pointer points to is ever written. This is the same pattern as the PR's new test (#15203). Before the fix, the dereference was not subtracted from the indirection level, so push_back's non-const object 'ths->sourcelist' was wrongly treated as modifying 'key'. The new constParameterCallback warning is therefore a true positive. It also correctly warns that the function is used as a callback (line 70), so changing the signature would need a function-pointer cast. ---- 27 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/o/openni/openni_1.5.4.0+dfsg.orig.tar.xz Result: your openni-1.5.4.0+dfsg/Source/OpenNI/FilesOnly/FilesOnlyMemory.cpp:145:12: style: Variable 'pnValue' can be declared as pointer to const [constVariablePointer] Explanation: `pnValue` is only dereferenced to read the value, which is passed by value to `xnOSEndianSwapUINT32(XnUInt32)`. The pointee is never modified, so `const XnUInt32*` works (with a matching cast). This is a true positive. The PR now subtracts the dereference from the indirection level when checking function arguments, so `*p` passed by value no longer counts as a modification. ---- 28 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/o/openni/openni_1.5.4.0+dfsg.orig.tar.xz Result: your openni-1.5.4.0+dfsg/Source/OpenNI/Linux/LinuxMemory.cpp:159:12: style: Variable 'pnValue' can be declared as pointer to const [constVariablePointer] Explanation: pnValue is only dereferenced to pass the value *pnValue by value to xnOSEndianSwapUINT32(XnUInt32). The pointed-to data is never modified, so it could be declared 'const XnUInt32*'. This is a true positive. Before the PR it was missed because the dereference was not subtracted from the indirection when checking function arguments. ---- 29 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/o/openni/openni_1.5.4.0+dfsg.orig.tar.xz Result: your openni-1.5.4.0+dfsg/Source/OpenNI/Win32/Win32Memory.cpp:144:12: style: Variable 'pnValue' can be declared as pointer to const [constVariablePointer] Explanation: pnValue is only dereferenced to read its value: `*pnValue` is passed by value to xnOSEndianSwapUINT32. The pointed-to data is never modified, so it could be declared `const XnUInt32*`. Before the PR, Cppcheck ignored the dereference when checking the function argument and wrongly treated the pointee as possibly changed. This is the same pattern as the PR's test case (#15203). The new warning is a true positive. ---- 30 / 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: In the code shown, `in2` is only read: once in the comparison `*in2 != x->x_delsize`, and once as `delay_delay(x, *in2)`. The second use passes the dereferenced float by value as a `t_floatarg`, so it cannot modify the pointee. Before the fix, `isVariableChanged` ignored the dereference and treated that call as a possible change through the pointer, so the warning was missed. With `pindirect = indirect - derefs`, Cppcheck now sees that the value is passed by value and reports the true positive. Confidence is medium because the rest of `delay_perform` after line 165 is not shown; in the visible part, `in2` is never written through. ---- 31 / 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 used to read `c->c_pairsz` and to pass `c->c_pairs+i` to `funbuff_delete`. The struct `t_funbuffcom` is not shown here, but the shared clipboard is resizable, so `c_pairs` is most likely a heap `t_atom*` pointer rather than an array member. If so, `const t_funbuffcom *c` still gives a non-const `t_atom*` for `c->c_pairs`, and the code compiles unchanged. Writing through `c->c_pairs` changes the atoms, not the struct, so `*c` is never modified. The PR subtracts the dereference count when it checks the member, which correctly lets Cppcheck see this and report the new true positive. If `c_pairs` were an array member instead, this would be a false positive, hence medium confidence. ---- 32 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/p/presage/presage_0.9.1.orig.tar.gz Result: main presage-0.9.1/apps/gtk/gprompter/scintilla/src/ViewStyle.cxx:54:31: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm] Explanation: Lines 53-57 are a textbook find_if pattern: iterate the vector, return the first element where strcmp(*it, name) == 0. The useStlAlgorithm suggestion was correct. The PR changes the indirection passed to isVariableChanged to `indirect - derefs`. For the dereferenced iterator `*it` passed to strcmp, this apparently makes Cppcheck treat the loop variable as possibly changed, so the check now stays silent. The same thing happened in Catalogue.cxx. A valid style suggestion was lost, which is a new false negative. ---- 33 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/p/presage/presage_0.9.1.orig.tar.gz Result: main presage-0.9.1/test/lib/core/selectorTest.cpp:101:5: style: Variable 'td' is assigned an expression that holds the same value. [redundantAssignment] presage-0.9.1/test/lib/core/selectorTest.cpp:64:8: note: td is assigned 'new TestData' here. presage-0.9.1/test/lib/core/selectorTest.cpp:101:5: note: Variable 'td' is assigned an expression that holds the same value. Explanation: Line 101 assigns td a fresh `new TestData` after the previous object was deleted. Each `new` yields a distinct object, so saying td is "assigned an expression that holds the same value" is wrong. With the fix, `pindirect = indirect - derefs`, Cppcheck now accounts for dereferences such as `*td` passed to push_back when checking whether a variable is changed. That makes the analysis more accurate, and this false positive is gone. ---- 34 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/p/presage/presage_0.9.1.orig.tar.gz Result: main presage-0.9.1/test/lib/core/selectorTest.cpp:197:5: style: Variable 'td' is assigned an expression that holds the same value. [redundantAssignment] presage-0.9.1/test/lib/core/selectorTest.cpp:182:8: note: td is assigned 'new TestData' here. presage-0.9.1/test/lib/core/selectorTest.cpp:197:5: note: Variable 'td' is assigned an expression that holds the same value. Explanation: Line 182 does `td = new TestData`, then `testData.push_back(*td); delete td;`. Line 197 does `td = new TestData` again. The `delete td` in between frees the pointer, and each `new` returns a separate allocation anyway, so 'assigned an expression that holds the same value' is wrong. This is a false positive. With the PR, the dereference `*td` in push_back is no longer treated as changing the pointer at the wrong indirection level, which apparently changes the analysis so the bogus warning disappears. Removing a false positive is an improvement. ---- 35 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/p/presage/presage_0.9.1.orig.tar.gz Result: main presage-0.9.1/test/lib/core/selectorTest.cpp:263:5: style: Variable 'td' is assigned an expression that holds the same value. [redundantAssignment] presage-0.9.1/test/lib/core/selectorTest.cpp:226:8: note: td is assigned 'new TestData' here. presage-0.9.1/test/lib/core/selectorTest.cpp:263:5: note: Variable 'td' is assigned an expression that holds the same value. Explanation: Each `td = new TestData` allocates a fresh object, so the second assignment does not hold the same value. In between, the code writes through the pointer (`td->updateString = ...`) and deletes it. The redundantAssignment warning is a false positive. The PR makes isVariableChanged account for derefs, so the fix for #15203 now correctly treats these writes through `td->` as changes. The warning is gone because Cppcheck understands the code better. ---- 36 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/p/presage/presage_0.9.1.orig.tar.gz Result: main presage-0.9.1/test/lib/core/selectorTest.cpp:278:5: style: Variable 'td' is assigned an expression that holds the same value. [redundantAssignment] presage-0.9.1/test/lib/core/selectorTest.cpp:263:8: note: td is assigned 'new TestData' here. presage-0.9.1/test/lib/core/selectorTest.cpp:278:5: note: Variable 'td' is assigned an expression that holds the same value. Explanation: The warning claims that `td = new TestData` at line 278 assigns the same value as line 263. This is a false positive. Each `new` returns a new allocation, and the object from line 263 was modified through `td->`, copied into `testData`, and deleted before line 278. The PR changes the indirection passed when checking whether a dereferenced variable is changed. That correctly treats writes through `td->` as modifications, so this bogus redundantAssignment warning goes away. ---- 37 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/p/presage/presage_0.9.1.orig.tar.gz Result: main presage-0.9.1/test/lib/core/selectorTest.cpp:344:5: style: Variable 'td' is assigned an expression that holds the same value. [redundantAssignment] presage-0.9.1/test/lib/core/selectorTest.cpp:307:8: note: td is assigned 'new TestData' here. presage-0.9.1/test/lib/core/selectorTest.cpp:344:5: note: Variable 'td' is assigned an expression that holds the same value. Explanation: The warning claimed that `td = new TestData;` at line 344 assigns the same value as line 307. That is false. Each `new` returns a new pointer, and in between `td` was dereferenced and modified (`td->updateString = ...`), copied into the vector with `push_back(*td)`, and deleted. The removed warning was a false positive. The PR changes `isVariableChanged` to subtract `derefs` from the indirection level. As a result, `testData.push_back(*td)` and the member writes through `td` are no longer misread as changes to the pointer `td` itself. ---- 38 / 50 ---- Verdict: REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/p/presage/presage_0.9.1.orig.tar.gz Result: your presage-0.9.1/src/lib/core/utility.cpp:84:17: performance:inconclusive: Use const reference for 'upstr' to avoid unnecessary data copying. [redundantCopyLocalConst] Explanation: `upstr` is a copy of `str` that is changed through an iterator (`*i = toupper(*i)` with `i = upstr.begin()`) and then returned by value. The copy is needed, and a const reference would not compile. The PR changed `pindirect` to `indirect - derefs`, so the write through the dereferenced iterator `*i` is no longer seen as a change to `upstr`. The new redundantCopyLocalConst warning is a false positive. ---- 39 / 50 ---- Verdict: ACCEPTABLE REGRESSION (high confidence) Package: https://ftp.debian.org/debian/pool/main/s/sqlcipher/sqlcipher_4.20.0.orig.tar.gz Result: main sqlcipher-4.20.0/src/test_intarray.c:133:18: style: Variable 'pVtab' can be declared as pointer to const [constVariablePointer] Explanation: In intarrayColumn, 'pVtab' is only read: pVtab->pContent->n is compared and pVtab->pContent->a[pCur->i] is passed by value to sqlite3_result_int64. Nothing is written through pVtab, so it could be 'const intarray_vtab *'. The warning was a true positive. The PR's change to the indirection calculation (indirect - derefs) suppresses it, which is a new false negative. ---- 40 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/s/sqlcipher/sqlcipher_4.20.0.orig.tar.gz Result: your sqlcipher-4.20.0/ext/recover/sqlite3recover.c:1821:28: style: Variable 'pCol' can be declared as pointer to const [constVariablePointer] Explanation: pCol is only read: pCol->iBind, pCol->bIPK and pCol->iField, where iField is just an index into apVal. Nothing is written through pCol, so it can be declared 'const RecoverColumn *'. The new warning is a true positive. Main probably missed it because the use inside apVal[pCol->iField], passed to recoverBindValue, was treated as a possible modification, which is the indirection bug this PR fixes. ---- 41 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/sqlcipher/sqlcipher_4.20.0.orig.tar.gz Result: your sqlcipher-4.20.0/ext/wasm/libcmpp.c:9917:37: style: Parameter 'pp' can be declared as pointer to const [constParameterPointer] Explanation: `cmpp__d_search` only reads through `pp`: it evaluates `&pp->pimpl->d.list` and passes it to `CmppDList_search`. `pimpl` is, by its name, a pointer to a separate object. If so, `d.list` lives in that object, not in `*pp`, and making `pp` a `const cmpp *` still leaves `pp->pimpl->d.list` non-const. Nothing in the function writes to `*pp`. The PR now subtracts the member-access dereference from the indirection level, so taking the address of a member reached through `pimpl` no longer counts as modifying `*pp`. This matches the #15203 test case, so the new warning is a valid true positive. ---- 42 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/s/sqlcipher/sqlcipher_4.20.0.orig.tar.gz Result: your sqlcipher-4.20.0/src/fkey.c:676:34: style: Parameter 'pTab' can be declared as pointer to const [constParameterPointer] Explanation: sqlite3FkReferences() only reads through pTab. It passes &pTab->pSchema->fkeyHash, whose address is reached through the Schema* member, to sqlite3HashFind(const Hash*, const char*), and passes pTab->zName as a const char*. Nothing is modified through pTab, so it could be declared const Table*. The PR fixes the indirection count for member access after dereferences, which lets Cppcheck find this true positive. ---- 43 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/s/sqlcipher/sqlcipher_4.20.0.orig.tar.gz Result: your sqlcipher-4.20.0/src/trigger.c:707:39: style: Parameter 'pTrigger' can be declared as pointer to const [constParameterPointer] Explanation: tableOfTrigger only reads pTrigger->pTabSchema (a pointer member, then dereferenced to get &...->tblHash) and pTrigger->table, and passes both to sqlite3HashFind, which takes const Hash* and const char*. Nothing modifies *pTrigger. If pTrigger were const Trigger*, pTabSchema would be Schema* const, so taking &pTabSchema->tblHash still compiles. The parameter can be pointer to const, so this is a new true positive. Before the fix, the dereference through the member was wrongly counted as a possible modification. ---- 44 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/s/sqlcipher/sqlcipher_4.20.0.orig.tar.gz Result: your sqlcipher-4.20.0/src/where.c:1475:13: style: Variable 'pE2' can be declared as pointer to const [constVariablePointer] Explanation: pE2 is assigned from pExpr->pLeft and then only read: pE2->op, pE2->iTable and pE2->iColumn. Nothing is written through it; the write goes through pExpr (pExpr->iColumn = ...). Assigning an Expr* to a const Expr* is valid, so declaring pE2 as 'const Expr *pE2' compiles. The new constVariablePointer warning is a true positive that was previously missed. ---- 45 / 50 ---- Verdict: ACCEPTABLE REGRESSION (medium confidence) Package: https://ftp.debian.org/debian/pool/main/u/ukui-system-monitor/ukui-system-monitor_1.0.4.orig.tar.gz Result: main ukui-system-monitor/src/singleProcessNet/refreshthread.cpp:142:30: style: Variable 'conn' can be declared as pointer to const [constVariablePointer] Explanation: `conn` is only used to read `conn->refpacket->...` fields, which are passed to `cnxDetected`. `refpacket` is reached through a pointer member, so even if `conn` were `const Connection*`, the pointee of `refpacket` would stay non-const. `conn` itself is never modified through, so the `constVariablePointer` warning was a true positive. The PR now subtracts `derefs` from the indirect level, and that loses this warning. The result is a new false negative, not a removed false positive. ---- 46 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/u/umview/umview_0.8.2.orig.tar.gz Result: your umview-0.8.2/umdevmbr/umdevramdisk.c:48:18: style: Variable 'ramdisk' can be declared as pointer to const [constVariablePointer] Explanation: In rd_write, the struct pointed to by 'ramdisk' is only read: 'flags' and 'rd_size' are read, and memcpy writes to the buffer that the member 'diskdata' points to, not to the struct itself. With 'const struct ramdisk *', 'diskdata' becomes 'char * const', which still allows writing through it. So the pointer can be declared as pointer to const, and the new warning is a true positive. The PR stops Cppcheck from treating a write through a member pointer as a change to the pointed-to struct. ---- 47 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/x/xscreensaver/xscreensaver_6.09+dfsg1.orig.tar.xz Result: your xscreensaver-6.09/driver/xscreensaver-command.c:141:9: style: Variable 'cmd' can be declared as pointer to const [constVariablePointer] Explanation: `cmd` is only ever assigned addresses of Atom variables (`&XA_ACTIVATE`, `&XA_WATCH`, etc.). As far as is known for this file, it is then only read through, e.g. `*cmd == XA_...` and `xscreensaver_command(dpy, *cmd, ...)`, which passes the value by copy. The pointed-to Atom is never written through `cmd`, so `const Atom *cmd` would compile and is correct. The PR subtracts the dereference count when checking function arguments, so passing `*cmd` by value is no longer treated as modifying the pointee. That is exactly the #15203 pattern, so the new warning is likely a true positive. The later uses of `cmd` are not shown, so confidence is medium. ---- 48 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/x/xscreensaver/xscreensaver_6.09+dfsg1.orig.tar.xz Result: your xscreensaver-6.09/hacks/glx/quickhull.c:321:57: style: Parameter 'context' can be declared as pointer to const [constParameterPointer] Explanation: `qh__face_centroid` only reads `context->vertices`, which in quickhull is a pointer member (`qh_vertex_t* vertices`). It passes `context->vertices + vertices[i]` to `qh__vec3_add`. Declaring `context` as `const qh_context_t*` only makes that member pointer const, not the vertex data it points to, so the call still compiles. Nothing in the struct is modified through `context`. The PR subtracts the dereference count when checking member-access chains, so Cppcheck no longer treats this as a modification of `context`. The new warning is a true positive. ---- 49 / 50 ---- Verdict: IMPROVEMENT (medium confidence) Package: https://ftp.debian.org/debian/pool/main/x/xscreensaver/xscreensaver_6.09+dfsg1.orig.tar.xz Result: your xscreensaver-6.09/hacks/glx/quickhull.c:495:45: style: Parameter 'context' can be declared as pointer to const [constParameterPointer] Explanation: In qh__furthest_point_from_plane, 'context' is only read: it computes 'context->vertices + index' and passes that to qh__dist_point_plane. 'vertices' is a pointer member of qh_context_t, so declaring 'context' as 'const qh_context_t*' only makes the pointer member itself const, not the vertices it points to. The code would still compile, and nothing in the function modifies *context. Before this change, Cppcheck treated passing a pointer member to a non-const function parameter as a write to the parameter. The fix to the indirection count now correctly finds this missed constParameterPointer, so this is a new true positive. ---- 50 / 50 ---- Verdict: IMPROVEMENT (high confidence) Package: https://ftp.debian.org/debian/pool/main/x/xscreensaver/xscreensaver_6.09+dfsg1.orig.tar.xz Result: your xscreensaver-6.09/hacks/glx/quickhull.c:569:28: style: Parameter 'face' can be declared as pointer to const [constParameterPointer] Explanation: In `qh__assert_face`, `face` is only read: `face->edges[i]` is used as an index into `context->edges`, and `face->face` is read inside the assert. Nothing written through `face` is changed, so it can be declared `const qh_face_t*`. Before the PR, Cppcheck treated `face->edges[i]`, used inside an argument expression, as passing `face` with the wrong indirection level. Subtracting `derefs` fixes that, so this new warning is a true positive.