From 310ae37edb3becedf5da904201f3439ea42ab12f Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 25 Aug 2015 17:09:40 +0200 Subject: Fix bad return value checks (detected with Coccinelle) In the "Getting Started with Coccinelle - KVM edition" presentation that has been held by Julia Lawall at the KVM forum 2015 (see the slides at http://events.linuxfoundation.org/sites/events/files/slides/tutorial_kvm_0.pdf), she pointed out some bad return value checks in U-Boot that can be detected with Coccinelle by using the following config file: @@ identifier x,y; identifier f; statement S; @@ x = f(...); ( if (x < 0) S | if ( - y + x < 0) S ) This patch now fixes these issues. Signed-off-by: Thomas Huth --- board/samsung/origen/tools/mkorigenspl.c | 2 +- board/samsung/smdkv310/tools/mksmdkv310spl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'board/samsung') diff --git a/board/samsung/origen/tools/mkorigenspl.c b/board/samsung/origen/tools/mkorigenspl.c index 3ed20efce3..8b0c3ac4bd 100644 --- a/board/samsung/origen/tools/mkorigenspl.c +++ b/board/samsung/origen/tools/mkorigenspl.c @@ -52,7 +52,7 @@ int main(int argc, char **argv) } ofd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, FILE_PERM); - if (ifd < 0) { + if (ofd < 0) { fprintf(stderr, "%s: Can't open %s: %s\n", argv[0], argv[2], strerror(errno)); if (ifd) diff --git a/board/samsung/smdkv310/tools/mksmdkv310spl.c b/board/samsung/smdkv310/tools/mksmdkv310spl.c index 9a64ca6ad6..ea61635db5 100644 --- a/board/samsung/smdkv310/tools/mksmdkv310spl.c +++ b/board/samsung/smdkv310/tools/mksmdkv310spl.c @@ -50,7 +50,7 @@ int main(int argc, char **argv) } ofd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, FILE_PERM); - if (ifd < 0) { + if (ofd < 0) { fprintf(stderr, "%s: Can't open %s: %s\n", argv[0], argv[2], strerror(errno)); if (ifd) -- cgit v1.2.1