From: Timur Tabi <timur@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH v3] Fix initrd length miscalculation in bootm command when using a dtu
Date: Thu, 03 May 2007 20:13:30 -0500 [thread overview]
Message-ID: <463A88BA.2030607@freescale.com> (raw)
In-Reply-To: <20070503234727.6000F3535DD@atlas.denx.de>
Wolfgang Denk wrote:
> So before your patch we had "len", "checksum", and "data", and now we
> have "len", "data", and "checksum".
>
> What is your reason for this change? I see no functinal difference
> nor any improvement of readability.
It's for the comment that I added. I wanted to make sure that the reader understood what
'len' and 'data' are for, since their purpose is not obvious from just reading the code.
>> - if (crc32 (0, (uchar *)data, len) != checksum) {
>> + if (crc32 (0, (uchar *) &header, sizeof(image_header_t)) != checksum) {
>
> This looks functionally identical to me, but is less readable.
The point behind the patch is to make sure that 'len' and 'data' are only used for the
purpose they are intended. Here, len and data are used as temporary variables.
>
>> @@ -779,9 +776,8 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
>>
>> checksum = ntohl(hdr->ih_dcrc);
>> addr = (ulong)((uchar *)(hdr) + sizeof(image_header_t));
>> - len = ntohl(hdr->ih_size);
>>
>> - if(checksum != crc32(0, (uchar *)addr, len)) {
>> + if(checksum != crc32(0, (uchar *)addr, ntohl(hdr->ih_size))) {
>
> Same here. functionally identical but less readable.
Not true. In this case, len has already been assigned the length of the initrd, and here
we lose this value. Without this change, the kernel will panic at boot.
> With this patch it is impossible to see what the problem is you are
> trying to fix.
It's clearly explained in the comment: 'data' and 'len' are the address and length of the
initrd, so this patch makes sure that these variables only contain those values.
--
Timur Tabi
Linux Kernel Developer @ Freescale
next prev parent reply other threads:[~2007-05-04 1:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-03 22:30 [U-Boot-Users] [PATCH v3] Fix initrd length miscalculation in bootm command when using a dtu Timur Tabi
2007-05-03 23:47 ` Wolfgang Denk
2007-05-04 1:13 ` Timur Tabi [this message]
2007-05-04 8:28 ` Wolfgang Denk
2007-05-04 13:25 ` Timur Tabi
2007-05-04 13:46 ` Stefan Roese
2007-05-04 14:22 ` Jerry Van Baren
2007-05-04 16:02 ` Timur Tabi
2007-05-04 16:07 ` Jerry Van Baren
2007-05-04 15:57 ` Timur Tabi
2007-05-04 16:27 ` Wolfgang Denk
2007-05-04 16:32 ` Timur Tabi
2007-05-04 19:28 ` Wolfgang Denk
2007-05-04 19:40 ` Timur Tabi
2007-05-04 21:58 ` Timur Tabi
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=463A88BA.2030607@freescale.com \
--to=timur@freescale.com \
--cc=u-boot@lists.denx.de \
/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