From: Bill Kendall <wkendall@sgi.com>
To: aelder@sgi.com
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH v2] xfsdump: enable dump header checksums
Date: Tue, 20 Sep 2011 13:27:11 -0500 [thread overview]
Message-ID: <4E78DAFF.3020204@sgi.com> (raw)
In-Reply-To: <1316538365.2912.32.camel@doink>
Alex Elder wrote:
> On Tue, 2011-09-20 at 08:05 -0500, Bill Kendall wrote:
>> +static inline u_int32_t
>> +calc_checksum(void *bufp, size_t len)
>> +{
>> + u_int32_t sum = 0;
>> + u_int32_t *sump = (u_int32_t *)bufp;
>> + u_int32_t *endp = (void *)sump + len
>
> No need to cast a (void *) object to another
> pointer type (and vice-versa).
>
> And although gcc allows arithmetic on void pointers,
> it is not standard, so (char *) would be a more
> portable choice.
Ha...I couldn't remember and when gcc didn't complain
I went with it. Using (char *) requires the result
to be cast back:
u_int32_t *endp = (u_int32_t *)((char *)sump + len)
This is a bit cleaner:
u_int32_t *endp = sump + len / sizeof(u_int32_t);
>
> The multiple-of-4 assumption would be well stated with
> an assertion.
I didn't want to add the extra cycles to a checksum routine,
but realistically it won't affect the run time of dump or
restore and asserts are likely disabled on released binaries
anyway. I'll add the assert here and remove the ones done
during initialization.
Bill
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2011-09-20 18:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-20 13:05 [PATCH v2] xfsdump: enable dump header checksums Bill Kendall
2011-09-20 17:06 ` Alex Elder
2011-09-20 18:27 ` Bill Kendall [this message]
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=4E78DAFF.3020204@sgi.com \
--to=wkendall@sgi.com \
--cc=aelder@sgi.com \
--cc=xfs@oss.sgi.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