Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Pointer arithmetic in src/direnum.c:561

fsvs
Discussion topic

Back to topic list

Pointer arithmetic in src/direnum.c:561

Author Jon <fsvs at jonmail dot co dot uk>
Full name Jon <fsvs at jonmail dot co dot uk>
Date 2008-09-18 06:36:41 PDT
Message 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

« Previous message in topic | 1 of 2 | Next message in topic »

Messages

Show all messages in topic

Pointer arithmetic in src/direnum.c:561 Jon <fsvs at jonmail dot co dot uk> Jon <fsvs at jonmail dot co dot uk> 2008-09-18 06:36:41 PDT
     Re: Pointer arithmetic in src/direnum.c:561 pmarek P.Marek 2008-09-18 08:54:58 PDT
Messages per page: