Skip to content
Snippets Groups Projects
Commit 2ab83f0d authored by Simon Glass's avatar Simon Glass
Browse files

cros_ec: Correct comparison between signed and unsigned numbers


Due to signed/unsigned comparison, '< sizeof(struct)' does not do the right
thing, since if ec_command() returns a -ve number we will consider this be
success.

Adjust all comparisons to avoid this problem.

This error was found with sandbox, which gives a segfault in this case. On
ARM we may instead silently fail.

We should also consider turning on -Wsign-compare to catch this sort of thing
in future.

Reviewed-by: default avatarAndrew Chew <achew@nvidia.com>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarVadim Bendebury <vbendeb@chromium.org>
Tested-by: default avatarAndrew Chew <achew@nvidia.com>
Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
Signed-off-by: default avatarJimmy Zhang <jimmzhang@nvidia.com>
parent a6070283
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment