This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: RedBoot sending incorrect TCP window size


Grant Edwards wrote:

> All occurrences of "sizeof (eth_header_t)" in net.h, tcp.c, udp.c
> need to be replace by a hard coded constant.  I'll send a patch
> later today...
>
> --
> Grant Edwards
> grante@visi.com

You can always avoid the hard coded constant by computing the
"real" limit of the struct as the offset to the last field + the
size of this last field. This should always work if the last field
is not a struct/bitfield ! (See stddef.h)

To finnish with the "sizeof" story, you will see with following sample that
the reported value of sizeof is compatible with the data representation
and obviously with pointer arithmetic. Look at gernerated asm.

--
#include <stddef.h>

typedef unsigned char t[6];

typedef struct {
  t x1;
  t x2;
  unsigned short s;
} st;

const int is = sizeof(s);
const st stt[2] = { { {1,2,3,4,5,6}, {1,2,3,4,5,6}, 1000 },
                    { {1,2,3,4,5,6}, {1,2,3,4,5,6}, 2000 } };

--
Eric DONNAT

Silicomp Research Institute
2 avenue de Vignate, 38610 Gieres, France.
http://www.ri.silicomp.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]