Skip to content

mport: fix upgrade.c ohash callback signatures after ohash update#398

Merged
laffer1 merged 1 commit into
masterfrom
fix-mport-ohash-upgrade-signatures
Jun 15, 2026
Merged

mport: fix upgrade.c ohash callback signatures after ohash update#398
laffer1 merged 1 commit into
masterfrom
fix-mport-ohash-upgrade-signatures

Conversation

@laffer1

@laffer1 laffer1 commented Jun 15, 2026

Copy link
Copy Markdown
Member

Summary

  • ecalloc updated from (size_t, void *) to (size_t, size_t, void *) to match the new ohash_info.calloc signature; implementation switched from malloc+memset to calloc
  • efree updated from (void *, size_t, void *) to (void *, void *) to match the new ohash_info.free signature
  • Forward declarations updated to match

Fixes build errors introduced after lib/libc/ohash was updated:

upgrade.c:73:38: error: incompatible function pointer types initializing
  'void *(*)(size_t, size_t, void *)' with 'void *(size_t, void *)'
upgrade.c:73:47: error: incompatible function pointer types initializing
  'void (*)(void *, void *)' with 'void (void *, size_t, void *)'

Test plan

  • cd contrib/mport/libmport && make — confirm upgrade.o compiles without errors
  • make buildworld — confirm no regression in full build

🤖 Generated with Claude Code

Summary by Sourcery

Bug Fixes:

  • Correct ecalloc and efree callback signatures and behavior to match the new ohash_info.calloc and ohash_info.free interfaces, resolving compilation errors after the ohash library update.

The ohash_info struct in lib/libc/ohash now expects:
  calloc: void *(size_t, size_t, void *)
  free:   void *(void *, void *)

Update ecalloc and efree in contrib/mport/libmport/upgrade.c to match
the new signatures. Switch from malloc+memset to calloc for correctness.

AI-Assisted-by: Claude Sonnet 4.6

Signed-off-by: Lucas Holt <luke@foolishgames.com>
@sourcery-ai

sourcery-ai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Aligns mport's upgrade.c ohash allocator callbacks with the updated libohash API by changing the ecalloc/efree prototypes and implementations to match the new calloc/free signatures and using calloc directly for zeroed allocation.

File-Level Changes

Change Details Files
Update ohash allocator callback prototypes and implementations in upgrade.c to match the new libohash API and use calloc for zero-initialized allocations.
  • Change ecalloc forward declaration to accept two size_t parameters plus a void * context, matching ohash_info.calloc
  • Change efree forward declaration to accept a pointer and a void * context, matching ohash_info.free
  • Update ecalloc implementation to take two size_t arguments and call calloc(s1, s2) instead of malloc+memset for zeroing
  • Update efree implementation signature to drop the unused size_t argument and simply free the given pointer
contrib/mport/libmport/upgrade.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the memory allocation helper functions in upgrade.c. Specifically, it updates ecalloc to use calloc instead of malloc and memset, and simplifies efree by removing an unused size parameter. I have no further feedback to provide as there are no review comments to evaluate.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

Claude finished @laffer1's task —— View job


Code Review Complete ✅

Reviewed the ohash callback signature fixes in contrib/mport/libmport/upgrade.c. The changes correctly address the ohash library API update.

Todo List:

  • Read and analyze the changed file contrib/mport/libmport/upgrade.c
  • Check malloc/free symmetry and memory management
  • Verify bounds checking
  • Review style(9) compliance (8-space tabs, 80-col)
  • Look for security issues
  • Provide comprehensive review feedback

✅ Review Results

Overall Assessment: LGTM - The changes are correct and necessary fixes for the ohash library update.

Memory Management ✅

  • Perfect malloc/free symmetry: The updated ecalloc/efree pair correctly implements the new ohash API
  • Improved implementation: Switching from malloc + memset to calloc is more efficient and cleaner
  • Proper error handling: ecalloc still properly handles allocation failures with err(1, "calloc")

API Compatibility ✅

  • Correct signature updates:
    • ecalloc: (size_t, void *)(size_t, size_t, void *) - now properly matches ohash_info.calloc
    • efree: (void *, size_t, void *)(void *, void *) - now properly matches ohash_info.free
  • Forward declarations updated: Both function prototypes at lines 46-47 correctly match implementations

Style(9) Compliance ✅

  • Consistent indentation: Uses 8-space tabs throughout
  • Line length: All lines under 80 characters
  • BSD style: Function braces, spacing, and formatting follow style(9)

Security ✅

  • No security issues introduced: The changes are purely API compatibility fixes
  • Maintained security properties: Error handling on allocation failure preserved
  • No new attack surfaces: Changes are limited to function signatures and internal implementation

Code Quality ✅

  • Clean implementation: calloc(s1, s2) is cleaner than malloc + memset
  • Proper context handling: Both functions correctly accept and can use the void *data context parameter
  • Consistent with ohash usage: The struct ohash_info initialization at line 72 will now work correctly

No issues found - this is a well-executed fix for the ohash API compatibility.


Job run | Branch: fix-mport-ohash-upgrade-signatures

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Both ecalloc and efree ignore their data argument; if that’s intentional, consider marking it __unused (or casting to (void)data) to make this explicit and avoid warnings.
  • In ecalloc, you could improve the error message by including the requested sizes (e.g., err(1, "calloc %zu x %zu", s1, s2);) to aid debugging when allocation fails.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Both `ecalloc` and `efree` ignore their `data` argument; if that’s intentional, consider marking it `__unused` (or casting to `(void)data`) to make this explicit and avoid warnings.
- In `ecalloc`, you could improve the error message by including the requested sizes (e.g., `err(1, "calloc %zu x %zu", s1, s2);`) to aid debugging when allocation fails.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@laffer1 laffer1 merged commit 526a71f into master Jun 15, 2026
8 of 13 checks passed
@laffer1 laffer1 deleted the fix-mport-ohash-upgrade-signatures branch June 15, 2026 13:49
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.

1 participant