Skip to content

Conversation

@hsinliang
Copy link

Add image string information to the display output of the fw-info subcommand. The user can modify the image string in the firmware header using the ChipLink Firmware Image Header Editor tool. After updating the firmware, use Switchtec-User fw-info to verify the image string information.

{
int i;

for (i = 0; i < len; i++)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please follow the coding style: should use tab characters (set to 8 spaces) as indents and the { for for and if statements should be on the same line.

This project follows Linux coding style so see here for more information:
https://www.kernel.org/doc/html/latest/process/coding-style.html


if(inf->valid){
printf("Image String:");
char_arr_print(inf->img_str, sizeof(inf->img_str));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't actually need the new helper, it should be equivalent to:

printf("%.*s", sizeof(inf->img_str), inf->img_str);

inf->valid ? "" : " (Invalid)");

if(inf->valid){
printf("Image String:");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The lines here are going to be too long for a standard screen. Can we maybe add this to a new line and match the indent of the Version string?

if (inf->valid) {
    printf("  %-4s\tImage String: %.*s\n", "", sizeof(inf->img_str), 
              inf->img_str);

size_t part_body_offset; //!< Partition image body offset
size_t image_len; //!< Length of the image
unsigned long image_crc; //!< CRC checksum of the image
char img_str[16];
Copy link
Collaborator

Choose a reason for hiding this comment

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

NIT: I'd very much prefer changes to the library be put in separate patches from changes to the CLI.

inf->metadata = metadata;

for(i = 0; i< 16; i++)
inf->img_str[i] = metadata->img_str[i];
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be a memcpy() and shouldn't need the constant 16:

memcpy(inf->img_str, metadata->img_str, sizeof(inf->img_str));

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.

2 participants