public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* flashcp
@ 2007-07-19 18:46 Tobias Simon
  2007-07-19 19:56 ` flashcp Jörn Engel
  0 siblings, 1 reply; 7+ messages in thread
From: Tobias Simon @ 2007-07-19 18:46 UTC (permalink / raw)
  To: linux-mtd

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@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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-07-20  0:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-19 18:46 flashcp Tobias Simon
2007-07-19 19:56 ` flashcp Jörn Engel
2007-07-19 21:08   ` flashcp Tobias Simon
2007-07-19 22:13     ` flashcp Jörn Engel
2007-07-19 22:55       ` flashcp Tobias Simon
2007-07-19 23:23         ` flashcp Tobias Simon
2007-07-20  0:28           ` flashcp Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox