<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jens Harms</title>
    <description>The latest articles on DEV Community by Jens Harms (@jens_harms_c50ccbd4550050).</description>
    <link>https://dev.to/jens_harms_c50ccbd4550050</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4134088%2Fa98802a7-b3d3-4120-8335-1f18c38c8936.png</url>
      <title>DEV Community: Jens Harms</title>
      <link>https://dev.to/jens_harms_c50ccbd4550050</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jens_harms_c50ccbd4550050"/>
    <language>en</language>
    <item>
      <title>A one-number triage tool for C code (and a cheap feedback loop for LLM output)</title>
      <dc:creator>Jens Harms</dc:creator>
      <pubDate>Sun, 20 Sep 2026 12:48:39 +0000</pubDate>
      <link>https://dev.to/jens_harms_c50ccbd4550050/a-one-number-triage-tool-for-c-code-and-a-cheap-feedback-loop-for-llm-output-1eco</link>
      <guid>https://dev.to/jens_harms_c50ccbd4550050/a-one-number-triage-tool-for-c-code-and-a-cheap-feedback-loop-for-llm-output-1eco</guid>
      <description>&lt;p&gt;C gets hard to trust in three predictable ways: deep nesting, pointers to&lt;br&gt;
pointers, and &lt;code&gt;a-&amp;gt;b-&amp;gt;c&lt;/code&gt; chains where nobody null-checks the middle pointer.&lt;br&gt;
So I wrote a tiny scorer that squashes that into one number per function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;score(f) = nesting × pointer depth × deref chain
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each factor is one sentence:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;nesting&lt;/strong&gt; — the depth of &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;for&lt;/code&gt;/&lt;code&gt;while&lt;/code&gt; levels&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pointer depth&lt;/strong&gt; — &lt;code&gt;int *&lt;/code&gt;, &lt;code&gt;int **&lt;/code&gt;, &lt;code&gt;int ***&lt;/code&gt; in params and locals (deeper is closer to a memory bug)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;deref chain&lt;/strong&gt; — &lt;code&gt;a-&amp;gt;b-&amp;gt;c&lt;/code&gt; runs, i.e. null-derefs where the middle pointer came from somewhere else&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's one file, zero dependencies, no parser worth mentioning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does the number mean anything?
&lt;/h3&gt;

&lt;p&gt;I checked it against maintenance churn — how often a function actually gets&lt;br&gt;
touched — on two very different codebases (libXt, a 40-year-old X11 toolkit,&lt;br&gt;
and libtiff, a format parser):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spearman(Score, Churn) = 0.52 (libXt), 0.38 (libtiff)&lt;/li&gt;
&lt;li&gt;better than raw line count (0.50 / 0.33) and cyclomatic complexity (0.41 / 0.32)&lt;/li&gt;
&lt;li&gt;the top-15 functions see roughly 3–5× the churn of the bottom-15&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also ran it across 20+ years of git history for libtiff, curl, redis and&lt;br&gt;
OpenMotif. None of them trend toward smaller functions — the median stays flat&lt;br&gt;
and &lt;strong&gt;the biggest function only ever grows&lt;/strong&gt;. Which is exactly why a cheap pointer&lt;br&gt;
to the hot spots helps.&lt;/p&gt;
&lt;h3&gt;
  
  
  The part I actually use it for
&lt;/h3&gt;

&lt;p&gt;LLM-generated C has the same tell. The loop is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;generate → c-score file.c → "rewrite the top 3" → re-score
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One round visibly flattens the output. A dumb, explainable number is enough to&lt;br&gt;
steer an LLM — you don't need a real static analyzer for this.&lt;/p&gt;
&lt;h3&gt;
  
  
  Honest limits
&lt;/h3&gt;

&lt;p&gt;It's a triage tool, not a bug detector. It won't find semantic bugs, and it&lt;br&gt;
can't see a deep call stack full of side effects. The parser is not perfect,&lt;br&gt;
and the Python is LLM-generated too. But the idea is the sound part — before&lt;br&gt;
you pick it apart, run it on a real codebase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;c-code-score
&lt;span class="k"&gt;for &lt;/span&gt;f &lt;span class="k"&gt;in &lt;/span&gt;src/&lt;span class="k"&gt;*&lt;/span&gt;.c&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;c-score &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/^[^ ]/{n=$1} /^  score:/{print n,$2}'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-k2&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Repo: &lt;a href="https://github.com/xtforever/c-score" rel="noopener noreferrer"&gt;https://github.com/xtforever/c-score&lt;/a&gt; · &lt;a href="https://codeberg.org/au1064/c-score" rel="noopener noreferrer"&gt;https://codeberg.org/au1064/c-score&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codequality</category>
      <category>debugging</category>
      <category>llm</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
