]> git.sur5r.net Git - u-boot/commit
cros_ec: Correct comparison between signed and unsigned numbers
authorSimon Glass <sjg@chromium.org>
Thu, 27 Feb 2014 20:26:11 +0000 (13:26 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 18 Mar 2014 02:05:47 +0000 (20:05 -0600)
commit2ab83f0d7522e34f6a67e6ed80f7ba03aa7c8dd6
tree0d04b1b5f5b38969fa4c923a691b3483a0d0dd23
parenta60702833150b8f9263a5f1fb9a6b64774cd44f3
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: Andrew Chew <achew@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Andrew Chew <achew@nvidia.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
drivers/misc/cros_ec.c