Is this bad coding practice?
Posted
by
user566540
on Stack Overflow
See other posts from Stack Overflow
or by user566540
Published on 2011-01-07T07:11:46Z
Indexed on
2011/01/07
8:54 UTC
Read the original article
Hit count: 146
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?
© Stack Overflow or respective owner