From: Jim Rees <rees@umich.edu>
To: Benny Halevy <bhalevy@panasas.com>
Cc: linux-nfs@vger.kernel.org, peter honeyman <honey@citi.umich.edu>
Subject: Re: [PATCH 4/5] various minor cleanups
Date: Thu, 2 Dec 2010 09:41:26 -0500 [thread overview]
Message-ID: <20101202144126.GA14604@merit.edu> (raw)
In-Reply-To: <4CF7A8F9.8010902@panasas.com>
Benny Halevy wrote:
>> -static char *pretty_sig(char *sig, int siglen)
>> +static char *pretty_sig(char *sig, uint32_t siglen)
>> {
>> static char rs[100];
>> - unsigned int i;
>> + unsigned long i;
>>
>> - if (siglen <= 4) {
>> + if (siglen <= sizeof i) {
>> memcpy(&i, sig, sizeof i);
>> - sprintf(rs, "0x%0x", i);
>> + sprintf(rs, "0x%0lx", i);
>
> What about machine endianess?
> The MDS and clients may be of different gender, no?
> Also, on 64 bit machines, you may copy 8 bytes while the signature
> is 4-bytes long so you may copy junk into i.
>
> Benny
>
>> } else {
>> + if (siglen > sizeof rs - 1)
>> + siglen = sizeof rs - 1;
Hmm, for courtesy purposes, how about ending the truncated
signature with "..."?
I am glad you are paying attention! I am aware of the shortcomings of
pretty_sig(). In addition to the problems you noted, it also assumes that a
signature over 8 bytes long is representable as a text string, which is not
guaranteed. The code it replaced was worse.
I put this in because for debugging I need to be able to follow a signature
all the way from my EMC server to the devmapper. pretty_sig() simply prints
the signature in a way that I can match it up with the signature on the
server.
I don't want to spend a lot of time on this, but I also am uneasy leaving
EMC-specific code in nfs-utils, especially since it can blow up if you use
it against a non-EMC server. My inclination is to remove this debugging
code when I no longer need it. I guess at the very least I should put in a
comment. I am open to suggestions.
next prev parent reply other threads:[~2010-12-02 14:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-30 19:13 [PATCH 0/5] nfs-utils: various changes Jim Rees
2010-11-30 19:13 ` [PATCH 1/5] add blkmapd and spnfsd to list of build targets to ignore Jim Rees
2010-12-02 14:05 ` Benny Halevy
2010-11-30 19:13 ` [PATCH 2/5] Remove blkmapd config file, which is no longer used Jim Rees
2010-12-02 14:06 ` Benny Halevy
2010-11-30 19:14 ` [PATCH 3/5] disk signature fixes Jim Rees
2010-11-30 19:14 ` [PATCH 4/5] various minor cleanups Jim Rees
2010-12-02 13:59 ` Benny Halevy
2010-12-02 14:11 ` Benny Halevy
2010-12-02 14:40 ` [PATCH] SQUASHME: decorate truncated signatures with "..." Benny Halevy
2010-12-02 14:41 ` Jim Rees [this message]
2010-12-02 14:43 ` [PATCH 4/5] various minor cleanups Benny Halevy
2010-12-02 16:10 ` Jim Rees
2010-12-02 14:35 ` [PATCH] SQUASHME: blkmapd: fix pretty_sig short sig endianess agnosticity Benny Halevy
2010-12-02 16:24 ` Jim Rees
2010-12-02 16:30 ` Benny Halevy
2010-12-02 16:58 ` Jim Rees
2010-11-30 19:14 ` [PATCH 5/5] device mapping fixes Jim Rees
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=20101202144126.GA14604@merit.edu \
--to=rees@umich.edu \
--cc=bhalevy@panasas.com \
--cc=honey@citi.umich.edu \
--cc=linux-nfs@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).