Is this bad coding practice?
- by user566540
I'm using PC-lint to analyze my code and theese lines are generating several errors. That makes me wonder if my coding pratice is wrong?
char *start;
char *end;
// Extract the phone number
start = (char*) (strchr(data, '\"') +1);
end = (char*) strchr(start, '\"');
*end = 0;
strlcpy((char*)Fp_smsSender, start , start-(end-1));
EDIT:
After your help i now have:
char *start;
char *end;
if (data != NULL)
{
// Extract the phone number
start = strchr(data, '\"');
if (start != NULL)
{
++start;
end = strchr(start, '\"');
if (end != NULL)
{
*end = 0;
strlcpy((char*)Fp_smsSender, start , FP_MAX_PHONE);
}
}
How does that look?