From patchwork Mon Sep 8 04:29:03 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 198 Return-Path: X-Original-To: patchwork@ozlabs.org Delivered-To: patchwork@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5CC58DDDFA for ; Mon, 8 Sep 2008 14:29:12 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1KcYN8-0002Vq-Qc; Mon, 08 Sep 2008 04:29:06 +0000 Received: from relay00.pair.com ([209.68.5.9]) by bombadil.infradead.org with smtp (Exim 4.68 #1 (Red Hat Linux)) id 1KcYN7-0002Vc-Ku for linux-mtd@lists.infradead.org; Mon, 08 Sep 2008 04:29:05 +0000 Received: (qmail 36547 invoked by uid 0); 8 Sep 2008 04:29:03 -0000 Received: from unknown (HELO localhost.localdomain) (unknown) by unknown with SMTP; 8 Sep 2008 04:29:03 -0000 X-pair-Authenticated: 66.134.71.115 From: Grant Erickson To: linux-mtd@lists.infradead.org Subject: [PATCH 4/6] [MTD-UTILS] nandwrite: Use Boolean Mnemonics from stdbool.h Date: Sun, 7 Sep 2008 21:29:03 -0700 Message-Id: <1220848143-22348-1-git-send-email-gerickson@nuovations.com> X-Mailer: git-send-email 1.6.0.1 Organization: Nuovation System Designs, LLC X-Spam-Score: -1.0 (-) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (-1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.68.5.9 listed in list.dnswl.org] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 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-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+patchwork=ozlabs.org@lists.infradead.org Added include directive for stdbool.h and leveraged where appropriate to improve code readability by making variable intent and usage more explicit. Signed-off-by: Grant Erickson diff --git a/nandwrite.c b/nandwrite.c index e5de140..5fbed41 100644 --- a/nandwrite.c +++ b/nandwrite.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -108,15 +109,15 @@ static void display_version (void) static const char *mtd_device, *img; static int mtdoffset = 0; -static int quiet = 0; -static int writeoob = 0; -static int markbad = 0; -static int autoplace = 0; -static int forcejffs2 = 0; -static int forceyaffs = 0; -static int forcelegacy = 0; -static int noecc = 0; -static int pad = 0; +static bool quiet = false; +static bool writeoob = false; +static bool autoplace = false; +static bool markbad = false; +static bool forcejffs2 = false; +static bool forceyaffs = false; +static bool forcelegacy = false; +static bool noecc = false; +static bool pad = false; static int blockalign = 1; /*default to using 16K block size */ static void process_options (int argc, char * const argv[]) @@ -161,31 +162,31 @@ static void process_options (int argc, char * const argv[]) } break; case 'q': - quiet = 1; + quiet = true; break; case 'a': - autoplace = 1; + autoplace = true; break; case 'j': - forcejffs2 = 1; + forcejffs2 = true; break; case 'y': - forceyaffs = 1; + forceyaffs = true; break; case 'f': - forcelegacy = 1; + forcelegacy = true; break; case 'n': - noecc = 1; + noecc = true; break; case 'm': - markbad = 1; + markbad = true; break; case 'o': - writeoob = 1; + writeoob = true; break; case 'p': - pad = 1; + pad = true; break; case 's': mtdoffset = strtol (optarg, NULL, 0); @@ -211,7 +212,8 @@ static void process_options (int argc, char * const argv[]) */ int main(int argc, char * const argv[]) { - int cnt, fd, ifd, imglen = 0, pagelen, baderaseblock, blockstart = -1; + int cnt, fd, ifd, imglen = 0, pagelen, blockstart = -1; + bool baderaseblock = false; struct mtd_info_user meminfo; struct mtd_oob_buf oob; loff_t offs; @@ -345,7 +347,7 @@ int main(int argc, char * const argv[]) imglen = lseek(ifd, 0, SEEK_END); lseek (ifd, 0, SEEK_SET); - pagelen = meminfo.writesize + ((writeoob == 1) ? meminfo.oobsize : 0); + pagelen = meminfo.writesize + ((writeoob) ? meminfo.oobsize : 0); // Check, if file is pagealigned if ((!pad) && ((imglen % pagelen) != 0)) { @@ -372,7 +374,7 @@ int main(int argc, char * const argv[]) while (blockstart != (mtdoffset & (~meminfo.erasesize + 1))) { blockstart = mtdoffset & (~meminfo.erasesize + 1); offs = blockstart; - baderaseblock = 0; + baderaseblock = false; if (!quiet) fprintf (stdout, "Writing data to block %x\n", blockstart); @@ -383,7 +385,7 @@ int main(int argc, char * const argv[]) goto closeall; } if (ret == 1) { - baderaseblock = 1; + baderaseblock = true; if (!quiet) fprintf (stderr, "Bad block at %x, %u block(s) " "from %x will be skipped\n",