Skip to content

Change Reboot log from text to CBOR encoded.#2011

Merged
mlaz merged 8 commits intoapache:masterfrom
manish-sudo:cbor_encoded_reboot_log
Sep 30, 2019
Merged

Change Reboot log from text to CBOR encoded.#2011
mlaz merged 8 commits intoapache:masterfrom
manish-sudo:cbor_encoded_reboot_log

Conversation

@manish-sudo
Copy link
Contributor

No description provided.

Copy link
Contributor

@vrahane vrahane left a comment

Choose a reason for hiding this comment

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

Generally, it looks fine but I think you should also add a dependency for tinycbor in pkg.yml for the reboot package

@manish-sudo
Copy link
Contributor Author

Generally, it looks fine but I think you should also add a dependency for tinycbor in pkg.yml for the reboot package

ACK

* buffer, then trim the filename from left. */
if (strlen(info->file) > (sizeof(buf) / 3))
{
off = strlen(info->file) - (sizeof(buf)/3);
Copy link
Contributor

Choose a reason for hiding this comment

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

missing spaces around /

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK

cbor_encode_text_stringz(&map, "img");
snprintf(buf, sizeof(buf), "%u.%u.%u.%u",
ver.iv_major, ver.iv_minor, ver.iv_revision,
(unsigned int) ver.iv_build_num);
Copy link
Contributor

Choose a reason for hiding this comment

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

original snprintf did not have space after cast, which is more common in mynewt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK

if (state_flags & IMGMGR_STATE_F_PENDING) {
off += snprintf(buf + off, sizeof buf - off, "%s ", "pending");
}
buf[off - 1] = '\0';
Copy link
Contributor

Choose a reason for hiding this comment

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

in case of no flags (I don't know if it can happen) buf[off - 1] = 0; would write outside buf.
That will be caught by coverity tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought of adding a protection earlier, but didn't thought it's absolutely required as technically there will be at-least one flag. Anyway, for the sanity I guarded this unlikely case.

state_flags = imgmgr_state_flags(boot_current_slot);
cbor_encode_text_stringz(&map, "flags");
off = 0;
memset(buf, 0, sizeof buf);
Copy link
Contributor

Choose a reason for hiding this comment

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

memset seems like overkill where buf[0] = '\0'; would do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK

Copy link
Contributor

@kasjer kasjer left a comment

Choose a reason for hiding this comment

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

Quality of the code is very good. I'm not sure why the switch from text to cbor was done, but I certainly don't have any problem with that.
I don't knew much details of cbor stuff in mynewt so I was not hard on buf size vs cbor_enc_buf size which may have room for future stack size optimization.

Copy link
Contributor

@vrahane vrahane left a comment

Choose a reason for hiding this comment

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

Looks good.

@mlaz mlaz merged commit 25cc114 into apache:master Sep 30, 2019
@vrahane
Copy link
Contributor

vrahane commented Sep 30, 2019

@manish-sudo Thanks, one thing I forgot to mention is for future PRs please mention the modules in the commit message. I should have mentioned this before approving but yeah, it's nice to have to go back and look at the history and know which module the commit is addressed for.

@manish-sudo manish-sudo deleted the cbor_encoded_reboot_log branch September 30, 2019 22:00
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.

4 participants