diff mbox

UBI: simplify image sequence test

Message ID 1380286316-29911-2-git-send-email-richard.genoud@gmail.com
State Accepted
Commit 55b80c409a1368b8dff3c78943101bccb0ea3aa1
Headers show

Commit Message

Richard Genoud Sept. 27, 2013, 12:51 p.m. UTC
The test:
if (!a && b)
  a = b;
can be symplified in:
if (!a)
  a = b;

And there's no need to test if ubi->image_seq is not null, because if it is,
it is set to image_seq.
So, we just test if image_seq is not null.

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
 drivers/mtd/ubi/attach.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Richard Weinberger Sept. 27, 2013, 1:28 p.m. UTC | #1
Am 27.09.2013 14:51, schrieb Richard Genoud:
> The test:
> if (!a && b)
>   a = b;
> can be symplified in:
> if (!a)
>   a = b;
> 
> And there's no need to test if ubi->image_seq is not null, because if it is,
> it is set to image_seq.
> So, we just test if image_seq is not null.
> 
> Signed-off-by: Richard Genoud <richard.genoud@gmail.com>

Acked-by: Richard Weinberger <richard@nod.at>
diff mbox

Patch

diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 03b32b0..33bb1f2 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -900,10 +900,9 @@  static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
 		 * number.
 		 */
 		image_seq = be32_to_cpu(ech->image_seq);
-		if (!ubi->image_seq && image_seq)
+		if (!ubi->image_seq)
 			ubi->image_seq = image_seq;
-		if (ubi->image_seq && image_seq &&
-		    ubi->image_seq != image_seq) {
+		if (image_seq && ubi->image_seq != image_seq) {
 			ubi_err("bad image sequence number %d in PEB %d, expected %d",
 				image_seq, pnum, ubi->image_seq);
 			ubi_dump_ec_hdr(ech);