From: Peter Korsgaard <jacmet@sunsite.dk>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCHv2] commands: add md5/sha1/sha256sum commands using the digest api
Date: Wed, 18 May 2011 09:12:52 +0200 [thread overview]
Message-ID: <87boz0fpmz.fsf@macbook.be.48ers.dk> (raw)
In-Reply-To: <20110518050826.GG18699@game.jcrosoft.org> (Jean-Christophe PLAGNIOL-VILLARD's message of "Wed, 18 May 2011 07:08:26 +0200")
>>>>> "Jean-Christophe" == Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> writes:
Hi,
>> +
>> + data = xmalloc(d->length);
Jean-Christophe> we realloc a buffer here where we alloc one in file_digest
Jean-Christophe> and not free it before calling print_digest
I'm not exactly sure what you mean, but yes - We could inline
print_digest in file_digest and reuse the 4K buf for the digest as
well. That would shrink the code slightly (lines / bytes) and get rid of
the 2nd xmalloc.
I'll fix that and send a v3 shortly.
>> + buf = xmalloc(4096);
Jean-Christophe> do we really need to allocate the buffer everytime?
Not really, but it's simpler to do like this. It's only once per file so
hardly a performance issue.
>> + while (*argv) {
>> + char *filename = "/dev/mem";
>> + ulong start = 0, size = ~0;
Jean-Christophe> ulong so so if we want to support 64bit vfs we need to
Jean-Christophe> use an other type
ulong is what parse_area_spec and the other memory commands use.
>> +#ifdef CONFIG_CMD_MD5SUM
>> +
>> +static int do_md5(struct command *cmdtp, int argc, char *argv[])
>> +{
>> + return do_digest("md5", argc, argv);
Jean-Christophe> pass the cmdtp will be good
Jean-Christophe> I agree it's not necessary now but I think it's a good
Jean-Christophe> practice
I think it makes more sense to add it when (if?) it is needed.
--
Bye, Peter Korsgaard
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-05-18 7:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-17 20:05 Peter Korsgaard
2011-05-18 5:08 ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-18 7:12 ` Peter Korsgaard [this message]
2011-05-18 7:50 ` Jean-Christophe PLAGNIOL-VILLARD
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=87boz0fpmz.fsf@macbook.be.48ers.dk \
--to=jacmet@sunsite.dk \
--cc=barebox@lists.infradead.org \
--cc=plagnioj@jcrosoft.com \
/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