flashcp
Tobias Simon
tobias.simon at sp-ss.de
Thu Jul 19 14:46:46 EDT 2007
Hello everybody,
I am new in this list.
Today I found a bug in the flashcp program of the mtd-utils:
In Line 260 of flashcp.c, the following operation is performed:
erase.length = filestat.st_size & ~(mtd.erasesize - 1);
I think that is not correct, because if mtd.erasesize is not a power of 2,
using a bitmask is wrong. ARM dataflash, for instance has a erasesize of
1056. My suggestion is the following code replacement, which uses modular
arithmetics:
if (filestat.st_size <= mtd.erasesize)
{
erase.length = mtd.erasesize;
}
else
{
erase.length = filestat.st_size + mtd.erasesize - (filestat.st_size %
mtd.erasesize);
}
What's your opinion?
--
Mit freundlichem Gruß / Kind regards
Tobias Simon
- Entwickler -
Simon + Puschmann Software-Systeme GbR
Tobias Simon, Andre Puschmann
Bergrat-Voigt-Straße 13
98693 Ilmenau
Tel.: 0173/2752144
E-Mail: tobias.simon at sp-ss.de
Internet: http://www.sp-ss.de
------------------------------------------------------------------------
Important Note: This e-mail and any attachments are confidential, may contain
trade secrets and may well also be legally privileged or otherwise protected
from disclosure. If you have received it in error, you are on notice of its
status. Please notify us immediately by reply e-mail and then delete this
e-mail and any attachment from your system. If you are not the intended
recipient please understand that you must not copy this e-mail or any
attachments or disclose the contents to any other person. Thank you.
More information about the linux-mtd
mailing list