{ "tokens": { "input": 100514, "cache_read": 184338, "cache_write": 3762, "output": 34853 }, "reviews": [ { "key": [ "https://ftp.debian.org/debian/pool/main/a/ampr-ripd/ampr-ripd_2.4.1.orig.tar.gz", "your ampr-ripd-2.4.1/ampr-ripd.c:1448:14: style: Variable 'hdr' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`hdr` is set once with `hdr = (rip_header *)buf;`. In the code shown it is only read (`hdr->version`, `hdr->command`). Declaring it `const rip_header *` would be valid, so the new constVariablePointer warning looks like a true positive. The PR stops treating compound assignments through aliased pointers as a write to the pointee. That matches the new test, where `p = r; r += s;` no longer counts as modifying `*p`. Main most likely missed this warning because of a similar compound assignment to `buf` (e.g. advancing the buffer) after the alias. Confidence is not high because the rest of the function is not shown." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/c/canu/canu_2.3+dfsg.orig.tar.xz", "your canu-2.3/src/utility/src/htslib/cram/cram_io.c:660:20: style: Variable 'up' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In safe_ltf8_get, 'up' is only read through (up[0], up[1], ...) and is never used to write data. The sibling function safe_itf8_get already declares the same pointer as 'const unsigned char *up'. So declaring it pointer to const is valid, and the new constVariablePointer warning is a true positive. Main most likely missed it because the compound assignments '(*cp)+=N' on the aliased pointer were wrongly treated as modifications; the PR now handles compound assignments through an extra indirection more precisely." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/c/chafa/chafa_1.18.2.orig.tar.gz", "your chafa-1.18.2/chafa/internal/chafa-string-util.c:116:9: error: Uninitialized variable: reg [uninitvar]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`reg` is declared without an initializer, and the first loop iteration runs `reg <<= 8`, which reads the uninitialized value. The source comment and the suppressed -Wuninitialized pragmas confirm the read is real and intentional: the author relies on the garbage being harmless. In C, reading an uninitialized automatic variable whose address is taken gives an indeterminate value, so this is still a genuine uninitialized read. The PR makes compound assignment count as a read of the old value, which matches the new test (`y <<= i` \u2192 uninitvar). The new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/d/darkplaces/darkplaces_0~20180908~beta1+git20260122.orig.tar.xz", "your darkplaces-0~20180908~beta1+git20260122/gl_rsurf.c:160:3: style: Variable 'bl' is assigned an expression that holds the same value. [redundantAssignment]\n darkplaces-0~20180908~beta1+git20260122/gl_rsurf.c:143:6: note: bl is assigned 'intblocklights' here.\n darkplaces-0~20180908~beta1+git20260122/gl_rsurf.c:160:3: note: Variable 'bl' is assigned an expression that holds the same value." ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "At line 143 `bl = intblocklights;` is assigned. Between there and line 160, `bl` itself is never modified. `memset(bl, ...)` takes the pointer by value, and `bl[i*3+0] += ...` writes to the pointed-to data, not to the pointer. So at line 160 `bl` still holds `intblocklights`, and the reassignment really is redundant. Before the PR, the compound assignment through `bl[...]` was wrongly treated as changing `bl`. The PR fixes that, so this new warning is a true positive. The reset is harmless defensive code, but the message is accurate." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/d/dascrubber/dascrubber_1.1.orig.tar.gz", "your DASCRUBBER-1.1/DB.c:1911:18: style: Variable 'dp' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "regression", "confidence": "medium", "explanation": "`dp` is the `readdir()` result, and the code does `name = dp->d_name;` where `name` is a plain `char *`. If `dp` were declared `const struct dirent *`, then `dp->d_name` would be a const array. Assigning it to `char *name` would discard the qualifier: a compiler warning in C, an error in C++. So the suggestion cannot be applied without further changes. Main did not report this. The PR changed how assignments are treated in `isVariableChanged`, which apparently stopped recognising this assignment as a possible write through `dp`. That makes this a new false positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/d/dircproxy/dircproxy_1.0.5.orig.tar.gz", "your dircproxy-1.0.5/src/irc_client.c:1503:5: error: If memory allocation fails: pointer addition with NULL pointer. [nullPointerArithmeticOutOfMemory]\n dircproxy-1.0.5/src/irc_client.c:1501:28: note: Assuming allocation function fails\n dircproxy-1.0.5/src/irc_client.c:1501:12: note: Assignment 'c=nick=(char*)malloc(strlen(tried)+2)', assigned value is 0\n dircproxy-1.0.5/src/irc_client.c:1503:5: note: Null pointer addition" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`c = nick = malloc(...)` is never checked for NULL. If the allocation fails, `c += strlen(nick) - 1` on line 1503 does arithmetic on a NULL pointer. Before the PR, the compound assignment counted as a write that dropped the null value. Now it is treated as a read and then an invalidation, so the addition is correctly flagged. This matches the updated testnullpointer expectation for `p += a`. The `strcpy` on line 1502 would fail first, so the warning is somewhat redundant, but it is a genuine unchecked-malloc issue, so this is a valid new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/ggml/ggml_1.0.0.orig.tar.gz", "your ggml-org-ggml-1d3d8b2/src/ggml-hexagon/htp/hmx-fa-kernels.h:54:20: style: Parameter 'out_tile' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "regression", "confidence": "medium", "explanation": "`out_tile` is the output tile of an HMX dot-product kernel. The shown part loads and multiplies into the accumulator via inline asm, and the result is presumably stored through `out_tile` in a later asm block. I could not see that block. Cppcheck drops asm operands, so it cannot see writes made by inline asm. Before the PR, some modification of `out_tile` (likely pointer arithmetic or a compound assignment) happened to keep the pointer from being treated as read-only. With the PR, a compound assignment no longer counts as changing the pointee, so the new constParameterPointer warning appears. Since the pointee is almost certainly written by asm, suggesting `const` is misleading, so this is likely a new false positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gimp/gimp_3.2.8.orig.tar.xz", "your gimp-3.2.8/plug-ins/file-sgi/sgi-lib.c:903:26: style: Variable 'start' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In write_rle16, 'start' is only assigned from 'row', incremented, compared via 'row - start', and dereferenced for reading (putshort(*start, sgip)). Nothing is ever written through it, so it can be 'const unsigned short *'. The new warning is a true positive. It probably appears because compound assignments like 'row += 2' are no longer wrongly treated as writing through the pointer, which the PR's own constVariablePointer test also covers." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/glide/glide_2002.04.10ds1.orig.tar.gz", "your glide-2002.04.10ds1/glide3x/cvg/init/info.c:73:11: warning: Uninitialized variable: rd_col [uninitvar]\n glide-2002.04.10ds1/glide3x/cvg/init/info.c:69:20: note: Assuming condition is false\n glide-2002.04.10ds1/glide3x/cvg/init/info.c:73:11: note: Uninitialized variable: rd_col" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "`rd_x` starts at 0 in the inner loop, so the first iteration always takes the `(rd_x & 1)==0` branch and assigns `rd_col`. The else branch `rd_col >>= 16` only runs on odd `rd_x`, after `rd_col` has been set in the previous iteration. The \"Assuming condition is false\" path cannot happen on the first iteration. The PR now treats compound assignment as a read of an uninitialized value, but here the variable is always initialized on the earlier loop iteration. This is a new false positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/glusterfs/glusterfs_11.2.orig.tar.gz", "your glusterfs-11.2/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c:284:5: error: If memory allocation fails: pointer addition with NULL pointer. [nullPointerArithmeticOutOfMemory]\n glusterfs-11.2/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c:275:17: note: Assuming allocation function fails\n glusterfs-11.2/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c:275:17: note: Assignment 'start=mmap(NULL,nleft,PROT_READ,MAP_PRIVATE,from_fd,0)', assigned value is 0\n glusterfs-11.2/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c:282:11: note: mover is assigned 'start' here.\n glusterfs-11.2/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c:284:5: note: Null pointer addition" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "`mmap` reports failure by returning `MAP_FAILED` ((void*)-1), not NULL. The code checks `start == MAP_FAILED` and jumps to `out` on failure. When `mmap` succeeds with a NULL address hint, it does not return 0. So `mover = start` is never NULL at `MOVER_MOVE(mover, nleft, start_offset)`, which advances the pointer. The new nullPointerArithmeticOutOfMemory warning, which assumes the allocation returned 0, is a false positive. It became visible because the PR now treats the compound assignment (`mover +=`) inside the macro as a read of the null value." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gnumach/gnumach_1.8+git20261028.orig.tar.xz", "your gnumach-1.8+git20261028/linux/pcmcia-cs/modules/cistpl.c:778:17: style: Variable 'q' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In parse_jedec, 'q' is set to 'p + tuple->TupleDataLen' and is only read afterwards, in the comparison 'p > q-2'. Nothing is ever written through 'q', so it could be declared 'const u_char *q'. The new constVariablePointer warning is a true positive. The PR stops treating compound assignments like 'p += 2' as modifying the pointed-to data, which is likely why this missed case is now reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gnuradio/gnuradio_3.10.12.0.orig.tar.gz", "your gnuradio-3.10.12.0/gr-dtv/lib/atsc/atsc_viterbi_gen.cc:72:27: style: Variable 'next_sym_seg' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`next_sym_seg` is a local cursor into `symbols`. In the visible code it is assigned from `symp` and then only compared (`symp >= next_sym_seg`). Elsewhere in the function it is likely only re-seated, by plain assignment or compound arithmetic such as `+=`. That later code is not shown, so this is an inference from the PR and the code's purpose. Such changes move the pointer itself and do not write through it. Before this PR, `isVariableChanged` treated a compound assignment on the pointer as a change of the pointee, which hid this warning. The PR's new test case (`r += s`) has the same pattern. Declaring it `const unsigned char *next_sym_seg` would be valid, so the new constVariablePointer warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/grub2/grub2_2.16.orig.tar.xz", "your grub-2.16/grub-core/lib/libgcrypt/cipher/rijndael.c:1290:18: style: Variable 'last_iv' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In _gcry_aes_cbc_enc, `last_iv` is only assigned (`last_iv = iv`, `last_iv = outbuf`), compared with `iv`, and passed as a source argument to cipher_block_xor and cipher_block_cpy. In libgcrypt both of those take `const void *` sources. Nothing is ever written through `last_iv`, so declaring it `const unsigned char *` is valid and the warning is a true positive. The reported line looks offset from the snippet, but column 18 matches the `last_iv` declaration. Main probably missed it because `outbuf += BLOCKSIZE` (an alias source) was treated as modifying the pointee. This is the same pattern as the new test (`p = r; r += s;`)." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/h/hime/hime_0.9.11+git20231221.g1c15f1f+dfsg.orig.tar.xz", "your hime/src/IMdkit/lib/i18nUtil.c:149:12: error: If memory allocation fails: pointer addition with NULL pointer. [nullPointerArithmeticOutOfMemory]\n hime/src/IMdkit/lib/i18nUtil.c:146:38: note: Assuming allocation function fails\n hime/src/IMdkit/lib/i18nUtil.c:146:13: note: Assignment 'reply=(unsigned char*)malloc(reply_length)', assigned value is 0\n hime/src/IMdkit/lib/i18nUtil.c:147:14: note: Assignment 'replyp=reply', assigned value is 0\n hime/src/IMdkit/lib/i18nUtil.c:149:12: note: Null pointer addition" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`reply` is the result of `malloc` and is never checked for NULL. `replyp` is set to `reply`. If the allocation fails, `replyp += header_size` does arithmetic on a NULL pointer. Before the PR, the compound assignment counted as a write that dropped the null value, so the warning was missed. The PR now treats `+=` as a read as well, so this real out-of-memory issue is reported. That matches the updated test in testnullpointer.cpp. The `memmove(reply, ...)` on line 148 would also be a null dereference, so the code does have a real bug when allocation fails. This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/i/inn2/inn2_2.7.4.orig.tar.xz", "your inn2-2.7.4/lib/inndcomm.c:245:10: error: If memory allocation fails: pointer addition with NULL pointer. [nullPointerArithmeticOutOfMemory]\n inn2-2.7.4/lib/inndcomm.c:240:19: note: Assuming allocation function fails\n inn2-2.7.4/lib/inndcomm.c:240:19: note: Assignment 'buff=xmalloc(bufsiz)', assigned value is 0\n inn2-2.7.4/lib/inndcomm.c:241:9: note: Assuming condition is true\n inn2-2.7.4/lib/inndcomm.c:245:10: note: Null pointer addition" ], "verdict": { "verdict": "regression", "confidence": "medium", "explanation": "The PR now treats a compound assignment (`buff += HEADER_SIZE`) as reading the old pointer value. Because of that, the possible NULL from the allocation reaches line 245 and Cppcheck reports nullPointerArithmeticOutOfMemory. In INN, however, xmalloc is a checked wrapper (x_malloc) that calls a fatal error handler and never returns NULL; GNU xmalloc has the same semantics. So 'Assuming allocation function fails' cannot happen here, and the new warning is a false positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/i/iqtree3/iqtree3_3.1.4+dfsg.orig.tar.xz", "your iqtree3-3.1.4/pll/bipartitionList.c:333:4: warning: If memory allocation fails, then there is a possible null pointer dereference: e->treeVector [nullPointerOutOfMemory]\n iqtree3-3.1.4/pll/bipartitionList.c:329:44: note: Assuming allocation function fails\n iqtree3-3.1.4/pll/bipartitionList.c:329:19: note: Assignment 'e->treeVector=(unsigned int*)calloc((unsigned long)treeVectorLength,sizeof(unsigned int))', assigned value is 0\n iqtree3-3.1.4/pll/bipartitionList.c:330:6: note: Assuming condition is false\n iqtree3-3.1.4/pll/bipartitionList.c:333:4: note: Null pointer dereference" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "Line 329 sets e->treeVector from rax_calloc (calloc) and never checks it for NULL. Line 333 then indexes it with `e->treeVector[...] |= ...`. If the allocation fails, that is a real null dereference. Before the PR, the compound assignment through the array index was wrongly treated as modifying the pointer `e->treeVector` itself, which hid the warning. The PR fixes this, so the new nullPointerOutOfMemory warning is a correct true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/k/kmscon/kmscon_10.0.4.orig.tar.gz", "your kmscon-10.0.4/src/video/drm_shared.c:1467:9: error: Uninitialized variable: disp->flags [uninitvar]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "The new uninitvar warning at line 1467 is a false positive. `disp` is the iterator of `dlist_for_each_entry` over `video->displays`, so on each iteration it points to an existing display object taken from the list. `disp->flags` on those objects is set when the display is created; nothing here is uninitialized. Cppcheck probably mis-tracks the uninitialized declaration of `disp` through the macro-expanded loop (container_of/typeof). The PR now treats compound assignments as reads/changes, which exposes this. The result is a new false error." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/libg/libgphoto2/libgphoto2_2.5.34.orig.tar.xz", "your libgphoto2-2.5.34/camlibs/casio/ycctoppm.c:57:38: error: If memory allocation fails: pointer addition with NULL pointer. [nullPointerArithmeticOutOfMemory]\n libgphoto2-2.5.34/camlibs/casio/ycctoppm.c:54:14: note: Assuming allocation function fails\n libgphoto2-2.5.34/camlibs/casio/ycctoppm.c:54:14: note: Assignment '*ppm=malloc(*ppmSize=(headerSize+3*width*height))', assigned value is 0\n libgphoto2-2.5.34/camlibs/casio/ycctoppm.c:56:6: note: dst is assigned '*ppm' here.\n libgphoto2-2.5.34/camlibs/casio/ycctoppm.c:57:38: note: Null pointer addition" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The return value of `malloc` at line 54 is stored in `*ppm` and copied into `dst` without any NULL check. If allocation fails, `dst` is NULL, so `memcpy(dst, ...)` and `dst += headerSize` at line 57 operate on a NULL pointer. The new `nullPointerArithmeticOutOfMemory` warning on `dst += headerSize` is therefore a true positive. Before this PR, Cppcheck treated the compound assignment `+=` as a plain write that killed the null value, which hid the problem. The PR now handles compound assignment as a read, so the missing allocation check is reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/libl/liblouisutdml/liblouisutdml_2.12.0.orig.tar.gz", "your liblouisutdml-2.12.0/liblouisutdml/logging.c:98:5: error: If memory allocation fails: pointer addition with NULL pointer. [nullPointerArithmeticOutOfMemory]\n liblouisutdml-2.12.0/liblouisutdml/logging.c:88:24: note: Assuming allocation function fails\n liblouisutdml-2.12.0/liblouisutdml/logging.c:88:24: note: Assignment 'logMsg=malloc(logBufSize)', assigned value is 0\n liblouisutdml-2.12.0/liblouisutdml/logging.c:89:13: note: Assignment 'p=logMsg', assigned value is 0\n liblouisutdml-2.12.0/liblouisutdml/logging.c:98:5: note: Null pointer addition" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "logWidecharBuf() never checks the result of malloc. If it fails, logMsg and p are NULL, and `p += strlen(msg)` on line 98 is arithmetic on a NULL pointer, which is undefined behaviour in C. Before the PR, the compound assignment was treated as a plain overwrite of p, so the null value was dropped. Now that `+=` is recognised as a read-modify-write, the warning is found. This matches the updated nullPointerArithmetic test. The warning is a true positive about missing allocation-failure handling." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/libs/libsdl1.2/libsdl1.2_1.2.15+dfsg2.orig.tar.gz", "your SDL-1.2.15/src/video/riscos/SDL_riscosFullScreenVideo.c:435:72: style: Parameter 'rects' can be declared as pointer to const. However it seems that 'FULLSCREEN_UpdateRects16bpp' is a callback function, if 'rects' is declared with const you might also need to cast function pointer(s). [constParameterCallback]\n SDL-1.2.15/src/video/riscos/SDL_riscosFullScreenVideo.c:255:40: note: You might need to cast the function pointer here\n SDL-1.2.15/src/video/riscos/SDL_riscosFullScreenVideo.c:435:72: note: Parameter 'rects' can be declared as pointer to const" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In FULLSCREEN_UpdateRects16bpp, 'rects' is only read (rects->x, ->y, ->w, ->h) and the pointer itself is incremented. Nothing is ever written through it, so it could be 'const SDL_Rect *'. The function is used as a callback, and the warning correctly says the function pointer may need a cast. The sibling 8bpp and 32bpp functions have the same pattern. Before this PR, Cppcheck likely treated the compound assignments in the function as modifying the variable and so missed this. The newly added warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/m/mrboom/mrboom_5.5+ds.orig.tar.xz", "your mrboom-5.5+ds/mrboom.c:763:1: style: Variable 'src' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`SPRITE_19_23` is a macro that declares a local `src` pointer into the sprite source data. It copies pixels from `src` to a destination buffer and advances `src` with pointer arithmetic such as `src += ...`. The PR stops treating compound assignment to the pointer itself (`r += s`) as a write through the pointer. This is the same case as the new testother test. `src` is only read through, so it can be pointer to const, and the new warning is plausibly a true positive. Confidence is medium because the macro body is not shown and it is defined in generated code." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/n/ncl/ncl_6.6.2.dfsg.1.orig.tar.xz", "your ncl-6.6.2.dfsg.1/ncarview/src/lib/libncarg_ras/sgiraster.c:593:17: style: Variable 'last' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`last` is only used in comparisons (`iptr <= last`, `iptr < last`, `iptr == last`, `iptr > last`) and is never dereferenced for writing, so it can be `const unsigned char *`. Main missed this because `last` is initialized from `iptr`, and `iptr += 3` was wrongly treated as modifying the pointed-to data. The PR stops treating compound assignment to the pointer itself as a write through it, so this new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/n/ndctl/ndctl_85.orig.tar.gz", "your pmem-ndctl-b30f916/ndctl/check.c:910:8: error: If memory allocation fails: pointer addition with NULL pointer. [nullPointerArithmeticOutOfMemory]\n pmem-ndctl-b30f916/ndctl/check.c:906:13: note: Assuming allocation function fails\n pmem-ndctl-b30f916/ndctl/check.c:906:13: note: Assignment 'addr=mmap(NULL,length,prot_flags,MAP_SHARED,bttc->fd,offset)', assigned value is 0\n pmem-ndctl-b30f916/ndctl/check.c:910:8: note: Null pointer addition" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "`mmap()` signals failure by returning `MAP_FAILED` (`(void*)-1`), not NULL, and the code checks `addr != MAP_FAILED` before doing `addr += page_offset`. A successful `mmap` with a NULL hint does not return 0 in practice, so `addr` is never NULL at line 910. The new nullPointerArithmeticOutOfMemory warning comes from the PR now treating compound assignment (`+=`) as a read of the pointer. It relies on a modeling assumption (allocation fails means NULL) that is wrong for `mmap`, so it is a false positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/n/ns2/ns2_2.35+dfsg.orig.tar.xz", "your ns-2.35/sensor-nets/landmark.cc:2939:18: style: Variable 'last_hop_ptr' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "The PR stops treating a compound assignment to the pointer itself (e.g. `walk += 3`) as a write through an alias that was copied from it. The new testother case `p = r; r += s;` expects constVariablePointer for `p`. In ns2, `last_hop_ptr` appears to be set from `walk` (`last_hop_ptr = walk;`) while `walk` is advanced with `+=` to walk the source-route hops. It then seems to be used only to read the previous hop's id and level. The usage lines are not shown, so this is inferred. If that holds, `last_hop_ptr` never writes through the pointer and could be `const unsigned char *`, making this a new true positive. `pkt_end_ptr`, declared on the same line, is not flagged, which fits with it being written through." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/o/ocp/ocp_3.5.0+ds.orig.tar.xz", "your ocp-3.5.0+ds/playit/itptrack.c:66:53: style: Parameter 'cpifaceSession' can be declared as pointer to const. However it seems that 'it_startrow' is a callback function, if 'cpifaceSession' is declared with const you might also need to cast function pointer(s). [constParameterCallback]\n ocp-3.5.0+ds/playit/itptrack.c:533:59: note: You might need to cast the function pointer here\n ocp-3.5.0+ds/playit/itptrack.c:66:53: note: Parameter 'cpifaceSession' can be declared as pointer to const" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`it_startrow` never reads or writes `cpifaceSession`; it only works on file-static globals (`xmcurpat`, `curdata`, `xmcurrow`, \u2026). So the parameter could be `const struct cpifaceSessionAPI_t *`. The warning correctly uses the callback variant and notes that the function pointer at line 533 would need a cast. Main likely missed it because of how the compound assignments in the function (`xmcurpat+=6`) were treated as modifications. The PR now treats compound assignments more precisely, so this new warning is technically correct. It is low-value, though, because the signature is fixed by the callback interface." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/o/ode/ode_0.16.6.orig.tar.gz", "your ode-0.16.6/OPCODE/Ice/IceRevisitedRadix.cpp:271:11: style: Variable 'h3' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`h3` is only read: `NbNegativeValues += h3[i]`. Here `h3[i]` is the right-hand side of a compound assignment, so nothing is written through `h3`. It can be declared `const udword*`. Main wrongly treated this use as a possible modification. The PR now only counts a compound assignment as a change when the indirection levels match. The new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/o/openblas/openblas_0.3.34+ds.orig.tar.xz", "your OpenMathLib-OpenBLAS-e016600/kernel/x86_64/dtrsm_kernel_LN_bulldozer.c:95:51: style: Parameter 'a' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In this DTRSM LN solve routine, `a` is the packed A panel. The visible inline asm only reads through it (the `vmovups (%2,%1,8)` loads), and the asm operand would advance only the pointer itself, never the data it points to. The PR stops treating compound pointer arithmetic (e.g. `p += k`) as a write through the pointer, so `a` is now correctly seen as read-only. Cppcheck still does not flag `bs` and `c`, which are the outputs written by the solve, so the analysis matches the code's semantics. Confidence is limited because the full asm body is not shown." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/o/openmw/openmw_0.51.0.orig.tar.gz", "your OpenMW-openmw-f4bec41/apps/openmw/mwmechanics/actors.cpp:470:23: style: Variable 'movement' can be declared as reference to const [constVariableReference]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "`movement` is a non-const reference returned by `getMovementSettings(actor)`. The code writes through it with `movement.mPosition[0] *= speedCoef;` and `movement.mPosition[1] *= speedCoef;`, so it cannot be a reference to const. The PR changed how `isVariableChanged` treats compound assignments that go through member and array access (the new `indirect - derefs - arrayAccess` condition). As a result, Cppcheck no longer sees that the referenced object is modified, and this new constVariableReference warning is a false positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/o/openni-sensor-primesense/openni-sensor-primesense_5.1.0.41.orig.tar.gz", "your Sensor-Stable-5.1.0.41/Source/XnFormats/XnFormatsMirror.cpp:152:11: style: Variable 'pDestEnd' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`pDestEnd` is only used in the comparison `pDest >= pDestEnd`. Nothing is ever written through it, so declaring it `const XnUInt8*` is valid, and comparing it with a non-const `XnUInt8*` compiles fine. The new constVariablePointer warning is a true positive. It probably appears because the PR's stricter handling of compound assignments (`pDest -= 4`, `pSrc += 4`) no longer treats them as changes to the pointed-to data." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/p/pcmciautils/pcmciautils_018.orig.tar.gz", "your pcmciautils-018/debug/parse_cis.c:214:14: style: Variable 'q' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In parse_jedec, 'q' is set to 'p + tuple->TupleDataLen' and is only used in the comparison 'p > q-2'. Nothing is ever written through 'q', so declaring it 'const u_char *q' is valid. The new constVariablePointer warning is a true positive. It appears because the PR stops treating the compound assignment 'p += 2' as a write through the pointer." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/p/pcsxr/pcsxr_1.9.94.orig.tar.xz", "your pcsxr/win32/zlib/deflate.c:752:21: style: Variable 'strend' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "regression", "confidence": "medium", "explanation": "In zlib's longest_match, `strend` is used in `scan < strend` and `len = MAX_MATCH - (int)(strend - scan)`. It is also used in `scan = strend - MAX_MATCH;`, where `scan` is a non-const `Bytef *`. Making only `strend` a `const Bytef *` would assign a const pointer to a non-const one, which is a qualifier-discarding warning in C and an error in C++. `scan` is not newly reported, so the advice cannot be followed as given. The warning probably appeared because the PR no longer treats compound assignments like `scan += 2` as modifying the pointee, which weakened the alias tracking through `scan`. This is likely a new false positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/p/poco/poco_1.14.2.orig.tar.bz2", "your poco-1.14.2-all/Foundation/src/DateTime.cpp:342:13: style: Variable 'lookup' can be declared as const array [constVariable]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`lookup` is a static int array that is only read, via `lookup[month]` in the return expression. It is never written, so declaring it `static const int lookup[]` is valid. The new constVariable warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/p/polyml/polyml_5.8.1.orig.tar.gz", "your polyml-5.8.1/libpolyml/libffi/src/moxie/ffi.c:180:9: style: Variable 'register_args_ptr' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`register_args_ptr` is set to `(char*)register_args` and later reassigned to `(char*)®ister_args[1]`. In the visible code it is never dereferenced or written through. In libffi's moxie closure code it is at most used for pointer comparison or arithmetic, never for writing. Declaring it `const char *` would compile and be correct, so the new constVariablePointer warning looks like a true positive. The PR now treats compound assignments (e.g. `ptr += 4`) through pointers more precisely, which likely uncovered this missed case. The rest of the function is not shown, hence medium confidence." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/p/powermanga/powermanga_0.93.1.orig.tar.gz", "your powermanga-0.93.1/src/gfxroutines.c:820:3: style: Variable 'src' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In the COPY2X_512x440 macro, 'src' is only used to read pixels (`*src++` on the right-hand side) and is advanced with `src += 256`. The pointed-to data is never written, so 'src' could be declared as `const TYPE *`. Main wrongly treated `src += 256` as a change to the pointee and stayed silent. The PR fixes this: a compound assignment to the pointer itself no longer counts as modifying the data it points to. The new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/p/pymol/pymol_3.1.0+dfsg.orig.tar.xz", "your pymol-open-source-3.1.0/layer0/Matrix.cpp:825:35: style: Parameter 'G' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In the visible body of MatrixGetRMS, the parameter `G` is never used: the function only reads `v1`, `v2` and `wt` and computes a local RMS value. Nothing is written through `G`, so declaring it `const PyMOLGlobals *` is valid, and Cppcheck reports unused pointer parameters by design. The PR changed how compound assignments are treated as variable changes, which plausibly removed a spurious 'changed' classification that was suppressing this warning. The new warning looks like a true positive, though the exact reason main missed it is not visible in the snippet." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/q/qemu/qemu_11.2.0~rc0+ds.orig.tar.xz", "your qemu-11.2.0-rc0/roms/u-boot/drivers/net/netconsole.c:259:45: style: Parameter 'dev' can be declared as pointer to const. However it seems that 'nc_stdio_puts' is a callback function, if 'dev' is declared with const you might also need to cast function pointer(s). [constParameterCallback]\n qemu-11.2.0-rc0/roms/u-boot/drivers/net/netconsole.c:338:13: note: You might need to cast the function pointer here\n qemu-11.2.0-rc0/roms/u-boot/drivers/net/netconsole.c:259:45: note: Parameter 'dev' can be declared as pointer to const" ], "verdict": { "verdict": "improvement", "confidence": "low", "explanation": "In nc_stdio_puts the parameter 'dev' is never written or dereferenced for writing; it is not used at all. Declaring it as pointer to const is therefore technically valid, and the message already notes that the function is a callback and may need a function-pointer cast. So the new warning is not a false positive. It is unclear why the PR exposes it here but not for the similar callbacks nc_stdio_putc/getc. This function contains the compound assignments 's += send_len' and 'len -= send_len', which the PR now handles differently, but that link is unconfirmed. It looks like a low-value but correct style finding." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rebol/rebol_3.22.5.orig.tar.gz", "your rebol-3.22.5/src/core/n-math.c:55:37: style: Parameter 'ds' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "Trig_Value only reads through 'ds', via the macros D_ARG(1), D_REF(2) and AS_DECIMAL. The only compound assignments in the function ('dval += ...') modify the local double 'dval', not anything 'ds' points to. The PR stops treating compound assignments as modifications of a pointer's pointee when the indirection does not match. That lets Cppcheck see that nothing is written through 'ds'. The function is static and called directly, so 'const REBVAL *ds' looks valid and the new constParameterPointer warning is likely a true positive. The macro definitions are not shown, so confidence is medium." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/relion/relion_5.1.1+ds.orig.tar.xz", "main 3dem-relion-e47503a/src/acc/sycl/sycl_memory_pool.cpp:270:3: error: Uninitialized variable: bytes [legacyUninitvar]" ], "verdict": { "verdict": "neutral", "confidence": "medium", "explanation": "In get_pool_size(), `bytes` is never initialized and `bytes += m._block_bytes` reads it, so this is a real bug. The PR makes compound assignment count as a read in ValueFlow, so the uninitvar check now reports it. The legacyUninitvar error goes away because the newer check already covers the same location; the 'your' line at 270:3 is the replacement. The bug is still reported, with a valueflow path note, but the severity drops from error to warning ('Assuming container is not empty'). Overall this is a re-labeling of the same true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/s/samtools-legacy/samtools-legacy_0.1.19+dfsg.orig.tar.xz", "your samtools-0.1.19/bam_sort.c:324:16: style: Variable 'beg' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In change_SO, 'beg' is only assigned from the char pointers q and p (char* converts implicitly to const char*). After that it is only read: compared with 0 and used in the pointer arithmetic beg - h->text. Nothing is ever written through it. Declaring it as 'const char *beg' would compile and keep the same behavior, so the new constVariablePointer warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/s/scipy/scipy_1.18.0.orig.tar.gz", "your scipy-scipy-7adb8c9/scipy/ndimage/src/ni_support.c:721:34: style: Condition 'position[ii]<=orgn' is always true [knownConditionTrueFalse]\n scipy-scipy-7adb8c9/scipy/ndimage/src/ni_support.c:719:30: note: Assuming that condition 'position[ii]==orgn' is not redundant\n scipy-scipy-7adb8c9/scipy/ndimage/src/ni_support.c:721:34: note: Condition 'position[ii]<=orgn' is always true" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "Inside the `if (position[ii] == orgn)` branch, `position[ii] += ashape[ii] - fshape[ii] + 1;` modifies `position[ii]`. Whether `position[ii] <= orgn` afterwards holds depends on `ashape[ii] - fshape[ii] + 1`, so the condition is not always true. The PR's new check `indirect - derefs - arrayAccess == 0 || op == \"=\"` evidently stops treating the compound assignment through an array subscript as a change. Cppcheck therefore keeps the stale value from line 719 and reports a false knownConditionTrueFalse." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/s/sdcc/sdcc_4.5.0+dfsg.orig.tar.xz", "your sdcc-4.5.0+dfsg/support/regression/tests/gcc-torture-execute-990513-1.c:15:8: style: Variable 'BM_tab_base' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`BM_tab_base` is only assigned from `BM_tab` and compared with it in the loop condition. It is never written through; the writes go through `BM_tab` (`*--BM_tab = j`). So declaring it as `const int *BM_tab_base` is valid. Before the PR, `BM_tab += 0400` was treated as modifying the pointed-to data at indirection 1, which hid this warning. The PR stops treating compound assignment to a pointer as a write to its pointee, so this is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/s/siege/siege_4.1.7.orig.tar.gz", "your siege-4.1.7/src/ftp.c:244:7: warning: Uninitialized variable: bytes [uninitvar]\n siege-4.1.7/src/ftp.c:243:13: note: Assuming condition is true\n siege-4.1.7/src/ftp.c:244:7: note: Uninitialized variable: bytes" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In ftp_list, 'int bytes;' is declared without an initializer, and 'bytes += n;' reads it on the first loop iteration. That is a read of an uninitialized variable, so the warning is a true positive (the value is never used afterwards, but reading it is still undefined behaviour). The PR makes compound assignment count as a read of the old value, which matches its new uninitvar test case (x += i)." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/t/teeworlds/teeworlds_0.7.5.orig.tar.xz", "your teeworlds-0.7.5/src/engine/external/zlib/deflate.c:1262:21: style: Variable 'strend' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "regression", "confidence": "medium", "explanation": "This is zlib's longest_match(). Further down the function, `strend` is used both in comparisons (`scan < strend`) and in assignments back to the non-const pointer `scan`: `scan = strend - MAX_MATCH;` (or `strend - (MAX_MATCH-1)` in the UNALIGNED_OK branch). If `strend` were declared `const Bytef *`, assigning `strend - MAX_MATCH` to `Bytef *scan` would drop the const qualifier. That is a compiler diagnostic in C and an error in C++. So `strend` cannot simply be made pointer-to-const, and the new constVariablePointer warning is a false positive. It appears because the PR changed how isVariableChanged treats assignments and pointer usage." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/t/tensorflow/tensorflow_2.14.1+dfsg.orig.tar.xz", "your tensorflow-2.14.1/tensorflow/lite/core/subgraph.cc:406:14: error: If memory allocation fails: pointer addition with NULL pointer. [nullPointerArithmeticOutOfMemory]\n tensorflow-2.14.1/tensorflow/lite/core/subgraph.cc:400:47: note: Assuming allocation function fails\n tensorflow-2.14.1/tensorflow/lite/core/subgraph.cc:400:40: note: Assignment 'allocation=static_cast(malloc(allocation_size))', assigned value is 0\n tensorflow-2.14.1/tensorflow/lite/core/subgraph.cc:406:14: note: Null pointer addition" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "malloc's result is never null-checked, so if allocation fails, `allocation += sizeof(Params)` adds an offset to a NULL pointer, which is undefined behavior. Before the PR, the compound assignment was treated as an ordinary assignment, so the null value was dropped before the read. With the PR, the null value reaches the `+=`. This matches the PR's updated test, which now expects nullPointerArithmetic for `p += a`. The new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/t/traceroute/traceroute_2.1.6.orig.tar.gz", "your traceroute-2.1.6/traceroute/extension.c:140:26: style: Variable 'iext' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In try_extension, 'iext' is only read: it is used for iext->version and iext->checksum, passed to in_csum (traceroute declares it as taking a const void *), and used in sizeof. Nothing is written through it, so it can be declared as a pointer to const. The warning was probably missing before because 'iext' aliases 'buf', and the later 'buf += sizeof(*iext)' was wrongly treated as modifying the data 'buf' points to. The PR fixes that compound-assignment handling, which is the same pattern as its new constVariablePointer test (p = r; r += s;). This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/v/vlc/vlc_3.0.24.orig.tar.xz", "your vlc-3.0.24/modules/visualization/visual/effects.c:256:26: style: Condition 'peaks[i]peaks[i]' is not redundant\n vlc-3.0.24/modules/visualization/visual/effects.c:253:27: note: Assuming condition is true\n vlc-3.0.24/modules/visualization/visual/effects.c:256:26: note: Condition 'peaks[i] peaks[i])`, so there `height[i] <= peaks[i]`. Line 255 then does `peaks[i] -= PEAK_SPEED`, after which `peaks[i] < height[i]` can easily be true, for example when height equals peaks before the decrement. The condition is not always false, so this is a new false positive. The PR changed how compound assignments to array elements are tracked, and Cppcheck now mishandles the `-=` on `peaks[i]`. Its own note even says the 'assigned value is -1', which is wrong." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/x/xsystem35/xsystem35_2.20.0.orig.tar.gz", "your xsystem35-sdl2-2.20.0/src/cursor.c:363:11: style: Variable 'p' can be declared as pointer to const [constVariablePointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In read_bitmapinfo, 'p' is a copy of 'data' that is apparently only kept to compute the consumed byte count (like 'return (int)(data - p);' in the previous function). Nothing is ever written through 'p', so 'const uint8_t* p' is valid and the warning is a true positive. Before the PR, compound assignments like 'data += 4' on the aliased pointer were wrongly treated as modifying the pointee, which suppressed the warning. The PR fixes this in isVariableChanged, so the new warning is a correct new finding. Confidence is medium because the rest of the function is not shown." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/z/zmat/zmat_1.0.0+ds.orig.tar.xz", "your zmat-1.0.0/src/blosc2/internal-complibs/zstd/dictBuilder/divsufsort.c:551:41: style: Parameter 'last' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "In ss_rotate, `last` is used in `a = last - 1`, where `a` is a non-const `int*`. The code then writes through `a` (`*a-- = *b`, `*a = t`). If `last` were declared `const int*`, the assignment `a = last - 1` would not compile without a cast. So `last` cannot be a pointer to const, and the new constParameterPointer warning is a false positive. It most likely comes from the changed assignment/compound-assignment handling in isVariableChanged." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/z/zoitechat/zoitechat_2.19.1.orig.tar.xz", "your zoitechat-2.19.1/plugins/sysinfo/unix/pci.c:122:46: style: Parameter 'vendor' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In `pci_find_fullname`, `vendor` is only read. It is passed to `g_snprintf` as a `%s` argument and to `strstr` as the needle, which is a `const char*` parameter. The value written into `position` points into `buffer`/`vendorname`, not into `vendor`, so `position += 6` and `*(position) = '\\0'` do not change data through `vendor`. The PR stopped treating compound assignments like `position += 6` as a write through a pointer that may alias the parameter, so Cppcheck now sees that `vendor` can be `const char*`. This is a new true positive. Confidence is medium because the end of the function is not shown." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/z/zpaq/zpaq_7.15+repack.orig.tar.xz", "your libzpaq.cpp:5187:41: style: Parameter 'last' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "In ss_rotate, 'last' is used in 'a = last - 1', where 'a' is a non-const 'int *' that is later written through ('*a-- = *b', '*a = t'). If 'last' were declared 'const int *', 'last - 1' would be 'const int *' and could not be assigned to 'int *a', so the code would not compile. The new constParameterPointer warning is a false positive, most likely caused by the changed assignment handling in isVariableChanged." } } ], "started": "2026-11-17 02:22:19 UTC", "runner": "aws-testrunner-2" }