Skip to content

tests: Remove xcid_init in favor of make_xcid#2047

Merged
tatsuhiro-t merged 1 commit intomainfrom
tests-eliminate-xcid_init
Mar 2, 2026
Merged

tests: Remove xcid_init in favor of make_xcid#2047
tatsuhiro-t merged 1 commit intomainfrom
tests-eliminate-xcid_init

Conversation

@tatsuhiro-t
Copy link
Copy Markdown
Member

No description provided.

@tatsuhiro-t tatsuhiro-t added this to the v1.22.0 milestone Mar 2, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 refactors the test suite by modernizing the way Connection IDs (CIDs) are initialized. Instead of using dedicated initialization functions, CIDs are now directly assigned using make_xcid macros, often as static const variables. This change simplifies the test code, improves readability, and potentially enhances performance by allowing compile-time initialization where possible.

Highlights

  • Refactoring CID Initialization in Tests: Replaced explicit dcid_init, scid_init, and rcid_init function calls with direct initialization using make_dcid(), make_scid(), and make_rcid() macros, often leveraging static const for compile-time initialization.
  • Test Code Simplification: Streamlined the setup of connection IDs (CIDs) within various test functions, making the test code more concise and readable by removing boilerplate initialization calls.
  • Removal of Helper Functions: Eliminated the dcid_init, scid_init, and rcid_init helper functions from ngtcp2_test_helper.c and ngtcp2_test_helper.h as they are no longer needed.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tests/ngtcp2_conn_test.c
    • Removed dcid_init and scid_init calls in various test setups.
    • Initialized initial_scid and original_dcid directly using make_dcid() in ngtcp2_transport_params.
    • Declared ngtcp2_cid variables as static const and initialized them with make_dcid(), make_scid(), or make_rcid().
  • tests/ngtcp2_pkt_test.c
    • Replaced dcid_init, scid_init, and rcid_init calls with direct static const initializations using make_xcid() macros.
  • tests/ngtcp2_rtb_test.c
    • Updated ngtcp2_cid declarations to static const initialized with make_dcid().
  • tests/ngtcp2_test_helper.c
    • Removed the dcid_init, scid_init, and rcid_init helper functions.
    • Updated ngtcp2_tpe_init_conn_handshake_server to directly assign tpe->dcid using make_dcid().
  • tests/ngtcp2_test_helper.h
    • Removed the declarations for scid_init, dcid_init, and rcid_init.
  • tests/ngtcp2_transport_params_test.c
    • Eliminated rcid_init, scid_init, and dcid_init calls.
    • Directly initialized preferred_addr.cid, retry_scid, original_dcid, and initial_scid fields in ngtcp2_transport_params with make_xcid() macros.
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
Copy Markdown
Contributor

@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 is a nice refactoring that removes the xcid_init family of functions and replaces their usage with direct calls to the make_xcid macros. This simplifies the test code by removing a layer of abstraction. The changes are generally well-executed, but I've identified a potential logic change in one of the test helpers and a minor stylistic inconsistency regarding redundant casts. My review includes suggestions to address these points.

conn_options opts;

dcid_init(&dcid);
dcid = (ngtcp2_cid)make_dcid();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The cast (ngtcp2_cid) is redundant here because the make_dcid() macro already expands to a compound literal of type ngtcp2_cid. For consistency with other parts of the codebase where this cast is not used (e.g., in tests/ngtcp2_transport_params_test.c), it would be better to remove it.

This comment also applies to similar changes on lines 12265, 12300, and 12335 in this file, as well as in tests/ngtcp2_transport_params_test.c.

  dcid = make_dcid();

ngtcp2_tpe_init_conn(tpe, conn);

rcid_init(&tpe->dcid);
tpe->dcid = (ngtcp2_cid)make_dcid();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This change from rcid_init(&tpe->dcid) to tpe->dcid = (ngtcp2_cid)make_dcid() seems to introduce an unintended logic change. The rcid_init function was a wrapper for make_rcid(), but it has been replaced with make_dcid(). This changes the value being assigned to tpe->dcid.

If the intention was just to remove the rcid_init function, this should probably be make_rcid() instead.

Also, the cast (ngtcp2_cid) is redundant because the make_*() macros already expand to a compound literal of the correct type. It would be good to remove it for consistency.

  tpe->dcid = make_rcid();

@tatsuhiro-t tatsuhiro-t merged commit f796f56 into main Mar 2, 2026
73 checks passed
@tatsuhiro-t tatsuhiro-t deleted the tests-eliminate-xcid_init branch March 2, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant