From patchwork Fri Sep 27 12:51:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 278581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 67D0E2C039C for ; Fri, 27 Sep 2013 22:53:08 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VPXXQ-0003Ea-P3; Fri, 27 Sep 2013 12:52:53 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VPXXO-0002A8-LQ; Fri, 27 Sep 2013 12:52:50 +0000 Received: from mail-we0-x236.google.com ([2a00:1450:400c:c03::236]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VPXXM-00026y-Ap for linux-mtd@lists.infradead.org; Fri, 27 Sep 2013 12:52:48 +0000 Received: by mail-we0-f182.google.com with SMTP id q59so2651167wes.13 for ; Fri, 27 Sep 2013 05:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+mK69WXkj+fPWDRDtYNnmIhQFpFhhuI3c2oiVND30ec=; b=fnvGxXuCGqalgW3r+47uBQeHLKU5QDLrI4XtntGnoNvfPnYpt+8D8LGoKw+KxYCUJx wi58oBWW1ooFPVP9f5NMN8y4D8T9PhMvS5Fw+HI8BsLoXXzuf0izId3d6Kx1alphLB+2 HB3Z0AcUVOSm+mgTmZ7vpiv2YDJhZLSpN2RUQC0EgRP668DPGv4EV63ub7v2wNPsTHqB WTiV9OfJpcSF7LvoTWkcQYM8+7VvX8wQ9sG7BnuiIgIiCJvvjS4Hr6X1LmvrHOy2RYYb Wrz3zU8NEzeZParTSmIDyIuQgeuAZdqItFJEZlgBz6o8b94VgypYQ/zjx5CmXnLMuL0h Yd/w== X-Received: by 10.194.250.6 with SMTP id yy6mr5651277wjc.13.1380286346716; Fri, 27 Sep 2013 05:52:26 -0700 (PDT) Received: from lnx-rg.pr (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPSA id fz8sm38292917wic.0.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Sep 2013 05:52:26 -0700 (PDT) From: Richard Genoud To: Richard Weinberger , Artem Bityutskiy Subject: [PATCH] UBI: simplify image sequence test Date: Fri, 27 Sep 2013 14:51:56 +0200 Message-Id: <1380286316-29911-2-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1380286316-29911-1-git-send-email-richard.genoud@gmail.com> References: <1380286316-29911-1-git-send-email-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130927_085248_561029_6C69C7CC X-CRM114-Status: GOOD ( 11.20 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (richard.genoud[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Richard Genoud , linux-mtd , David Woodhouse , linux-kernel@vger.kernel.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Acked-by: Richard Weinberger --- drivers/mtd/ubi/attach.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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);