diff mbox

[U-Boot] cmd: ubi: remove unnecessary logical constraint

Message ID 20170415142525.27402-1-xypron.glpk@gmx.de
State Accepted
Commit 18f41f2fa2d021f7baad37ba6fbe01b49309afbb
Delegated to: Heiko Schocher
Headers show

Commit Message

Heinrich Schuchardt April 15, 2017, 2:25 p.m. UTC
A size_t variable can never be negative.

The problem was indicated by cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 cmd/ubi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini April 15, 2017, 4:12 p.m. UTC | #1
On Sat, Apr 15, 2017 at 04:25:25PM +0200, Heinrich Schuchardt wrote:

> A size_t variable can never be negative.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Reviewed-by: Tom Rini <trini@konsulko.com>
Heiko Schocher April 18, 2017, 4:01 a.m. UTC | #2
Hello Heinrih,

Am 15.04.2017 um 16:25 schrieb Heinrich Schuchardt:
> A size_t variable can never be negative.
>
> The problem was indicated by cppcheck.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>   cmd/ubi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/cmd/ubi.c b/cmd/ubi.c
> index efc43ffde9..222be5a357 100644
> --- a/cmd/ubi.c
> +++ b/cmd/ubi.c
> @@ -308,7 +308,7 @@ int ubi_volume_begin_write(char *volume, void *buf, size_t size,
>   		return ENODEV;
>
>   	rsvd_bytes = vol->reserved_pebs * (ubi->leb_size - vol->data_pad);
> -	if (size < 0 || size > rsvd_bytes) {
> +	if (size > rsvd_bytes) {
>   		printf("size > volume size! Aborting!\n");
>   		return EINVAL;
>   	}
>
diff mbox

Patch

diff --git a/cmd/ubi.c b/cmd/ubi.c
index efc43ffde9..222be5a357 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -308,7 +308,7 @@  int ubi_volume_begin_write(char *volume, void *buf, size_t size,
 		return ENODEV;
 
 	rsvd_bytes = vol->reserved_pebs * (ubi->leb_size - vol->data_pad);
-	if (size < 0 || size > rsvd_bytes) {
+	if (size > rsvd_bytes) {
 		printf("size > volume size! Aborting!\n");
 		return EINVAL;
 	}