From: Patrick Mansfield <patmans@us.ibm.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: Segfault fix in scsi_id-0.6
Date: Wed, 29 Sep 2004 00:45:39 +0000 [thread overview]
Message-ID: <20040929004539.GA2282@beaverton.ibm.com> (raw)
[following up on hotplug-devel ...]
On Tue, Sep 28, 2004 at 03:33:59PM -0600, Andrew Patterson wrote:
> Hi Patrick,
>
> I found a segfault when running scsi_id on an IA-64 box. I assume you
> will get the same behavior on any box where an int is 32 bits and not
> 64. I have included a patch to fix the problem. Note the "- (char *)0
> change that I stole from lmdd.
>
> Andrew
>
>
>
> diff -Nur scsi_id-0.6/scsi_id.c scsi_id-0.6.new/scsi_id.c
> --- scsi_id-0.6/scsi_id.c 2004-07-30 14:33:59.000000000 -0600
> +++ scsi_id-0.6.new/scsi_id.c 2004-09-28 15:24:44.000000000 -0600
> @@ -713,7 +713,7 @@
>
> #define ALIGN 512
> unaligned_buf = malloc(MAX_SERIAL_LEN + ALIGN);
> - serial = (char*) (((int) unaligned_buf + (ALIGN - 1)) & ~(ALIGN
> - 1));
> + serial = (char*) (((unaligned_buf - (char *)0) + (ALIGN - 1)) &
> ~(ALIGN - 1));
> dprintf("buffer unaligned 0x%p; aligned 0x%p\n", unaligned_buf,
> serial); #undef ALIGN
Thanks for pointing this out, patch works fine.
But how about just casting to unsigned long instead? Like:
Index: scsi_id.c
=================================RCS file: /home/patman/CVS/scsi_id/scsi_id/scsi_id.c,v
retrieving revision 1.36
diff -u -r1.36 scsi_id.c
--- scsi_id.c 30 Jul 2004 20:33:59 -0000 1.36
+++ scsi_id.c 29 Sep 2004 00:38:59 -0000
@@ -713,7 +713,8 @@
#define ALIGN 512
unaligned_buf = malloc(MAX_SERIAL_LEN + ALIGN);
- serial = (char*) (((int) unaligned_buf + (ALIGN - 1)) & ~(ALIGN - 1));
+ serial = (char*) (((unsigned long) unaligned_buf + (ALIGN - 1))
+ & ~(ALIGN - 1));
dprintf("buffer unaligned 0x%p; aligned 0x%p\n", unaligned_buf, serial);
#undef ALIGN
-- Patrick Mansfield
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
next reply other threads:[~2004-09-29 0:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-29 0:45 Patrick Mansfield [this message]
2004-09-29 18:58 ` Segfault fix in scsi_id-0.6 Dave Dodge
2004-09-29 20:21 ` Andrew Patterson
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=20040929004539.GA2282@beaverton.ibm.com \
--to=patmans@us.ibm.com \
--cc=linux-hotplug@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).