Skip to contentSkip to conversation

cmd: ubi: remove unnecessary logical constraint

PATCH New Heinrich Schuchardt 3 participants 3 messages Apr 15, 2017 – Apr 18, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: ubi: remove unnecessary logical constraint

A size_t variable can never be negative.

The problem was indicated by cppcheck.

---
 cmd/ubi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/ubi.c +1 -1
index efc43ffde9..222be5a357 100644
@@ -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;
 	}
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 cmd: ubi: remove unnecessary logical constraint

Quoted 5 lines · Heinrich Schuchardt

A size_t variable can never be negative.

The problem was indicated by cppcheck.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170415/867b3de7/attachment.sig>
#2 lore raw

PATCH 1/1 cmd: ubi: remove unnecessary logical constraint

In reply to Heinrich Schuchardt

Hello Heinrih,

Am 15.04.2017 um 16:25 schrieb Heinrich Schuchardt:

Quoted 8 lines

A size_t variable can never be negative.

The problem was indicated by cppcheck.

---
  cmd/ubi.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

bye,
Heiko

Quoted 15 lines
cmd/ubi.c +1 -1
index efc43ffde9..222be5a357 100644
@@ -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;
  	}
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany