mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@googlemail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 6/8] nandtest: clean up code
Date: Mon, 22 Oct 2012 09:23:30 +0200	[thread overview]
Message-ID: <1350890612-10588-7-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1350890612-10588-1-git-send-email-alex.aring@gmail.com>

Clean up code:

	- change 'i+i' to 'i + i'.
	- change counter variable to unsigned int.
	- use spaces instead of tabs in help text.
	- remove __test_ofs variable.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 commands/nandtest.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/commands/nandtest.c b/commands/nandtest.c
index cdf9c31..ead728b 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -144,8 +144,8 @@ static int erase_and_write(off_t ofs, unsigned char *data,
 				ecc_stats_over++;
 			} else {
 				/* Increment ECC stat value */
-				ecc_stats[(newstats.corrected-
-						oldstats.corrected)-1]++;
+				ecc_stats[(newstats.corrected -
+						oldstats.corrected) - 1]++;
 			}
 			/* Set oldstats to newstats */
 			oldstats.corrected = newstats.corrected;
@@ -179,13 +179,13 @@ static int erase_and_write(off_t ofs, unsigned char *data,
 /* Print stats of nandtest. */
 static void print_stats(int nr_passes, int length)
 {
-	int i;
+	unsigned int i;
 	printf("-------- Summary --------\n");
 	printf("Tested blocks		: %d\n", (length/meminfo.erasesize)
 			* nr_passes);
 
 	for (i = 0; i < MAX_ECC_BITS; i++)
-		printf("ECC %d bit error(s)	: %d\n", i+1, ecc_stats[i]);
+		printf("ECC %d bit error(s)	: %d\n", i + 1, ecc_stats[i]);
 
 	printf("ECC >%d bit error(s)	: %d\n", MAX_ECC_BITS, ecc_stats_over);
 	printf("ECC corrections failed	: %d\n", ecc_failed_cnt);
@@ -195,10 +195,9 @@ static void print_stats(int nr_passes, int length)
 /* Main program. */
 static int do_nandtest(int argc, char *argv[])
 {
-	int opt, do_nandtest_dev = -1;
+	int opt, do_nandtest_dev = -1, ret = -1;
 	off_t flash_offset = 0, test_ofs, length = 0;
 	unsigned int nr_iterations = 1, iter;
-	int ret = -1;
 	unsigned char *wbuf, *rbuf;
 
 	ecc_failed_cnt = 0;
@@ -276,10 +275,10 @@ static int do_nandtest(int argc, char *argv[])
 	}
 
 	printf("Flash offset: 0x%08x\n",
-			(unsigned)(flash_offset+memregion.offset));
+			(unsigned)(flash_offset + memregion.offset));
 	printf("Length: 0x%08x\n", (unsigned)length);
 	printf("End address: 0x%08x\n",
-			(unsigned)(flash_offset+length+memregion.offset));
+			(unsigned)(flash_offset + length + memregion.offset));
 	printf("Erasesize: 0x%08x\n", (unsigned)(meminfo.erasesize));
 	printf("Starting nandtest...\n");
 
@@ -311,14 +310,13 @@ static int do_nandtest(int argc, char *argv[])
 	for (iter = 0; iter < nr_iterations; iter++) {
 		init_progression_bar(length);
 		for (test_ofs = flash_offset;
-				test_ofs < flash_offset+length;
+				test_ofs < flash_offset + length;
 				test_ofs += meminfo.erasesize) {
-			loff_t __test_ofs = test_ofs;
 			show_progress(test_ofs);
 			srand(seed);
 			seed = rand();
 
-			if (ioctl(fd, MEMGETBADBLOCK, &__test_ofs)) {
+			if (ioctl(fd, MEMGETBADBLOCK, &test_ofs)) {
 				printf("\nBad block at 0x%08x\n",
 						(unsigned)(test_ofs +
 							memregion.offset));
@@ -334,7 +332,7 @@ static int do_nandtest(int argc, char *argv[])
 				goto err2;
 		}
 		show_progress(test_ofs);
-		printf("\nFinished pass %d successfully\n", iter+1);
+		printf("\nFinished pass %d successfully\n", iter + 1);
 	}
 
 	print_stats(nr_iterations, length);
@@ -359,12 +357,12 @@ err:
 /* String for usage of nandtest */
 static const __maybe_unused char cmd_nandtest_help[] =
 "Usage: nandtest [OPTION] <device>\n"
-		"  -t,	Really do a nandtest on device.\n"
-		"  -m,	Mark blocks bad if they appear so.\n"
-		"  -s	<seed>,	Supply random seed.\n"
-		"  -i	<iterations>, Number of iterations.\n"
-		"  -o	<offset>, Start offset on flash.\n"
-		"  -l	<length>, Length of flash to test.\n";
+		"  -t,  Really do a nandtest on device.\n"
+		"  -m,  Mark blocks bad if they appear so.\n"
+		"  -s   <seed>, Supply random seed.\n"
+		"  -i   <iterations>, Number of iterations.\n"
+		"  -o   <offset>, Start offset on flash.\n"
+		"  -l   <length>, Length of flash to test.\n";
 
 BAREBOX_CMD_START(nandtest)
 	.cmd		= do_nandtest,
-- 
1.7.12.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-10-22  7:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22  7:23 [PATCH 0/8] improve nandtest command Alexander Aring
2012-10-22  7:23 ` [PATCH 1/8] nandtest: stat ecc per page not per eraseblock Alexander Aring
2012-10-22  7:23 ` [PATCH 2/8] nandtest: add progressbar instead of offset print Alexander Aring
2012-10-22  7:23 ` [PATCH 3/8] nandtest: rename command argument p to i Alexander Aring
2012-10-22  7:23 ` [PATCH 4/8] nandtest: change flash length variable type Alexander Aring
2012-10-22  7:23 ` [PATCH 5/8] nandtest: use get_random_bytes instead of for loop Alexander Aring
2012-10-22  7:23 ` Alexander Aring [this message]
2012-10-22  7:23 ` [PATCH 7/8] nandtest: use loff_t instead off_t Alexander Aring
2012-10-22  7:23 ` [PATCH 8/8] nandtest: add another constraints check Alexander Aring
2012-10-23  6:27 ` [PATCH 0/8] improve nandtest command Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350890612-10588-7-git-send-email-alex.aring@gmail.com \
    --to=alex.aring@googlemail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox