diff --git a/common/log.c b/common/log.c index 3b5588e..59869cd 100644 --- a/common/log.c +++ b/common/log.c @@ -38,12 +38,16 @@ static const char *log_level_name[LOGL_COUNT] = { const char *log_get_cat_name(enum log_category_t cat) { - if (cat > LOGC_COUNT) - return "invalid"; + const char *name; + + if (cat < 0 || cat >= LOGC_COUNT) + return ""; if (cat >= LOGC_NONE) return log_cat_name[cat - LOGC_NONE]; - return uclass_get_name((enum uclass_id)cat); + name = uclass_get_name((enum uclass_id)cat); + + return name ? name : ""; } enum log_category_t log_get_cat_by_name(const char *name) diff --git a/include/log.h b/include/log.h index a3edd25..3e99d6e 100644 --- a/include/log.h +++ b/include/log.h @@ -274,7 +274,8 @@ struct log_filter { * log_get_cat_name() - Get the name of a category * * @cat: Category to look up - * @return category name (which may be a uclass driver name) + * @return category name (which may be a uclass driver name) if found, or + * "" if invalid, or "" if not found */ const char *log_get_cat_name(enum log_category_t cat);