From f0bda71fe2a4df4201c6195be1fe46cf895c134d Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 28 Aug 2022 13:02:10 +0200 Subject: shared/path_simplify: return an unsigned value --- src/shared/include/camellia/path.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/shared/include') diff --git a/src/shared/include/camellia/path.h b/src/shared/include/camellia/path.h index 8efa0d4..b268595 100644 --- a/src/shared/include/camellia/path.h +++ b/src/shared/include/camellia/path.h @@ -4,7 +4,14 @@ #define PATH_MAX 512 /** Reduce a path to its simplest form. + * Kinds of invalid paths: + * - relative - "" "a" "./a" + * - going behind the root directory - "/../" * - * @return length of the string in *out, always less than len. Negative if the path was invalid. + * @return On success, length of the string in *out, <= len. 0 if the path was invalid. + * + * returns an unsigned type because: + * 1. valid paths always return at least 1, for the initial slash + * 2. it makes it easier to assign the result to an unsigned variable and check for error */ -int path_simplify(const char *in, char *out, size_t len); +size_t path_simplify(const char *in, char *out, size_t len); -- cgit v1.2.3