Quality analysis control doubts
I had run the quality analysis control for my code base and i have some doubts regarding some error value seen which is shown below:
this is just the code extract
typedef struct UISR_caller_info_s/*structure declaration*/
{
unsigned char number[20];
unsigned char Name[30];
unsigned int numberType;
} caller_t;
static caller_t gs_val;/*variable of the structure type*/
Error:
2027: strcpy((char *)gs_val.Name, NULL);
^
Msg(2:0310) Casting to different object pointer type.
REFERENCE - ISO:C90-6.3.4 Cast Operators - Semantics <next>
The error is shown at the char * typecasting which i really have no idea why thi开发者_开发知识库s is happening. Please let me know how to avoid this kind of error
Thanks GNR
First of all, that strcpy
call will likely cause a segmentation fault (and definitely causes undefined behaviour) - you probably don't want NULL
for the second parameter. You don't need the cast for your call anyway:
strcpy(gs_value.Name, "");
Will work fine, and is probably what you meant in the first place. It may be that your compiler is very picky, and it's complaining about the cast from unsigned char
to char
- you can fix that by changing your structure appropriately.
精彩评论