Repository navigation
foomatic-rip: fix cppcheck 2.19 findings - #816
Merged
Merged
Conversation
The cppcheck job has been failing since ubuntu-latest moved to Ubuntu 26.04, which ships cppcheck 2.19 instead of 2.13. It reports 36 findings on master: - syntaxError in foomaticrip.c and utils/driverless.c: the workflow passed -DVERSION=2.x.y without quotes, so "..." VERSION "..." string concatenation did not parse. Quote it, as cups-browsed already does. With that, cppcheck analyses both files again and finds more of the next two groups. - nullPointerOutOfMemory after "if (!p) rip_die(...);": cppcheck does not understand C11 _Noreturn, so it assumes rip_die() can return. Also mark rip_die() __attribute__((noreturn)) in util.h. This also makes the inline cppcheck-suppress comments in renderer.c, which worked around the same thing, unnecessary, so drop them. - nullPointerOutOfMemory for malloc()/calloc() results that were not checked at all, in create_job(), options.c, argv_split(), make_absolute_path() and the list helpers in util.c. Check them and call rip_die(1, "ERROR: out of memory ...") like the rest of foomatic-rip does. - pointerSize: modern_shell was allocated with sizeof(char*) per character instead of sizeof(char). With this, cppcheck 2.19 and 2.13 run with the CI job's options report nothing. The build and "make check" give the same results as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cppcheck job is failing on master. No code change caused it:
ubuntu-latestmoved to Ubuntu 26.04, which installs cppcheck 2.19 instead of 2.13 (the same thing that broke cups-browsed, fixed in OpenPrinting/cups-browsed#87). On master, 2.19 reports 36 findings, all in foomatic-rip once the first one is fixed.foomaticrip.candutils/driverless.c: the workflow passed-DVERSION=2.x.ywithout quotes, so"..." VERSION "..."didn't parse. It's quoted now, as cups-browsed already does. With that fixed, cppcheck analyses both files again and finds a few more of the issues below.if (!p) rip_die(...);: cppcheck doesn't understand C11_Noreturn, so it assumesrip_die()can return. I checked this with a minimal test case:__attribute__((noreturn))is honoured and_Noreturnis not.rip_die()inutil.hnow carries both. That also makes the inlinecppcheck-suppresscomments inrenderer.cunnecessary (they worked around the same thing), so I removed them.malloc()/calloc()results that weren't checked at all:create_job(), several spots inoptions.c,argv_split(),make_absolute_path()and the list helpers inutil.c. Each is now checked and callsrip_die(1, "ERROR: out of memory ..."), like the rest of foomatic-rip.modern_shellwas allocated withsizeof(char*)per character instead ofsizeof(char).I didn't pin the runner back to 24.04, because that would only hide the findings.
Testing: I ran the exact cppcheck command from
.github/workflows/cppcheck.ymlin containers. Inubuntu:26.04(2.19), master exits 1 with 36 findings (the same list as the failing CI run) and this branch exits 0. Inubuntu:24.04(2.13), this branch also exits 0, including with therenderer.csuppressions removed. The build succeeds with no new warnings, andmake checkgives the same results as master (4 pass, 1 skip).