Skip to content

foomatic-rip: fix cppcheck 2.19 findings - #816

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
rue19:fix-cppcheck-2.19
Nov 24, 2026
Merged

tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
rue19:fix-cppcheck-2.19

Conversation

@rue19

@rue19 rue19 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

The cppcheck job is failing on master. No code change caused it: ubuntu-latest moved 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.

  • syntaxError in foomaticrip.c and utils/driverless.c: the workflow passed -DVERSION=2.x.y without 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.
  • nullPointerOutOfMemory after if (!p) rip_die(...);: cppcheck doesn't understand C11 _Noreturn, so it assumes rip_die() can return. I checked this with a minimal test case: __attribute__((noreturn)) is honoured and _Noreturn is not. rip_die() in util.h now carries both. That also makes the inline cppcheck-suppress comments in renderer.c unnecessary (they worked around the same thing), so I removed them.
  • nullPointerOutOfMemory for malloc()/calloc() results that weren't checked at all: create_job(), several spots in options.c, argv_split(), make_absolute_path() and the list helpers in util.c. Each is now checked and calls rip_die(1, "ERROR: out of memory ..."), like the rest of foomatic-rip.
  • pointerSize: modern_shell was allocated with sizeof(char*) per character instead of sizeof(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.yml in containers. In ubuntu:26.04 (2.19), master exits 1 with 36 findings (the same list as the failing CI run) and this branch exits 0. In ubuntu:24.04 (2.13), this branch also exits 0, including with the renderer.c suppressions removed. The build succeeds with no new warnings, and make check gives the same results as master (4 pass, 1 skip).

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.
@tillkamppeter
tillkamppeter merged commit 47f5edc into OpenPrinting:master Nov 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants