summaryrefslogtreecommitdiff
path: root/src/shared/include
diff options
context:
space:
mode:
authordzwdz2022-08-28 13:02:10 +0200
committerdzwdz2022-08-28 13:02:10 +0200
commitf0bda71fe2a4df4201c6195be1fe46cf895c134d (patch)
tree098f6d4007d74569d486b515d95986b8c145d492 /src/shared/include
parentc43b0ac7672b0d8fce8b1ea0a0dbe4383d60485e (diff)
shared/path_simplify: return an unsigned value
Diffstat (limited to 'src/shared/include')
-rw-r--r--src/shared/include/camellia/path.h11
1 files changed, 9 insertions, 2 deletions
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);