A one-number triage tool for C code (and a cheap feedback loop for LLM output)
C gets hard to trust in three predictable ways: deep nesting, pointers to a->b->c chains where nobody null-checks the middle pointer. score(f) = nesting × pointer depth × deref chain Each factor is one sentence: nesting — the depth of if/for/while levels pointer depth — int *, int **, int *** in pa

C gets hard to trust in three predictable ways: deep nesting, pointers to a->b->c chains where nobody null-checks the middle pointer. score(f) = nesting × pointer depth × deref chain Each factor is one sentence: nesting — the depth of if/for/while levels pointer depth — int *, int **, int *** in params and locals (deeper is closer to a memory bug) deref chain — a->b->c runs, i.e. null-derefs where the middle pointer came from somewhere else It's one file, zero dependencies, no parser worth mentioning. I checked it against maintenance churn — how often a function actually gets Spearman(Score, Churn) = 0.52 (libXt), 0.38 (libtiff) better than raw line count (0.50 / 0.33) and cyclomatic complexity (0.41 / 0.32) the top-15 functions see roughly 3–5× the churn of the bottom-15 I also ran it across 20+ years of git history for libtiff, curl, redis and the biggest function only ever grows. Which is exactly why a cheap pointer LLM-generated C has the same tell. The loop is: generate → c-score file.c → "rewrite the top 3" → re-score One round visibly flattens the output. A dumb, explainable number is enough to It's a triage tool, not a bug detector. It won't find semantic bugs, and it pip install c-code-score for f in src/*.c; do c-score "$f"; done \ | awk '/^[^ ]/{n=$1} /^ score:/{print n,$2}' \ | sort -k2 -rn | head Repo: https://github.com/xtforever/c-score · https://codeberg.org/au1064/c-score
Key Takeaways
- •C gets hard to trust in three predictable ways: deep nesting, pointers to a->b->c chains where nobody null-checks the middle pointer. score(f) = nesting × pointer depth × deref chain Each factor is one sentence: nesting — the depth of if/for/while levels pointer depth — int *, int **, int *** in pa
- •This story was reported by Dev.to, covering developments in the dev space.
- •AI advancements continue to reshape industries — read the full article on Dev.to for complete coverage.
📖 Continue reading the full article:
Read Full Article on Dev.to →

