| Submitter | Phil Sutter |
|---|---|
| Date | Feb. 21, 2013, 5:21 p.m. |
| Message ID | <1361467316-29044-5-git-send-email-phil.sutter@viprinet.com> |
| Download | mbox | patch |
| Permalink | /patch/222380/ |
| State | Accepted |
| Delegated to: | Scott Wood |
| Headers | show |
Comments
On Thu, Feb 21, 2013 at 06:21:56PM +0100, Phil Sutter wrote: > Calculating the checksum of incompletely read data is useless. > > Signed-off-by: Phil Sutter <phil.sutter@viprinet.com> > --- > common/env_nand.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/common/env_nand.c b/common/env_nand.c > index 60a87ec..0e1d17a 100644 > --- a/common/env_nand.c > +++ b/common/env_nand.c > @@ -337,8 +337,8 @@ void env_relocate_spec(void) > puts("*** Warning - some problems detected " > "reading environment; recovered successfully\n"); > > - crc1_ok = crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc; > - crc2_ok = crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc; > + crc1_ok = !read1_fail && (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc); > + crc2_ok = !read2_fail && (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc); Lines over 80 columns -- fixed and applied to u-boot-nand-flash. -Scott
Patch
diff --git a/common/env_nand.c b/common/env_nand.c index 60a87ec..0e1d17a 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -337,8 +337,8 @@ void env_relocate_spec(void) puts("*** Warning - some problems detected " "reading environment; recovered successfully\n"); - crc1_ok = crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc; - crc2_ok = crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc; + crc1_ok = !read1_fail && (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc); + crc2_ok = !read2_fail && (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc); if (!crc1_ok && !crc2_ok) { set_default_env("!bad CRC");
Calculating the checksum of incompletely read data is useless. Signed-off-by: Phil Sutter <phil.sutter@viprinet.com> --- common/env_nand.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)