aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2011-08-19 10:07:55 -0700
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2011-08-23 09:27:50 +0300
commit6e894b9fd9544c109817bd88811d83cd93970e31 (patch)
treee32eb4c6aa3304e43e7b5ed74599db43f9b6c7ac
parent56db38eb2a2642aea87bb9c5dd247bd4f383eb64 (diff)
nandwrite: refactor "old_oobinfo" code
Move variable within conditional and remove duplicated code. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
-rw-r--r--nandwrite.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/nandwrite.c b/nandwrite.c
index e90c032..95baa38 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -497,7 +497,6 @@ int main(int argc, char * const argv[])
if (!noecc) {
int i, start, len;
- int tags_pos = 0;
struct nand_oobinfo old_oobinfo;
/* Read the current oob info */
@@ -515,16 +514,13 @@ int main(int argc, char * const argv[])
* such as the layout used by diskonchip.c
*/
if (old_oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
+ int tags_pos = 0, tmp_ofs;
for (i = 0; old_oobinfo.oobfree[i][1]; i++) {
/* Set the reserved bytes to 0xff */
start = old_oobinfo.oobfree[i][0];
len = old_oobinfo.oobfree[i][1];
- if (rawoob)
- memcpy(oobbuf + start,
- oobreadbuf + start, len);
- else
- memcpy(oobbuf + start,
- oobreadbuf + tags_pos, len);
+ tmp_ofs = rawoob ? start : tags_pos;
+ memcpy(oobbuf + start, oobreadbuf + tmp_ofs, len);
tags_pos += len;
}
} else {