Eliminate a bunch of idiotic assert()'s in rpmtd getters

In the cases where zero is a sane return for non-existent data,
return it instead of barfing up an assert. Many more unnecessary
asserts left there but these are rather obvious...
This commit is contained in:
Panu Matilainen 2017-08-30 14:26:19 +03:00
parent d78813fa94
commit 9c979cffe9
1 changed files with 9 additions and 9 deletions

View File

@ -49,9 +49,12 @@ void rpmtdFreeData(rpmtd td)
rpm_count_t rpmtdCount(rpmtd td) rpm_count_t rpmtdCount(rpmtd td)
{ {
assert(td != NULL); rpm_count_t count = 0;
/* fix up for binary type abusing count as data length */ if (td != NULL) {
return (td->type == RPM_BIN_TYPE) ? 1 : td->count; /* fix up for binary type abusing count as data length */
count = (td->type == RPM_BIN_TYPE) ? 1 : td->count;
}
return count;
} }
rpm_count_t rpmtdSize(rpmtd td) rpm_count_t rpmtdSize(rpmtd td)
@ -61,20 +64,17 @@ rpm_count_t rpmtdSize(rpmtd td)
rpmTagVal rpmtdTag(rpmtd td) rpmTagVal rpmtdTag(rpmtd td)
{ {
assert(td != NULL); return (td != NULL) ? td->tag : 0;
return td->tag;
} }
rpmTagType rpmtdType(rpmtd td) rpmTagType rpmtdType(rpmtd td)
{ {
assert(td != NULL); return (td != NULL) ? td->type : 0;
return td->type;
} }
rpmTagClass rpmtdClass(rpmtd td) rpmTagClass rpmtdClass(rpmtd td)
{ {
assert(td != NULL); return (td != NULL) ? rpmTagTypeGetClass(td->type) : 0;
return rpmTagTypeGetClass(td->type);
} }
rpmtdFlags rpmtdGetFlags(rpmtd td) rpmtdFlags rpmtdGetFlags(rpmtd td)