From: Mike Frysinger Date: Fri, 20 Jan 2012 14:07:22 -0500 Subject: [U-Boot] [PATCH 3/3] cmd_mem: cmp: convert while() to for() loop In-Reply-To: <1327086442-18016-1-git-send-email-vapier@gentoo.org> References: <1327086442-18016-1-git-send-email-vapier@gentoo.org> Message-ID: <1327086442-18016-3-git-send-email-vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Simplify the code slightly by using a for() loop since this is basically what we're already doing -- incrementing "ngood" to the value in "count". Signed-off-by: Mike Frysinger --- common/cmd_mem.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 03e7f87..7a5addc 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -296,9 +296,7 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif - ngood = 0; - - while (count-- > 0) { + for (ngood = 0; ngood < count; ++ngood) { ulong word1, word2; if (size == 4) { word1 = *(ulong *)addr1; @@ -318,12 +316,11 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; } - ngood++; addr1 += size; addr2 += size; /* reset watchdog from time to time */ - if ((count % (64 << 10)) == 0) + if ((ngood % (64 << 10)) == 0) WATCHDOG_RESET(); } -- 1.7.7.3