From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrick Mansfield Date: Wed, 29 Sep 2004 00:45:39 +0000 Subject: Re: Segfault fix in scsi_id-0.6 Message-Id: <20040929004539.GA2282@beaverton.ibm.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org [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