{"id":198,"url":"http://patchwork.ozlabs.org/api/1.0/patches/198/?format=json","project":{"id":3,"url":"http://patchwork.ozlabs.org/api/1.0/projects/3/?format=json","name":"Linux MTD development","link_name":"linux-mtd","list_id":"linux-mtd.lists.infradead.org","list_email":"linux-mtd@lists.infradead.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<1220848143-22348-1-git-send-email-gerickson@nuovations.com>","date":"2008-09-08T04:29:03","name":"nandwrite: Use Boolean Mnemonics from stdbool.h","commit_ref":"6c812a3b2691cc6c6898bdc52e4d90c506e69be8","pull_url":null,"state":"accepted","archived":false,"hash":"2c162567afb65197b514bb5ba07a4f3656ffeddf","submitter":{"id":115,"url":"http://patchwork.ozlabs.org/api/1.0/people/115/?format=json","name":"Grant Erickson","email":"gerickson@nuovations.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-mtd/patch/1220848143-22348-1-git-send-email-gerickson@nuovations.com/mbox/","series":[],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/198/checks/","tags":{},"headers":{"Return-Path":"<linux-mtd-bounces+patchwork=ozlabs.org@lists.infradead.org>","X-Original-To":"patchwork@ozlabs.org","Delivered-To":"patchwork@ozlabs.org","Received":["from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])\n\t(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\n\t(Client did not present a certificate)\n\tby ozlabs.org (Postfix) with ESMTPS id 5CC58DDDFA\n\tfor <patchwork@ozlabs.org>; Mon,  8 Sep 2008 14:29:12 +1000 (EST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux))\n\tid 1KcYN8-0002Vq-Qc; Mon, 08 Sep 2008 04:29:06 +0000","from relay00.pair.com ([209.68.5.9])\n\tby bombadil.infradead.org with smtp (Exim 4.68 #1 (Red Hat Linux))\n\tid 1KcYN7-0002Vc-Ku\n\tfor linux-mtd@lists.infradead.org; Mon, 08 Sep 2008 04:29:05 +0000","(qmail 36547 invoked by uid 0); 8 Sep 2008 04:29:03 -0000","from unknown (HELO localhost.localdomain) (unknown)\n\tby unknown with SMTP; 8 Sep 2008 04:29:03 -0000"],"X-pair-Authenticated":"66.134.71.115","From":"Grant Erickson <gerickson@nuovations.com>","To":"linux-mtd@lists.infradead.org","Subject":"[PATCH 4/6] [MTD-UTILS] nandwrite: Use Boolean Mnemonics from\n\tstdbool.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:\n\tContent analysis details:   (-1.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-1.0 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow 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 <linux-mtd.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-mtd>","List-Post":"<mailto:linux-mtd@lists.infradead.org>","List-Help":"<mailto:linux-mtd-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"linux-mtd-bounces@lists.infradead.org","Errors-To":"linux-mtd-bounces+patchwork=ozlabs.org@lists.infradead.org"},"content":"Added include directive for stdbool.h and leveraged where appropriate\nto improve code readability by making variable intent and usage more\nexplicit.\n\nSigned-off-by: Grant Erickson <gerickson@nuovations.com>","diff":"diff --git a/nandwrite.c b/nandwrite.c\nindex e5de140..5fbed41 100644\n--- a/nandwrite.c\n+++ b/nandwrite.c\n@@ -23,6 +23,7 @@\n #include <ctype.h>\n #include <errno.h>\n #include <fcntl.h>\n+#include <stdbool.h>\n #include <stdio.h>\n #include <stdlib.h>\n #include <string.h>\n@@ -108,15 +109,15 @@ static void display_version (void)\n \n static const char\t*mtd_device, *img;\n static int\t\tmtdoffset = 0;\n-static int\t\tquiet = 0;\n-static int\t\twriteoob = 0;\n-static int\t\tmarkbad = 0;\n-static int\t\tautoplace = 0;\n-static int\t\tforcejffs2 = 0;\n-static int\t\tforceyaffs = 0;\n-static int\t\tforcelegacy = 0;\n-static int\t\tnoecc = 0;\n-static int\t\tpad = 0;\n+static bool\t\tquiet = false;\n+static bool\t\twriteoob = false;\n+static bool\t\tautoplace = false;\n+static bool\t\tmarkbad = false;\n+static bool\t\tforcejffs2 = false;\n+static bool\t\tforceyaffs = false;\n+static bool\t\tforcelegacy = false;\n+static bool\t\tnoecc = false;\n+static bool\t\tpad = false;\n static int\t\tblockalign = 1; /*default to using 16K block size */\n \n static void process_options (int argc, char * const argv[])\n@@ -161,31 +162,31 @@ static void process_options (int argc, char * const argv[])\n \t\t\t\t}\n \t\t\t\tbreak;\n \t\t\tcase 'q':\n-\t\t\t\tquiet = 1;\n+\t\t\t\tquiet = true;\n \t\t\t\tbreak;\n \t\t\tcase 'a':\n-\t\t\t\tautoplace = 1;\n+\t\t\t\tautoplace = true;\n \t\t\t\tbreak;\n \t\t\tcase 'j':\n-\t\t\t\tforcejffs2 = 1;\n+\t\t\t\tforcejffs2 = true;\n \t\t\t\tbreak;\n \t\t\tcase 'y':\n-\t\t\t\tforceyaffs = 1;\n+\t\t\t\tforceyaffs = true;\n \t\t\t\tbreak;\n \t\t\tcase 'f':\n-\t\t\t\tforcelegacy = 1;\n+\t\t\t\tforcelegacy = true;\n \t\t\t\tbreak;\n \t\t\tcase 'n':\n-\t\t\t\tnoecc = 1;\n+\t\t\t\tnoecc = true;\n \t\t\t\tbreak;\n \t\t\tcase 'm':\n-\t\t\t\tmarkbad = 1;\n+\t\t\t\tmarkbad = true;\n \t\t\t\tbreak;\n \t\t\tcase 'o':\n-\t\t\t\twriteoob = 1;\n+\t\t\t\twriteoob = true;\n \t\t\t\tbreak;\n \t\t\tcase 'p':\n-\t\t\t\tpad = 1;\n+\t\t\t\tpad = true;\n \t\t\t\tbreak;\n \t\t\tcase 's':\n \t\t\t\tmtdoffset = strtol (optarg, NULL, 0);\n@@ -211,7 +212,8 @@ static void process_options (int argc, char * const argv[])\n  */\n int main(int argc, char * const argv[])\n {\n-\tint cnt, fd, ifd, imglen = 0, pagelen, baderaseblock, blockstart = -1;\n+\tint cnt, fd, ifd, imglen = 0, pagelen, blockstart = -1;\n+\tbool baderaseblock = false;\n \tstruct mtd_info_user meminfo;\n \tstruct mtd_oob_buf oob;\n \tloff_t offs;\n@@ -345,7 +347,7 @@ int main(int argc, char * const argv[])\n \timglen = lseek(ifd, 0, SEEK_END);\n \tlseek (ifd, 0, SEEK_SET);\n \n-\tpagelen = meminfo.writesize + ((writeoob == 1) ? meminfo.oobsize : 0);\n+\tpagelen = meminfo.writesize + ((writeoob) ? meminfo.oobsize : 0);\n \n \t// Check, if file is pagealigned\n \tif ((!pad) && ((imglen % pagelen) != 0)) {\n@@ -372,7 +374,7 @@ int main(int argc, char * const argv[])\n \t\twhile (blockstart != (mtdoffset & (~meminfo.erasesize + 1))) {\n \t\t\tblockstart = mtdoffset & (~meminfo.erasesize + 1);\n \t\t\toffs = blockstart;\n-\t\t\tbaderaseblock = 0;\n+\t\t\tbaderaseblock = false;\n \t\t\tif (!quiet)\n \t\t\t\tfprintf (stdout, \"Writing data to block %x\\n\", blockstart);\n \n@@ -383,7 +385,7 @@ int main(int argc, char * const argv[])\n \t\t\t\t\tgoto closeall;\n \t\t\t\t}\n \t\t\t\tif (ret == 1) {\n-\t\t\t\t\tbaderaseblock = 1;\n+\t\t\t\t\tbaderaseblock = true;\n \t\t\t\t\tif (!quiet)\n \t\t\t\t\t\tfprintf (stderr, \"Bad block at %x, %u block(s) \"\n \t\t\t\t\t\t\t\t\"from %x will be skipped\\n\",\n","prefixes":[]}