Change the type_from_string*() functions to return an "enum object_type", but don't refactor their callers to check for "== OBJ_BAD" instead of "< 0". Refactoring the check of the return value to check == OBJ_BAD would now be equivalent to "ret < 0", but the consensus on an earlier version of this patch was to not do that, and to instead use -1 consistently as a return value. It just so happens that OBJ_BAD == -1, but let's not put a hard reliance on that. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- object.c | 8 ++++---- object.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/object.c b/object.c index 5477abc97c..2216cdcda2 100644 --- a/object.c +++ b/object.c @@ -35,9 +35,9 @@ const char *type_name(unsigned int type) return object_type_strings[type]; } -int type_from_string_gently(const char *str, ssize_t len) +enum object_type type_from_string_gently(const char *str, ssize_t len) { - int i; + enum object_type i; for (i = 1; i < ARRAY_SIZE(object_type_strings); i++) if (!strncmp(str, object_type_strings[i], len) && @@ -46,10 +46,10 @@ int type_from_string_gently(const char *str, ssize_t len) return -1; } -int type_from_string(const char *str) +enum object_type type_from_string(const char *str) { size_t len = strlen(str); - int ret = type_from_string_gently(str, len); + enum object_type ret = type_from_string_gently(str, len); if (ret < 0) die(_("invalid object type \"%s\""), str); return ret; diff --git a/object.h b/object.h index ffdc129830..5e7a523e85 100644 --- a/object.h +++ b/object.h @@ -93,8 +93,8 @@ struct object { }; const char *type_name(unsigned int type); -int type_from_string_gently(const char *str, ssize_t len); -int type_from_string(const char *str); +enum object_type type_from_string_gently(const char *str, ssize_t len); +enum object_type type_from_string(const char *str); /* * Return the current number of buckets in the object hashmap. -- 2.31.1.592.gdf54ba9003