Jon | 18 Sep 15:34

Pointer arithmetic in src/direnum.c:561

Hi,

I think line src/direnum.c:561 should change from:

  sts->name=names[i] + this->strings;

to:

  sts->name=this->strings + names[i];

I have spent the last 3 evenings trying to get fsvs running on my Nokia
N800 and kept getting segmentation faults every time I ran the command:

  fsvs commit -m 'yada-yada-yada' /etc

Using DEBUGP and binary chopping through the code I tracked the segfault
down to src/direnum.c:587 which uses sts->name.  The last change to
sts->name was made at 561 which does the fancy pointer arithmetic to
convert an integer offset from the names[] array to a char*.

I use a cross-compiler to build programs for the Nokia N800.  I
suspect that the compiler will only generate the code I want when the
source expression looks like char*+int.  I think it generates bad
code when the source expression is int+char*.

Thanks
Jonty
Philipp Marek | 18 Sep 17:54

Re: Pointer arithmetic in src/direnum.c:561

Hello Jonty!

On Thursday 18 September 2008 Jon wrote:
> I think line src/direnum.c:561 should change from:
>
>   sts->name=names[i] + this->strings;
>
> to:
>
>   sts->name=this->strings + names[i];
...
> I think it generates bad
> code when the source expression is int+char*.
Yes, you're right.
It's a bit cleaner that way.

Fixed in r1882.
Thank you!

Regards,

Phil

--

-- 
Versioning your /etc, /home or even your whole installation?
             Try fsvs (fsvs.tigris.org)!

Gmane