public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: Re: [PATCH] staging: fbtft: replace sprintf with snprintf
Date: Thu, 04 Jun 2026 14:40:17 +1000	[thread overview]
Message-ID: <review-patch1-2026060110-unlisted-headache-aec7@gregkh> (raw)
In-Reply-To: <2026060110-unlisted-headache-aec7@gregkh>

Patch Review

**Correctness: The change is functionally correct.**

The buffers are declared at line 734-735:
```c
char text1[50] = "";
char text2[50] = "";
```

The patch correctly uses `sizeof(text1)` and `sizeof(text2)` as the size arguments, which resolve to 50 since these are stack-allocated arrays (not pointers). The format strings and arguments are preserved correctly.

**Observations:**

1. **Low practical risk from the original code**: The `text1` format `", %zu KiB buffer memory"` with a `size_t` value shifted right by 10 bits will produce at most ~30 characters (e.g. `", 4294967295 KiB buffer memory"` is 31 chars). Similarly, `text2` with `", spi%d.%d at %d MHz"` will realistically fit well within 50 bytes. There is no actual buffer overflow risk here — the `sprintf` calls are safe given the buffer sizes and value ranges. This is a cleanup, not a bug fix, despite the commit message claiming "potential buffer overflow."

2. **Preferred kernel alternative**: The current kernel community preference for this kind of cleanup is `scnprintf()` rather than `snprintf()`. `scnprintf()` returns the number of characters actually written (excluding the null terminator), which is generally more useful and avoids off-by-one confusion with the return value. However, since the return values are not used here, `snprintf()` is functionally equivalent and acceptable.

3. **Style nit**: The reformatted `snprintf` for `text2` has correct alignment — the continuation arguments are aligned to the opening parenthesis, which follows kernel coding style.

**Verdict**: The code change itself is fine as a minor cleanup, but the patch would need to be resubmitted with: (a) a proper commit message explaining the rationale, (b) the patch sent inline (not as an attachment), (c) a real name on the Signed-off-by, and (d) use of `git send-email`. The commit message should also not overstate the risk — this is a style/hardening cleanup, not fixing an actual overflow.

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-06-04  4:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01  0:43 [PATCH] staging: fbtft: replace sprintf with snprintf Enchanted Hunter
2026-06-01  5:44 ` Greg KH
2026-06-04  4:40   ` Claude review: " Claude Code Review Bot
2026-06-04  4:40   ` Claude Code Review Bot [this message]
2026-06-01  8:25 ` Andy Shevchenko
2026-06-02 17:12   ` Enchanted Hunter
2026-06-02 18:31     ` Andy Shevchenko
2026-06-02 19:33       ` Enchanted Hunter
2026-06-03  1:13         ` Andy Shevchenko
2026-06-03  9:14           ` Enchanted Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch1-2026060110-unlisted-headache-aec7@gregkh \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox