Re: [Linux-ia64] do me a favor

From: Qiu HongBing <qiuhb_at_necas.nec.co.jp>
Date: 2001-11-13 12:59:07
But next example happened same.

...
newtComponent newtEntry(int left, int top, const char* initialValue, int
width, char** resultPtr,int flags);
...

char d[20][20];
...
entry[2]=newtEntry(-1,-1,d[2],10,(char**)&d[11],NEWT_ENTRY_SCROLL);--->>outp
ut the unaligned access
...
entry[3]=newtEntry(-1,-1,d[7],10,(char**)&d[16],NEWT_ENTRY_SCROLL);
...


but , If I changed it to as follows and it is OK.

...
newtComponent newtEntry9int left, int top, const char* initialValue, int
width, char** resultPtr,int flags);
...

char d[20][20];
...
{
char temp[20];
sprintf(temp,"%s",d[11]);
entry[2]=newtEntry(-1,-1,d[2],10,(char**)&temp/*&d[11]*/,NEWT_ENTRY_SCROLL);
sprintf(d[11],"%s",temp);
}
...
entry[3]=newtEntry(-1,-1,d[7],10,(char**)&d[16],NEWT_ENTRY_SCROLL);
...

I want to know why.
That's all.
Thanks.

        --Qiu HongBing


----- Original Message -----
From: "Dan Pop" <Dan.Pop@cern.ch>
To: "Qiu HongBing" <qiuhb@necas.nec.co.jp>
Cc: <linux-ia64@linuxia64.org>
Sent: Tuesday, November 13, 2001 9:20 AM
Subject: Re: [Linux-ia64] do me a favor


>
>
> On Tue, 13 Nov 2001, Qiu HongBing wrote:
>
> > My problem is as follows:
> >
> > struct aa{
> > unsigned short a;
> > unsigned short b;
> > unsigned short c;
> > unsigned short d;
> > unsigned int e;
> > unsigned int f;
> > unsigned int g;
> > unsigned int h;
> > unsigned short i;
> > }
> > ...
> > struct aa *a1;
> > ...
> >
> > fun1(char *,unsigned int *,char *,char *,unsigned int * temp,unsigned
int *)
> > {
> > ...
> > *temp=10;
> > ...
> > }
> > ...
> >
> > fun1(a,b,c,d,&a1->b,e);
> > ...
> >
> > On IA64 Linux RedHat 7.1(2.4.3-3), when the program run to
> > fun1(a,b,c,d,&a1->b,e), the kernel write into syslog some message which
is
> > "Nov  5 10:12:02 sdv2 kernel: ESMmlx(7837): unaligned access to
> > 0x600000000001684c, ip=0x2000000000624370".
>
> The reason is obvious: fun1 expects temp to be a pointer to unsigned
> int, but you're passing it &a1->b, which is a pointer to unsigned
> short.  The compiler should have actually warned you about that.
>
> > But if I modify the source as follows and it is OK. I dont know why. So
I
> > want to get some help to solve the real cause.
>
> Then, either define the b member as unsigned int, or the temp
> parameter as pointer to unsigned short.
>
> Dan
>
>
Received on Mon Nov 12 18:00:07 2001

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:05 EST