public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Tobias Simon <tobias.simon@sp-ss.de>
To: linux-mtd@lists.infradead.org
Subject: flashcp
Date: Thu, 19 Jul 2007 20:46:46 +0200	[thread overview]
Message-ID: <200707192046.47340.tobias.simon@sp-ss.de> (raw)

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.

             reply	other threads:[~2007-07-19 18:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-19 18:46 Tobias Simon [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200707192046.47340.tobias.simon@sp-ss.de \
    --to=tobias.simon@sp-ss.de \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox