From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: lib/fonts: Look up glyph data with font_data_glyph_buf()
Date: Thu, 04 Jun 2026 16:27:41 +1000 [thread overview]
Message-ID: <review-patch1-20260529140759.529929-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20260529140759.529929-2-tzimmermann@suse.de>
Patch Review
This patch adds two functions to `lib/fonts/fonts.c`:
```c
static unsigned int font_data_num_glyphs(font_data_t *fd, unsigned int width, unsigned int height)
{
return font_data_size(fd) / font_glyph_size(width, height);
}
```
```c
const unsigned char *font_data_glyph_buf(font_data_t *fd,
unsigned int width, unsigned int vpitch,
unsigned int c)
{
if (c >= font_data_num_glyphs(fd, width, vpitch))
return NULL;
return font_data_buf(fd) + font_glyph_size(width, vpitch) * c;
}
```
I verified that internal built-in fonts correctly set up `FNTSIZE` in their `extra` array (e.g. `font_8x16.c` uses `{ 0, 0, FONTDATAMAX, 0 }` where `FONTDATAMAX=4096`, matching `256 glyphs * 16 bytes`), so `font_data_size()` will return the right value and `font_data_num_glyphs()` computes correctly.
**Minor observations:**
- The parameter naming is slightly inconsistent: `font_data_num_glyphs` calls its third parameter `height`, but `font_data_glyph_buf` calls the same parameter `vpitch`. Both mean "number of scanlines per glyph." The doc comment on `font_data_glyph_buf` correctly says "@vpitch: The number of scanlines per glyph" so this is just cosmetic, but using `vpitch` consistently would be cleaner.
- If `width` or `height` were ever 0, `font_glyph_size()` returns 0 and `font_data_num_glyphs()` divides by zero. This can't happen with valid font data and the existing code already assumes non-zero dimensions everywhere, so this is not a real concern — just noting there's no explicit guard.
- The kdoc is good and clearly documents the NULL return case.
**No bugs. Looks good.**
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-06-04 6:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 14:01 [PATCH 0/4] drm: Safe font-data access in log/panic drawing Thomas Zimmermann
2026-05-29 14:01 ` [PATCH 1/4] lib/fonts: Look up glyph data with font_data_glyph_buf() Thomas Zimmermann
2026-06-01 11:18 ` Jocelyn Falempe
2026-06-02 8:08 ` Thomas Zimmermann
2026-06-04 6:27 ` Claude Code Review Bot [this message]
2026-05-29 14:01 ` [PATCH 2/4] drm/client: log: Look up glyph shape with font helper Thomas Zimmermann
2026-06-01 11:19 ` Jocelyn Falempe
2026-06-04 6:27 ` Claude review: " Claude Code Review Bot
2026-05-29 14:01 ` [PATCH 3/4] drm/panic: " Thomas Zimmermann
2026-06-01 11:19 ` Jocelyn Falempe
2026-06-04 6:27 ` Claude review: " Claude Code Review Bot
2026-05-29 14:01 ` [PATCH 4/4] drm/draw: Remove unused helper drm_draw_get_char_bitmap() Thomas Zimmermann
2026-06-01 11:19 ` Jocelyn Falempe
2026-06-04 6:27 ` Claude review: " Claude Code Review Bot
2026-06-04 6:27 ` Claude review: drm: Safe font-data access in log/panic drawing Claude Code Review Bot
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-20260529140759.529929-2-tzimmermann@suse.de \
--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