Change the type_from_string() macro into a function and drop the support for passing len < 0. Support for len < 0 was added in fe8e3b71805 (Refactor type_from_string() to allow continuing after detecting an error, 2014-09-10), but no callers use that form. Let's drop it to simplify this, and in preparation for simplifying these even further. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- object.c | 10 +++++++--- object.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/object.c b/object.c index 7fdca3ed1e..88de01e5ac 100644 --- a/object.c +++ b/object.c @@ -39,9 +39,6 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle) { int i; - if (len < 0) - len = strlen(str); - for (i = 1; i < ARRAY_SIZE(object_type_strings); i++) if (!strncmp(str, object_type_strings[i], len) && object_type_strings[i][len] == '\0') @@ -53,6 +50,13 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle) die(_("invalid object type \"%s\""), str); } +int type_from_string(const char *str) +{ + size_t len = strlen(str); + int ret = type_from_string_gently(str, len, 0); + return ret; +} + /* * Return a numerical hash value between 0 and n-1 for the object with * the specified sha1. n must be a power of 2. Please note that the diff --git a/object.h b/object.h index 59daadce21..3ab3eb193d 100644 --- a/object.h +++ b/object.h @@ -94,7 +94,7 @@ struct object { const char *type_name(unsigned int type); int type_from_string_gently(const char *str, ssize_t, int gentle); -#define type_from_string(str) type_from_string_gently(str, -1, 0) +int type_from_string(const char *str); /* * Return the current number of buckets in the object hashmap. -- 2.31.1.592.gdf54ba9003