Changeset View
Changeset View
Standalone View
Standalone View
cddl/contrib/opensolaris/common/ctf/ctf_lookup.c
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | ctf_lookup_by_name(ctf_file_t *fp, const char *name) | ||||
const ctf_helem_t *hp; | const ctf_helem_t *hp; | ||||
const char *p, *q, *end; | const char *p, *q, *end; | ||||
ctf_id_t type = 0; | ctf_id_t type = 0; | ||||
ctf_id_t ntype, ptype; | ctf_id_t ntype, ptype; | ||||
if (name == NULL) | if (name == NULL) | ||||
return (ctf_set_errno(fp, EINVAL)); | return (ctf_set_errno(fp, EINVAL)); | ||||
for (p = name, end = name + strlen(name); *p != '\0'; p = q) { | for (p = name, end = name + strlen(name); *p != '\0'; p = q) { | ||||
markj: Sorry, I had been focusing on the other change. Could you explain why this part is needed? I'm… | |||||
Done Inline Actions
domagoj.stolfa_gmail.com: > Sorry, I had been focusing on the other change. Could you explain why this part is needed? | |||||
Done Inline ActionsYou're right. I've updated the diff to reflect it. I think it was left over from debugging when I thought my code had caused a memory corruption :-). domagoj.stolfa_gmail.com: You're right. I've updated the diff to reflect it. I think it was left over from debugging when… | |||||
while (isspace(*p)) | while (isspace(*p)) | ||||
p++; /* skip leading ws */ | p++; /* skip leading ws */ | ||||
if (p == end) | if (p == end) | ||||
break; | break; | ||||
if ((q = strpbrk(p + 1, delimiters)) == NULL) | if ((q = strpbrk(p + 1, delimiters)) == NULL) | ||||
q = end; /* compare until end */ | q = end; /* compare until end */ | ||||
Show All 24 Lines | if (*p == '*') { | ||||
q = p + 1; | q = p + 1; | ||||
continue; | continue; | ||||
} | } | ||||
if (isqualifier(p, (size_t)(q - p))) | if (isqualifier(p, (size_t)(q - p))) | ||||
continue; /* skip qualifier keyword */ | continue; /* skip qualifier keyword */ | ||||
for (lp = fp->ctf_lookups; lp->ctl_prefix != NULL; lp++) { | for (lp = fp->ctf_lookups; lp->ctl_prefix != NULL; lp++) { | ||||
if (lp->ctl_prefix[0] == '\0' || | if ((size_t)(q - p) >= lp->ctl_len && | ||||
strncmp(p, lp->ctl_prefix, (size_t)(q - p)) == 0) { | (lp->ctl_prefix[0] == '\0' || | ||||
strncmp(p, lp->ctl_prefix, (size_t)(q - p)) == 0)) { | |||||
for (p += lp->ctl_len; isspace(*p); p++) | for (p += lp->ctl_len; isspace(*p); p++) | ||||
continue; /* skip prefix and next ws */ | continue; /* skip prefix and next ws */ | ||||
if ((q = strchr(p, '*')) == NULL) | if ((q = strchr(p, '*')) == NULL) | ||||
q = end; /* compare until end */ | q = end; /* compare until end */ | ||||
while (isspace(q[-1])) | while (isspace(q[-1])) | ||||
q--; /* exclude trailing ws */ | q--; /* exclude trailing ws */ | ||||
▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines |
Sorry, I had been focusing on the other change. Could you explain why this part is needed? I'm having trouble seeing how q or p can end up being NULL.