Hi s.kr !
This is
C language code, yes?
Quote:
Originally Posted by s.kr
[...]
int data[iov.iov_len];
int i;
//zero the content
for (i=0;i<iov.iov_len;i++)
data[i]=0;
//fill data
data[i]=(*((int**)iov.iov_base))[i];
//print data
for (i=0;i<iov.iov_len;i++)
printk("%d",data[i]);
[...]
|
You don't show this code:
Quote:
//fill data
data[i]=(*((int**)iov.iov_base))[i];
|
as being in a loop. Is it inside a loop? Or did you only intend to copy
only as many bytes as fit inside one
int on the processor that's being used?
Maybe this
C code will show you what I mean:
Code:
# include <stdio.h>
# define IOV_LEN 20
int main( int ac , char *av[] )
{
char iov_base[IOV_LEN] = "ME WANT CORE DUMP!" ;
int data[IOV_LEN] ;
int i ;
printf( "sizeof(iov_base)=%d\n", sizeof(iov_base) ) ;
printf( "sizeof(\"ME WANT CORE DUMP!\")=%d\n", sizeof("ME WANT CORE DUMP!") ) ;
printf( "sizeof(data)=%d\n", sizeof(data) ) ;
printf( "sizeof(i)=%d\n", sizeof(i) ) ;
//zero the content
for ( i=0 ; i<IOV_LEN ; i++ )
data[i] = 0 ;
printf( "i = %d\n" , i ) ;
//fill data
data[i] = ( *( (int**) iov_base ) )[i] ;
printf( "Executed assignment for filling data\n" ) ;
//print data
for ( i=0 ; i < IOV_LEN ; i++ )
printf( "%d\n", data[i] ) ;
printf( "Executed loop to print data\n" ) ;
}
I'm expecting it will crash before it finishes executing the assignment statement. So we'll never see the message saying that it executed the assignment statement.
Here's the output when I run the compiled program:
Code:
sizeof(iov_base)=20
sizeof("ME WANT CORE DUMP!")=19
sizeof(data)=80
sizeof(i)=4
i = 20
Segmentation fault
When means it crashed while trying to execute the assignment statement.
Hope this helps.