Previously, calling these functions with arbitrary values would cause
them to do a struct member lookup on a null pointer. Now they return
the pointer instead.
Also, some users have been confused by the docs, and have passsed, for
example, adns_s_max_misconfig. This is also not permitted. Clarify
that only values actually returned by adns are allowed.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
* the abbreviation of the error - eg, for adns_s_timeout it returns
* "timeout". adns_errtypeabbrev returns the abbreviation of the
* error class: ie, for values up to adns_s_max_XXX it will return the
- * string XXX. You MUST NOT call these functions with status values
- * not returned by the same adns library.
+ * string XXX.
+ *
+ * If you call these functions with status values not actually
+ * returned from other functions in the same adns library, the
+ * returned information may be NULL.
*/
#ifdef __cplusplus
const struct sinfo *si;
si= findsinfo(st);
- return si->string;
+ return si ? si->string : 0;
}
const char *adns_errabbrev(adns_status st) {
const struct sinfo *si;
si= findsinfo(st);
- return si->abbrev;
+ return si ? si->abbrev : 0;
}
sti= bsearch(&st,stinfos, sizeof(stinfos)/sizeof(*stinfos),
sizeof(*stinfos), sti_compar);
- return sti->abbrev;
+ return sti ? sti->abbrev : 0;
}