Skip to content

build: fix calloc transposed args#172

Open
heitbaum wants to merge 1 commit intorsyslog:masterfrom
heitbaum:calloc
Open

build: fix calloc transposed args#172
heitbaum wants to merge 1 commit intorsyslog:masterfrom
heitbaum:calloc

Conversation

@heitbaum
Copy link

@heitbaum heitbaum commented Feb 18, 2026

fixes:

    ../arraylist.c: In function 'array_list_new':
    ../arraylist.c:34:49: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
       34 |         if(!(arr->array = (void**)calloc(sizeof(void*), arr->size))) {
          |                                                 ^~~~
    ../arraylist.c:34:49: note: earlier argument should specify number of elements, later size of each element
    ../json_object.c: In function 'fjson_object_new':
    ../json_object.c:217:78: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
      217 |         struct fjson_object *const jso = (struct fjson_object*)calloc(sizeof(struct fjson_object), 1);
          |                                                                              ^~~~~~
    ../json_object.c:217:78: note: earlier argument should specify number of elements, later size of each element

Summary by cubic

Fixed transposed calloc arguments to use (elements, size) and remove -Wcalloc-transposed-args build warnings. This makes allocations clearer and avoids potential issues.

  • Bug Fixes
    • arraylist.c: use calloc(arr->size, sizeof(void*))
    • json_object.c: use calloc(1, sizeof(struct fjson_object))

Written for commit 490df88. Summary will update on new commits.

fixes:
    ../arraylist.c: In function 'array_list_new':
    ../arraylist.c:34:49: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
       34 |         if(!(arr->array = (void**)calloc(sizeof(void*), arr->size))) {
          |                                                 ^~~~
    ../arraylist.c:34:49: note: earlier argument should specify number of elements, later size of each element
    ../json_object.c: In function 'fjson_object_new':
    ../json_object.c:217:78: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
      217 |         struct fjson_object *const jso = (struct fjson_object*)calloc(sizeof(struct fjson_object), 1);
          |                                                                              ^~~~~~
    ../json_object.c:217:78: note: earlier argument should specify number of elements, later size of each element

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @heitbaum, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request corrects the order of arguments in calls to the calloc function within the arraylist.c and json_object.c files. This resolves compiler warnings and ensures correct memory allocation, improving code reliability.

Highlights

  • Calloc Argument Order: This PR addresses warnings related to the order of arguments passed to the calloc function in arraylist.c and json_object.c. The arguments were transposed, potentially leading to unexpected behavior.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

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

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 correctly fixes transposed arguments in calloc calls within arraylist.c and json_object.c. These changes address the -Wcalloc-transposed-args compiler warnings, improving code correctness and clarity. The fixes are straightforward and well-implemented. The changes look good to me.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

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

Comments