Skip to content

cfu service: deduping common response helper methods#773

Open
sanjay-nagesh wants to merge 3 commits intoOpenDevicePartnership:mainfrom
sanjay-nagesh:sanjay-issue-388-cfu-response-utils
Open

cfu service: deduping common response helper methods#773
sanjay-nagesh wants to merge 3 commits intoOpenDevicePartnership:mainfrom
sanjay-nagesh:sanjay-issue-388-cfu-response-utils

Conversation

@sanjay-nagesh
Copy link
Copy Markdown

Fixed Issue #388

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Issue #388 by deduplicating CFU “common response” construction logic (invalid FW version + content rejection) into a shared helper module and updating existing CFU components to use it.

Changes:

  • Added cfu-service-internal response helper functions in a new responses module.
  • Updated Buffer and Splitter to call the shared helpers instead of maintaining duplicate local methods.
  • Wired the new module into the crate via lib.rs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
cfu-service/src/splitter.rs Replaces local helper methods with calls into crate::responses for common response creation.
cfu-service/src/buffer.rs Replaces duplicated response-building helpers with shared crate::responses utilities.
cfu-service/src/responses.rs Introduces shared helpers for invalid FW version responses and content rejection responses.
cfu-service/src/lib.rs Adds the internal responses module to the crate.

@RobertZ2011
Copy link
Copy Markdown
Contributor

@sanjay-nagesh You'll need to rebase this branch to pull in the latest changes from main before it can be merged.

Copilot AI review requested due to automatic review settings April 3, 2026 18:19
@sanjay-nagesh sanjay-nagesh force-pushed the sanjay-issue-388-cfu-response-utils branch from 1f41ccc to e07e8c9 Compare April 3, 2026 18:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment on lines +13 to +14
let dev_inf = FwVerComponentInfo::new(FwVersion::new(INVALID_FW_VERSION), component_id);
let comp_info: [FwVerComponentInfo; MAX_CMPT_COUNT] = [dev_inf; MAX_CMPT_COUNT];
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The local variable name dev_inf is unclear/abbreviated; consider renaming to something more descriptive (e.g., dev_info or component_info_entry) to make the helper’s intent easier to read/maintain.

Suggested change
let dev_inf = FwVerComponentInfo::new(FwVersion::new(INVALID_FW_VERSION), component_id);
let comp_info: [FwVerComponentInfo; MAX_CMPT_COUNT] = [dev_inf; MAX_CMPT_COUNT];
let component_info_entry = FwVerComponentInfo::new(FwVersion::new(INVALID_FW_VERSION), component_id);
let comp_info: [FwVerComponentInfo; MAX_CMPT_COUNT] =
[component_info_entry; MAX_CMPT_COUNT];

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +24
// Returns a content rejection response with the given block sequence number.
// This is used when firmware content cannot be delivered or handled correctly.
//
pub(crate) fn create_content_rejection(sequence: u16) -> InternalResponseData {
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The standalone // line is unnecessary, and these look like function docs; consider converting them to rustdoc comments (/// ...) so they stay attached to the functions and match the style used elsewhere in this crate.

Copilot uses AI. Check for mistakes.
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.

3 participants