一般数据终止异常在编程方面是:指针操作错误,或者数组越界等等!而我现在一下的程序(在S3C2440裸奔时)就是看不出哪里造成数据终止异常,现在请教各位大侠!
struct FAT_Init_Arg Init_Arg_SD;
struct FAT_Init_Arg *pArg=NULL;
UINT32 FAT_Enter_Dir(INT8 *path)
{
UINT32 Cur_Clust=0,sec_temp=0,iSec=0,iDir=0,Old_Clust=0;
UINT8 i=1,counter=0,flag=0;
struct direntry *pDir=NULL;
INT8 name[20]={0};
INT8 *Mypath=NULL;
Mypath=(INT8 *)malloc(30);
Mypath=path;
pDir=malloc(sizeof(struct direntry));
pArg=&Init_Arg_SD;
Cur_Clust=pArg->FirstDirClust;
if(*(Mypath+1)==0 && *(Mypath+0)=='\\')
{
Uart_Printf("*(Mypath+1)=%xh,*(Mypath+0)=%xh \n", *(Mypath+1),*(Mypath+0));
return Cur_Clust;
}
else
{
while(*(Mypath+i)!=0)
{
if(*(Mypath+i)=='\\')
{
for(;counter<8;counter++)
{
name[counter]=' ';
}
name[counter]=0;
counter=0;
do
{
sec_temp=(SOC(Cur_Clust));
for(iSec=sec_temp;iSecSectorsPerClust;iSec++)
{
Rd_Block(iSec, 1, (U32*)FAT32_Buffer);
Uart_Printf("iSec one of all sectors =%xh\n", iSec);
for(iDir=0;iDirBytesPerSector;iDir+=sizeof(struct direntry))
{
pDir=((struct direntry *)(FAT32_Buffer+iDir));
if(Compare_Dir_Name((INT8*)pDir->deName,(INT8*)name))
{
flag=1;
Cur_Clust=pDir->deLowCluster[0]+(pDir->deLowCluster[1]<<8)+(pDir->deHighClust[0]<<16)+(pDir->deHighClust[1]<<24);
iDir=pArg->BytesPerSector;
iSec=sec_temp+pArg->SectorsPerClust;
}
}
}
Old_Clust=Cur_Clust;
}while(!flag && (Cur_Clust=FAT32_GetNextCluster(Cur_Clust))!=0x0fffffff);
if(!flag)
{
temp_dir_cluster=Old_Clust;
strcpy(temp_dir_name,name);
flag=0;
free(pDir);
free(Mypath);
return 0;
}
flag=0;
}
else
{
name[counter++]=(L2U(*(Mypath+i)));
Uart_Printf("*(Mypath+i)=%xh ,i=%d \n", *(Mypath+i),i);
}
i++;
}
}
name[counter]=0;
flag=1;
temp_dir_cluster=Cur_Clust;
strcpy(temp_dir_name,name);
free(pDir);
free(Mypath);
return Cur_Clust;
}
而当我把红色的代码屏蔽之后,就没出现数据终止异常。