{ "tokens": { "input": 148036, "cache_read": 77952, "cache_write": 3248, "output": 23900 }, "reviews": [ { "key": [ "https://ftp.debian.org/debian/pool/main/b/blt/blt_3.0~1+08570046+dfsg.orig.tar.xz", "your blt-src-08570046d5f162d27b206b4479f7b27bc56e7ddd/src/bltArcBall.c:352:28: style: Parameter 'A' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`HMatrix` is a typedef for a 2D double array, so parameter `A` decays to a pointer to rows. `MatrixToQuaternion` only reads `A[i][j]` and writes only through `q`, so `A` could be declared `const HMatrix A`. Before the PR, the check skipped variables whose type came from a typedef. The PR now reports typedef'd arrays like this one, matching its new test case. The finding is correct. One minor caveat: in C before C23, passing a non-const 2D array to a const-qualified array parameter can trigger pedantic compiler warnings." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/c/chocolate-doom/chocolate-doom_3.1.1.orig.tar.gz", "your chocolate-doom-chocolate-doom-3.1.1/src/aes_prng.c:891:29: style: Parameter 'key' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`prng_seed_t` is an array typedef (`byte[16]`), so the parameter `key` decays to `byte*`. It is only passed to `AES_SetKey`, whose key input is presumably `const byte *` (as in the Linux AES code it is based on). Writing `const prng_seed_t key` is valid C and gives a pointer to const byte. The old typedef bailout is meant for typedefs that hide a pointer, so it should not suppress array typedefs. The new warning is a plausible true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/c/chocolate-doom/chocolate-doom_3.1.1.orig.tar.gz", "your chocolate-doom-chocolate-doom-3.1.1/src/heretic/p_enemy.c:2345:23: style: Variable 'bossType' can be declared as const array [constVariable]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "bossType is a static local array of mobjtype_t (a typedef'd enum). In this function it is only read, through the comparison bossType[gameepisode - 1]. It could be declared const. Before the PR the warning was suppressed because the type start token came from a simplified typedef. The PR now only skips the case where the typedef itself expands to a pointer, so this true positive is reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/c/chocolate-doom/chocolate-doom_3.1.1.orig.tar.gz", "your chocolate-doom-chocolate-doom-3.1.1/src/mus2mid.c:142:10: style: Variable 'endtrack' can be declared as const array [constVariable]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`endtrack` is a local `byte[]` array (byte is a typedef). It is initialized once and then only passed to `mem_fwrite`, which takes a `const void *` buffer, so it is never modified and can be declared const. Before this PR, the typedef'd element type made Cppcheck skip the check. The PR now only skips pointer typedefs, so this is a true positive that was previously missed." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/d/disulfinder/disulfinder_1.2.11.orig.tar.gz", "your disulfinder-1.2.11/disulfind/src/NN/multi-array.cpp:139:20: style: Parameter 'array' can be declared as pointer to const [constParameterReference]" ], "verdict": { "verdict": "regression", "confidence": "medium", "explanation": "`ARRAY1` is almost certainly a typedef for `REAL*`, so the parameter is `REAL*& array`. Its type end token is `&`, not a typedef'd `*`. The old check skipped typedef-based types unless the trailing `*` was written explicitly; that guard was deliberate. The new condition skips only when the end token is a typedef'd `*`, so this reference-to-typedef-pointer case is now reported. The code does only read through `array`. However, the user cannot apply the suggestion through the typedef: `const ARRAY1&` means `REAL* const&`, not pointer to const. They would have to drop the typedef. The message is also inaccurate, saying 'pointer to const' for a reference parameter. This looks like an unintended side effect of a fix meant for typedef'd arrays, so the new warning is noise." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/d/disulfinder/disulfinder_1.2.11.orig.tar.gz", "your disulfinder-1.2.11/disulfind/src/NN/multi-array.cpp:155:20: style: Parameter 'array' can be declared as pointer to const [constParameterReference]" ], "verdict": { "verdict": "regression", "confidence": "medium", "explanation": "`ARRAY1` is evidently a typedef for a pointer type such as `REAL*`, and the parameter is `ARRAY1 &array`. The old check deliberately skipped variables whose pointer comes from a simplified typedef, because the user cannot add a const to the pointee without dropping the shared typedef. The PR loosened that condition so this case is now reported. Acting on the warning is also awkward: `ARRAY1&` is a reference to a pointer. `const REAL*&` would not bind to the `REAL*` lvalues passed by callers such as `norm1(array[i], n2)`. The new warning is therefore not practically actionable and is a newly introduced false positive. It is an unintended side effect of a fix aimed at arrays of typedef'd element types." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/d/disulfinder/disulfinder_1.2.11.orig.tar.gz", "your disulfinder-1.2.11/disulfind/src/NN/multi-array.cpp:243:42: style: Parameter 'array' can be declared as pointer to const [constParameterReference]" ], "verdict": { "verdict": "regression", "confidence": "medium", "explanation": "ARRAY1 is evidently a pointer typedef: arrays are created with new[], freed with delete[], and indexed. So the parameter is a reference to a pointer (`double*&` hidden behind the typedef). Before the PR, the typedef bailout skipped it. The new condition only skips when typeEndToken is a typedef '*'. For this reference parameter the type ends in '&', so the bailout no longer applies. The suggestion is not a real fix: the element type is hidden in the typedef. A `const T*&` parameter also cannot bind to the non-const `array[i]` lvalue passed by the ARRAY2 overload. The message also mixes 'pointer to const' with the constParameterReference id. This is a side effect of the PR, which targeted typedef'd array element types (#15167), and adds a noisy, hard-to-act-on warning." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/d/disulfinder/disulfinder_1.2.11.orig.tar.gz", "your disulfinder-1.2.11/disulfind/src/NN/multi-array.cpp:87:37: style: Parameter 'src' can be declared as pointer to const [constParameterReference]" ], "verdict": { "verdict": "regression", "confidence": "medium", "explanation": "`ARRAY1` is a pointer typedef (e.g. `REAL*`), and `src` is declared as `ARRAY1 &src`. After simplification this becomes `REAL * & src`, so the type ends in `&`, not `*`. The old check skipped variables whose type comes from a typedef unless an explicit non-typedef `*` ends the type, so this was suppressed. The new condition skips only when the type ends in a typedef `*`, so this reference-to-typedef-pointer now gets reported. The PR was meant to enable warnings for arrays of typedef'd elements (#15167); this pointer case is an unintended side effect. Writing `const ARRAY1&` would only give `REAL* const&`, not a pointer to const. Following the advice means dropping the typedef and spelling out `const REAL* const&`. That is the kind of noise the old typedef suppression was designed to avoid." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/f/flashbench/flashbench_62+git20120606.2e30b19.orig.tar.xz", "your flashbench-62+git20120606.2e30b19/flashbench.c:24:36: style: Parameter 'data' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "ns_min only reads data[i] and never writes to it, so 'data' can be declared as 'const ns_t data[]'. Before the PR, the warning was suppressed because ns_t is a typedef. The PR now only skips pointer typedefs, so this correct warning is reported. This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/f/flashbench/flashbench_62+git20120606.2e30b19.orig.tar.xz", "your flashbench-62+git20120606.2e30b19/flashbench.c:49:36: style: Parameter 'data' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In ns_max, the parameter 'data' (ns_t data[], where ns_t is a typedef for long long) is only read inside the loop and is never written. It can be declared as const ns_t data[]. Before the PR, the warning was skipped only because the element type is a typedef. The PR now limits that skip to cases where the pointer itself comes from the typedef, so this true positive is reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/f/flashbench/flashbench_62+git20120606.2e30b19.orig.tar.xz", "your flashbench-62+git20120606.2e30b19/flashbench.c:62:36: style: Parameter 'data' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "ns_t is a typedef (likely long long). ns_avg only reads data[i] to compute a sum and never writes through it, so `const ns_t data[]` is valid. The old check skipped variables whose type came from a simplified typedef, even when the typedef was not a pointer. The PR now only skips pointer typedefs, so this correct warning is newly reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/f/flashbench/flashbench_62+git20120606.2e30b19.orig.tar.xz", "your flashbench-62+git20120606.2e30b19/flashbench.c:94:29: style: Parameter 'ns' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In `regression()`, the parameter `ns` (type `ns_t ns[]`, where `ns_t` is a typedef) is only read (`ns[i]` in the sums) and never written. So `const ns_t ns[]` is valid. Before the PR, the check skipped it only because the element type came from a simplified typedef. The PR narrows that skip to typedefs of pointer types, so this correct warning is now reported. This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gcc-h8300-hms/gcc-h8300-hms_3.4.6+dfsg2.orig.tar.gz", "your gcc-h8300-hms-3.4.6+dfsg2/gcc/debug.c:64:29: style: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const. However it seems that 'debug_true_tree' is a callback function, if 'ATTRIBUTE_UNUSED' is declared with const you might also need to cast function pointer(s). [constParameterCallback]\n gcc-h8300-hms-3.4.6+dfsg2/gcc/debug.c:35:3: note: You might need to cast the function pointer here\n gcc-h8300-hms-3.4.6+dfsg2/gcc/debug.c:64:29: note: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "The parameter 'block' has type 'tree', a typedef for 'union tree_node *'. ATTRIBUTE_UNUSED is an unexpanded macro, so Cppcheck takes it as the parameter name. Because the pointer is hidden inside a typedef, the user cannot write 'pointer to const' by adding const (const tree would make the pointer const, not the pointee). The old condition skipped this case. The PR narrowed the skip so that it only applies when the type end token is a simplified-typedef '*'. This typedef'd pointer now slips through. The warning names the wrong identifier ('ATTRIBUTE_UNUSED'), cannot be acted on without changing the type, and appears as a flood of similar new reports across the package. This is a false positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gcc-h8300-hms/gcc-h8300-hms_3.4.6+dfsg2.orig.tar.gz", "your gcc-h8300-hms-3.4.6+dfsg2/gcc/genattrtab.c:2445:17: style: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const. However it seems that 'one_fn' is a callback function, if 'ATTRIBUTE_UNUSED' is declared with const you might also need to cast function pointer(s). [constParameterCallback]\n gcc-h8300-hms-3.4.6+dfsg2/gcc/genattrtab.c:2389:53: note: You might need to cast the function pointer here\n gcc-h8300-hms-3.4.6+dfsg2/gcc/genattrtab.c:2445:17: note: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "In `one_fn (rtx exp ATTRIBUTE_UNUSED)`, `rtx` is a typedef for `struct rtx_def *`. Because the `ATTRIBUTE_UNUSED` macro is not defined in this configuration, Cppcheck treats 'ATTRIBUTE_UNUSED' as the parameter name, and that name is wrong. The pointer comes from the typedef: the typeEndToken '*' is itself part of the simplified typedef. The old condition skipped any variable whose type starts with a simplified typedef, unless it ended in a non-typedef '*'. The new condition only skips when typeEndToken is a '*' that comes from the typedef. Cppcheck's typeEndToken for a typedef'd pointer may not be that '*', so these typedef'd pointers are no longer suppressed. That is the effect seen across the package. The user also cannot write a pointer-to-const via the `rtx` typedef without changing the type (`const rtx` makes the pointer const, not the pointee). The function is also used as a callback through a function pointer, so changing the signature would break the assignment. The new warning is a false positive with a bogus parameter name." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gcc-h8300-hms/gcc-h8300-hms_3.4.6+dfsg2.orig.tar.gz", "your gcc-h8300-hms-3.4.6+dfsg2/gcc/hooks.c:174:28: style: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "`rtx` is a typedef for `struct rtx_def *`. Because the ATTRIBUTE_UNUSED macro is not expanded, Cppcheck takes 'ATTRIBUTE_UNUSED' as the parameter name, and the warning names a macro, not a variable. The type comes entirely from the typedef, so both the type start token and the end '*' are simplified-typedef tokens. Main skipped this case. The PR changed the `!(A && !B)` logic to `A && B`, which no longer skips it for pointers, so these warnings now appear. Suggesting 'pointer to const' for a typedef'd pointer type like `rtx` is not actionable: `const rtx` makes the pointer const, not the pointee. The reported name is also wrong. This is a new false positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gcc-h8300-hms/gcc-h8300-hms_3.4.6+dfsg2.orig.tar.gz", "your gcc-h8300-hms-3.4.6+dfsg2/gcc/hooks.c:187:41: style: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "Line 187 declares the parameter `rtx a ATTRIBUTE_UNUSED`. `rtx` is a typedef for `struct rtx_def *`, and `ATTRIBUTE_UNUSED` is an unexpanded macro. Cppcheck therefore takes `ATTRIBUTE_UNUSED` as the parameter name and `a` as the last token of the type. The new condition only skips a typedef type when the type's last token is the typedef's own `*`. Here the last token is `a`, so the old skip no longer applies. The result is a warning about a parameter named 'ATTRIBUTE_UNUSED'. Its advice also cannot be followed directly: writing `const rtx` would make the pointer itself const, not the pointee. The function is also a generic hook whose signature must match a hook type. This is a new false positive caused by misparsing typedef'd pointers, and the same pattern produces many similar lines across the package." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gcc-h8300-hms/gcc-h8300-hms_3.4.6+dfsg2.orig.tar.gz", "your gcc-h8300-hms-3.4.6+dfsg2/gcc/langhooks.c:224:33: style: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "`ATTRIBUTE_UNUSED` is an unexpanded macro, so Cppcheck takes it as the parameter name. `tree` is a typedef for a pointer, so the typedef is expanded and the `*` comes from the typedef. Making the parameter const would mean changing the typedef, or writing `const tree`, which gives a const pointer and not a pointer to const. The old code skipped this case because the type end `*` was a simplified typedef token. The PR's new condition seems meant to keep skipping it, but the warnings show it no longer does. This is likely because the `*` token is not flagged as a simplified typedef in this case. The result is a false positive with a bogus parameter name, repeated across many files." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gcc-h8300-hms/gcc-h8300-hms_3.4.6+dfsg2.orig.tar.gz", "your gcc-h8300-hms-3.4.6+dfsg2/gcc/langhooks.c:250:27: style: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "`ATTRIBUTE_UNUSED` is an unexpanded macro (normally `__attribute__((unused))`). Cppcheck takes it as the parameter name, so the warning names a non-existent parameter. `tree` is a typedef for a pointer (`typedef union tree_node *tree`). Here the `*` comes from the typedef, so suggesting a pointer-to-const is wrong or unhelpful. The parameter is also unused and the function is a lang hook whose signature is fixed. The PR changed the typedef skip condition so that, in this case, the check is no longer skipped. The result is many new false positives like this one." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gcc-h8300-hms/gcc-h8300-hms_3.4.6+dfsg2.orig.tar.gz", "your gcc-h8300-hms-3.4.6+dfsg2/gcc/langhooks.c:394:44: style: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "The new warning is a false positive. In GCC, `tree` is a typedef for a pointer type (`union tree_node *`), and `ATTRIBUTE_UNUSED` is an unexpanded macro. Cppcheck therefore takes `ATTRIBUTE_UNUSED` to be the parameter name. Main suppressed the warning because the pointer comes from a simplified typedef, so the user cannot simply write `const` at the pointed-to level. The PR changed that condition, so the warning now fires. It names 'ATTRIBUTE_UNUSED' as the parameter, which is wrong. It also suggests making a `tree` parameter a pointer to const, which cannot be done without changing the typedef. These are hook functions with fixed signatures. Many similar new warnings appear across the package, which confirms the PR is too permissive for pointer typedefs." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gcc-h8300-hms/gcc-h8300-hms_3.4.6+dfsg2.orig.tar.gz", "your gcc-h8300-hms-3.4.6+dfsg2/gcc/langhooks.c:435:60: style: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const [constParameterPointer]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "`tree` is a pointer typedef (`typedef union tree_node *tree`). Cppcheck does not know the `ATTRIBUTE_UNUSED` macro, so it treats it as the parameter name. The type end token becomes `t` instead of the typedef `*`. The PR's narrowed typedef check therefore no longer skips this case. The new warning names a bogus parameter 'ATTRIBUTE_UNUSED'. It also suggests pointer-to-const for a pointer hidden behind a typedef, which cannot be done by adding const to `tree`. This is a false positive, and it is part of a large batch of identical new ATTRIBUTE_UNUSED warnings." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/g/gcc-h8300-hms/gcc-h8300-hms_3.4.6+dfsg2.orig.tar.gz", "your gcc-h8300-hms-3.4.6+dfsg2/gcc/sched-ebb.c:108:32: style: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const. However it seems that 'can_schedule_ready_p' is a callback function, if 'ATTRIBUTE_UNUSED' is declared with const you might also need to cast function pointer(s). [constParameterCallback]\n gcc-h8300-hms-3.4.6+dfsg2/gcc/sched-ebb.c:198:3: note: You might need to cast the function pointer here\n gcc-h8300-hms-3.4.6+dfsg2/gcc/sched-ebb.c:108:32: note: Parameter 'ATTRIBUTE_UNUSED' can be declared as pointer to const" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "`rtx` is a typedef for a pointer (`struct rtx_def *`). Cppcheck does not know the `ATTRIBUTE_UNUSED` macro, so it misreads `rtx insn ATTRIBUTE_UNUSED` and takes 'ATTRIBUTE_UNUSED' as the parameter name. The type then ends at `insn`, not at the typedef `*`. Main skipped this parameter because its type starts with a simplified typedef. The PR narrowed that skip to cases where the type ends with a typedef `*`, so this parameter is no longer skipped. The result is a nonsensical warning about a parameter named 'ATTRIBUTE_UNUSED'. The suggestion is also hard to act on: adding `const` to a pointer typedef does not give a pointer to const. Many such new warnings appear across the package, so the PR adds false positives here." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/h/highs/highs_1.14.0+ds.orig.tar.xz", "your ERGO-Code-HiGHS-7df0786/extern/amd/amd_postorder.c:19:13: style: Parameter 'Parent' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In amd_postorder, 'Parent' is an input that is only read (e.g. `parent = Parent [j]`). The comment even says it is not modified, and AMD's postorder never writes to it. Before this change, the warning was suppressed only because the element type `amd_int` is a typedef. The PR now treats typedef'd element types correctly, as in the new #15167 test. Declaring the parameter as a const array is valid, so this is a newly found true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/h/highs/highs_1.14.0+ds.orig.tar.xz", "your ERGO-Code-HiGHS-7df0786/extern/amd/amd_postorder.c:20:13: style: Parameter 'Nv' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`amd_int` is a typedef, and the old code skipped any pointer or array whose type started with a simplified typedef, so this warning was suppressed before. The comment marks `Nv` as an input that is not modified. In the visible code it is only read (`if (Nv [j] > 0)`), and in AMD's postorder it is only read elsewhere too. The parameter could therefore be declared const, and the new warning is a true positive the PR now correctly reports." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/h/highs/highs_1.14.0+ds.orig.tar.xz", "your ERGO-Code-HiGHS-7df0786/extern/amd/amd_postorder.c:22:13: style: Parameter 'Fsize' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`Fsize` is a typedef'd (`amd_int`) array parameter, documented as an input that is not modified. In `amd_postorder` it is only read (`frsize = Fsize[f]`) and is not passed to `amd_post_tree`. So it really can be declared const. Before the PR, the check skipped variables whose type came from a simplified typedef. The PR now reports array parameters of typedef type, which makes this a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/k/kali/kali_3.1+dfsg.orig.tar.xz", "your kali-3.1/symmetry.c:733:24: style: Parameter 'f' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "MATRIX appears to be a typedef for a 1-D numeric array, since it is indexed as f[0..3] with scalar arithmetic. In CopyMatrix, 'f' is only read (t[i]=f[i]), so declaring it 'const MATRIX f' is valid. It decays to a const element pointer, and existing calls that pass non-const MATRIX values still compile in C. The PR now skips only typedefs whose type ends in a typedef'd '*', where adding const would not reach the pointee. Array typedefs like this one are no longer wrongly skipped, so this is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/k/kali/kali_3.1+dfsg.orig.tar.xz", "your kali-3.1/symmetry.c:757:28: style: Parameter 's' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "MATRIX is an array typedef, almost certainly `float[4]`, since it is indexed s[0]..s[3]. The PR still skips pointer typedefs, so it is not a pointer type. In MatrixMultiply, 's' is only read and is never passed to a function taking a non-const MATRIX. Declaring it `const MATRIX s` (a const float pointer after adjustment) is valid C, and callers can still pass non-const arrays. The new warning is a true positive that was previously suppressed only because the type came from a typedef." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/k/kali/kali_3.1+dfsg.orig.tar.xz", "your kali-3.1/symmetry.c:757:38: style: Parameter 't' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "MATRIX is evidently an array typedef (e.g. `float[4]`), so the parameter `t` decays to `float *`. In MatrixMultiply, `t` is only read (`t[0]`..`t[3]`), never written. Declaring it `const MATRIX t` (i.e. `const float *`) is valid and correct. The PR stops skipping array-typedef variables in checkConstPointer; previously the simplified-typedef check suppressed this warning. This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/k/kali/kali_3.1+dfsg.orig.tar.xz", "your kali-3.1/symmetry.c:767:41: style: Parameter 'm' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`MATRIX` is a typedef for a small array (probably `float[4]`). In `VectorMatrixMult`, the parameter `m` is only read (`m[0]` through `m[3]`) and never written or passed on as non-const. Declaring it `const MATRIX m` is valid and does not change behavior. Before this PR, Cppcheck skipped any variable whose type came from a typedef. The PR now reports typedef'd arrays too, which gives a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/k/kali/kali_3.1+dfsg.orig.tar.xz", "your kali-3.1/symmetry.c:778:26: style: Parameter 's' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`MATRIX` is almost certainly an array typedef such as `typedef float MATRIX[4]`. In `InvertMatrix`, the parameter `s` is only read (`s[0]*s[3]`, `s[3]/det`, and so on). Only `d` is written. So `s` could be declared `const MATRIX s`, and the new constParameter warning is a true positive. Before this PR it was suppressed only because the type came from a typedef. The PR narrows that skip to pointer typedefs, which is exactly what lets this array-typedef case through." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/m/mmdb/mmdb_2.0.22.orig.tar.gz", "your mmdb2-2.0.22/mmdb2/mmdb_mattype.cpp:1774:32: style: Parameter 'iUB' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`intUniBin` is a typedef for a byte array, so the parameter `iUB` decays to a `byte*`. The function only reads `iUB[j]` and never writes through it. Declaring it as `const intUniBin iUB` is valid, and callers passing non-const arrays still compile. The PR stops the typedef check from suppressing this case, which makes the warning a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/m/mmdb/mmdb_2.0.22.orig.tar.gz", "your mmdb2-2.0.22/mmdb2/mmdb_mattype.cpp:1783:36: style: Parameter 'sUB' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In mmdb, `shortUniBin` is a typedef for a byte array, so the parameter `sUB` is really a byte pointer. `UniBin2short` only reads `sUB[j]` and never writes through it. Declaring it as `const shortUniBin sUB` is valid and accurate, so the new constParameter warning is a true positive. Before this PR, the simplified-typedef check suppressed it." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/m/mmdb/mmdb_2.0.22.orig.tar.gz", "your mmdb2-2.0.22/mmdb2/mmdb_mattype.cpp:1795:34: style: Parameter 'lUB' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`longUniBin` is almost certainly an array typedef such as `typedef byte longUniBin[N]`. `UniBin2long` only reads `lUB[j]` and never writes to it. Writing `const longUniBin lUB` makes the elements const (it becomes `const byte*`), so the suggestion is valid and compiles. The old code skipped every typedef'd type except `*`. That skip only matters for pointer typedefs, where `const P` means `T* const` rather than a pointer to const. The PR now limits the skip to pointer typedefs, so this real const-correctness finding is reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/m/mmdb/mmdb_2.0.22.orig.tar.gz", "your mmdb2-2.0.22/mmdb2/mmdb_mattype.cpp:1807:34: style: Parameter 'wUB' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In mmdb, `wordUniBin` is an array typedef (`byte[N]`), so the parameter `wUB` decays to `byte*`. `UniBin2word` only reads `wUB[j]` and never writes through it, so `const wordUniBin wUB` is valid and the suggestion is a true positive. Before this PR, the typedef'd type start token suppressed the warning. The PR now only skips cases where the pointer itself comes from a typedef. The modified parameters `rUB`/`srUB` in the nearby functions are correctly not reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/n/nlopt/nlopt_2.11.0.orig.tar.gz", "your stevengj-nlopt-88c424d/src/algs/subplex/subplex.c:1809:23: style: Variable 'bnsfac' can be declared as const array [constVariable]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`bnsfac` is a static `doublereal` lookup table (`doublereal` is a typedef for `double`) initialised to constants. In the f2c code it is only read as a coefficient table and never written. Before the PR, Cppcheck skipped any variable whose type started with a simplified typedef, so arrays of typedef'd element types were never reported. The PR narrows that skip to pointer typedefs only, matching the new test for #15167. Declaring this table `static const doublereal` is valid, so the new constVariable warning is a true positive. Confidence is medium because the code that uses `bnsfac` is not shown here." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/o/openmolcas/openmolcas_26.06.orig.tar.bz2", "your OpenMolcas-v26.06/src/mma_util/cgetmem.c:376:24: style: Parameter 'mentries' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "`mentry` is a typedef'd struct. In the default build (no `_DEBUGPRINT_MEM_`), `find_mentry` only reads `mentries[i].offset`, so `const mentry mentries[]` would compile and the new constParameter warning is correct. Before this PR the warning was suppressed only because the element type came from a typedef. The PR fixes that over-broad suppression, which is the same fix as the #15167 test case. One caveat: in the `_DEBUGPRINT_MEM_` configuration, `tgt = &mentries[i]` takes a non-const pointer and passes it to `dump_mentry(char*, mentry*)`, so const would need extra changes there. Cppcheck reports this kind of warning per configuration, so that limitation is a known general one." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rasmol/rasmol_2.7.6.0.orig.tar.gz", "your rasmol-2.7.6.0/src/molecule.c:1849:36: style: Parameter 'C' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "'Long' is a typedef, so main skipped this parameter. The PR now reports arrays of typedef'd element types, which are the same as plain arrays for const purposes. In TestBuriedSurface, C is only read (C[0], C[1], C[2] in the distance calculations), and nothing in the shown code writes to it. Declaring it 'const Long C[3]' looks valid, so this is a new true positive. The rest of the function body is not shown, hence medium confidence." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rasmol/rasmol_2.7.6.0.orig.tar.gz", "your rasmol-2.7.6.0/src/vector.c:198:19: style: Parameter 'u' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`Length(Real u[3])` only reads `u[0..2]` and never modifies them, so the parameter can be declared `const Real u[3]`. Before the PR, Cppcheck skipped this case because `Real` is a typedef: the old condition suppressed any variable whose type starts with a simplified typedef, unless it ended in a non-typedef `*`. The PR now only suppresses variables whose pointer itself comes from the typedef, so this array parameter is reported. This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rasmol/rasmol_2.7.6.0.orig.tar.gz", "your rasmol-2.7.6.0/src/vector.c:203:23: style: Parameter 'u' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "DotProduct only reads u[0..2] and never writes through u. Real is a typedef (float/double), so the old code skipped this array parameter because its type came from a simplified typedef. The PR now only skips when the pointer '*' itself comes from the typedef. 'Real u[3]' can safely be 'const Real u[3]', so the new constParameter warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rasmol/rasmol_2.7.6.0.orig.tar.gz", "your rasmol-2.7.6.0/src/vector.c:214:25: style: Parameter 'u' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In CrossProduct, 'u' is only read (u[0], u[1], u[2]) and is never written or passed on as non-const. Only 'n' is written. 'Real' is a typedef (double/float), so before the PR the check skipped it because the type came from a simplified typedef. With the PR, only pointer typedefs are skipped, so this valid suggestion to declare 'u' as const is now reported. It is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rasmol/rasmol_2.7.6.0.orig.tar.gz", "your rasmol-2.7.6.0/src/vector.c:214:36: style: Parameter 'v' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In CrossProduct, 'v' is only read (v[0], v[1], v[2]) to compute n, so it could be declared 'const Real v[3]'. Before this PR, the check was skipped because 'Real' is a simplified typedef. The PR now only skips pointers whose '*' itself comes from a typedef. For a plain 1D array, passing a non-const Real[3] to a const Real* parameter is valid C, so the new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rasmol/rasmol_2.7.6.0.orig.tar.gz", "your rasmol-2.7.6.0/src/vector.c:247:23: style: Parameter 'A' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In MultMatrix, `A` is only read (`A[i][k]` on the right-hand side) and never written. `Real` is a typedef for a floating-point type. Main skipped the warning only because the element type came from a typedef. The PR makes typedef'd element types behave like plain `double A[4][4]`, so the new constParameter warning is consistent with how Cppcheck treats non-typedef types. It is a valid suggestion. One minor caveat: in pre-C23 C, passing a non-const 2D array to a const-qualified 2D parameter can trigger compiler warnings. That caveat applies equally to non-typedef types and does not make this warning wrong." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rasmol/rasmol_2.7.6.0.orig.tar.gz", "your rasmol-2.7.6.0/src/vector.c:247:37: style: Parameter 'B' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In MultMatrix, B is only read (`A[i][k] * B[k][j]`) and never written, so declaring it const is valid. Before this PR the warning was suppressed only because the element type `Real` is a typedef. The PR makes typedef'd element types behave like plain types, so this is a newly found true positive. One caveat: in pre-C23 C, passing a non-const 2D array to a `const Real[4][4]` parameter can trigger compiler qualification warnings. That makes the suggestion slightly less practical, but it is still correct about the code's semantics." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rasmol/rasmol_2.7.6.0.orig.tar.gz", "your rasmol-2.7.6.0/src/vector.c:268:23: style: Parameter 'v' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "PrintVector only reads v[i] to pass it to sprintf and never writes it. 'Real' is a typedef (likely double), so declaring the parameter as 'const Real v[3]' is valid and correct. Before the PR, the check was skipped because the type started with a simplified typedef. The PR now only skips typedef'd pointer types, so this true positive is newly reported." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/r/rasmol/rasmol_2.7.6.0.orig.tar.gz", "your rasmol-2.7.6.0/src/vector.c:279:23: style: Parameter 'M' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "PrintMatrix only reads M[i][j] and passes the values to sprintf. It never writes to M, so the parameter could be declared as const Real M[4][4]. Before the PR, the warning was suppressed only because the element type 'Real' is a typedef. The PR keeps that suppression only when the pointer itself comes from the typedef. This is a new true positive. (In C, passing a non-const 2D array to a const parameter can trigger a compiler warning, but the stylistic suggestion is still valid.)" } }, { "key": [ "https://ftp.debian.org/debian/pool/main/s/siconos/siconos_4.4.0+dfsg.orig.tar.xz", "your siconos-4.4.0/externals/netlib/dctemplates/F2CLIBS/libF77/s_cat.c:7:42: style: Parameter 'rnp' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`ftnlen` is a typedef for an integer type. In `s_cat`, `rnp[]` is only read (`rnp[i] < nc`, `nc = rnp[i]`) and never written, so `const ftnlen rnp[]` would be valid. Before the PR, Cppcheck skipped this report because the parameter's type starts with a simplified typedef. The PR narrows that skip to pointer typedefs only, which correctly exposes this true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/u/unrtf/unrtf_0.21.13.orig.tar.gz", "your unrtf-0.21.13/src/word.c:273:6: style: Variable 'tags_to_opt' can be declared as const array [constVariable]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`tags_to_opt` is a local array of the typedef'd struct `Tag`. In the code shown, its elements are only read: `.name` and `.has_param` are passed to `strlen`, `strncmp` and `strcmp`, or compared. Nothing writes to it, so declaring it `const Tag tags_to_opt[]` is valid. The warning was previously suppressed only because the type came from a simplified typedef. The PR narrows that suppression to typedefs that are themselves pointer types, which matches its new test case (#15167). This is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/w/wabt/wabt_1.0.42+dfsg+~cs1.0.39.orig.tar.xz", "your wabt-1.0.42/wasm2c/benchmarks/dhrystone/src/dhry_2.c:133:15: style: Parameter 'Str_1_Par_Ref' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "In dhrystone, `Str_30` is a typedef for `char[31]`, so the parameter is really a `char*` to an array. `Func_2` only reads it: it passes elements by value to `Func_1` and passes the array to `strcmp`, which takes `const char*`. Writing `const Str_30 Str_1_Par_Ref` is valid C and makes the elements const. The warning is therefore a true positive. The PR now suppresses the check only for pointer typedefs, where `const` would bind to the pointer itself. Array typedefs like this one are no longer skipped." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/w/wabt/wabt_1.0.42+dfsg+~cs1.0.39.orig.tar.xz", "your wabt-1.0.42/wasm2c/benchmarks/dhrystone/src/dhry_2.c:133:37: style: Parameter 'Str_2_Par_Ref' can be declared as const array [constParameter]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "In Dhrystone, `Str_30` is `typedef char Str_30[31]`, so the parameter `Str_2_Par_Ref` is really a `char *`. In `Func_2` it is only read: it is indexed to pass a char by value to `Func_1`, and it is passed to `strcmp`, which takes `const char*`. Writing `const Str_30 Str_2_Par_Ref` is valid C and the function would still behave the same. Main skipped this case only because the type came from a typedef. The PR deliberately stops skipping array typedefs, which is the same pattern as its new test. The new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/x/xfce4-settings/xfce4-settings_4.20.5.orig.tar.bz2", "your xfce4-settings-4.20.5/common/edid-parse.c:230:19: style: Variable 'color_type' can be declared as const array [constVariable]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "`color_type` is a local array of a typedef'd enum type (`ColorType`). It is initialized once and then only read (`color_type[bits]`), so it could be declared const. Before the PR, the check skipped any variable whose type started with a simplified typedef. The PR now skips only pointer typedefs, so this true positive is newly reported. It matches the new test case in the PR." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/x/xfce4-settings/xfce4-settings_4.20.5.orig.tar.bz2", "your xfce4-settings-4.20.5/common/edid-parse.c:432:16: style: Variable 'stereo' can be declared as const array [constVariable]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The array 'stereo' (StereoType is a typedef of an enum) is initialized once and then only read, via 'detailed->stereo = stereo[bits]'. It could be declared 'const StereoType stereo[]', so the warning is a true positive. Before the PR, Cppcheck suppressed it only because the type came from a typedef. The PR now skips the check only when the pointer itself comes from a typedef, which matches the new test case." } } ], "started": "2026-11-03 18:39:00 UTC", "runner": "aws-testrunner-1" }