* [U-Boot] [PATCH] cmd: ubi: remove unnecessary logical constraint
@ 2017-04-15 14:25 Heinrich Schuchardt
2017-04-15 16:12 ` Tom Rini
2017-04-18 4:01 ` Heiko Schocher
0 siblings, 2 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2017-04-15 14:25 UTC (permalink / raw)
To: u-boot
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(-)
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;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] cmd: ubi: remove unnecessary logical constraint
2017-04-15 14:25 [U-Boot] [PATCH] cmd: ubi: remove unnecessary logical constraint Heinrich Schuchardt
@ 2017-04-15 16:12 ` Tom Rini
2017-04-18 4:01 ` Heiko Schocher
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2017-04-15 16:12 UTC (permalink / raw)
To: u-boot
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>
--
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] cmd: ubi: remove unnecessary logical constraint
2017-04-15 14:25 [U-Boot] [PATCH] cmd: ubi: remove unnecessary logical constraint Heinrich Schuchardt
2017-04-15 16:12 ` Tom Rini
@ 2017-04-18 4:01 ` Heiko Schocher
1 sibling, 0 replies; 3+ messages in thread
From: Heiko Schocher @ 2017-04-18 4:01 UTC (permalink / raw)
To: u-boot
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;
> }
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-18 4:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-15 14:25 [U-Boot] [PATCH] cmd: ubi: remove unnecessary logical constraint Heinrich Schuchardt
2017-04-15 16:12 ` Tom Rini
2017-04-18 4:01 ` Heiko Schocher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox