summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-06-23 08:18:54 -0400
committerDavid Robillard <d@drobilla.net>2024-06-23 08:18:54 -0400
commita94997aae5ea760380d09baaf2b41912afb4b122 (patch)
treea41ace07c9907344b5440fd992c5349c0df6ab81
parent384b073bdad676bd3e1e39b527321e9a67bfa491 (diff)
downloadzix-a94997aae5ea760380d09baaf2b41912afb4b122.tar.gz
zix-a94997aae5ea760380d09baaf2b41912afb4b122.tar.bz2
zix-a94997aae5ea760380d09baaf2b41912afb4b122.zip
Fix build on POSIX systems without PATH_MAX defined
-rw-r--r--NEWS3
-rw-r--r--src/posix/filesystem_posix.c8
2 files changed, 7 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index b9bc9ca..7e95197 100644
--- a/NEWS
+++ b/NEWS
@@ -2,11 +2,12 @@ zix (0.5.0) unstable; urgency=medium
* Add ZIX_NODISCARD attribute
* Avoid fdatasync() on Darwin
+ * Fix build on POSIX systems without PATH_MAX defined
* Fix library current_version on MacOS
* Fix nullability annotations for zix_canonical_path() and friends
* Fix ring unit test when mlock() is unavailable
- -- David Robillard <d@drobilla.net> Sat, 22 Jun 2024 23:21:21 +0000
+ -- David Robillard <d@drobilla.net> Sun, 23 Jun 2024 12:18:29 +0000
zix (0.4.2) stable; urgency=medium
diff --git a/src/posix/filesystem_posix.c b/src/posix/filesystem_posix.c
index c82cdf7..be13995 100644
--- a/src/posix/filesystem_posix.c
+++ b/src/posix/filesystem_posix.c
@@ -90,7 +90,7 @@ copy_path(ZixAllocator* const allocator,
#if !defined(PATH_MAX) && USE_PATHCONF
static size_t
-max_path_size(void)
+max_path_size(const char* const path)
{
const long path_max = pathconf(path, _PC_PATH_MAX);
return (path_max > 0) ? (size_t)path_max : zix_system_page_size();
@@ -99,8 +99,10 @@ max_path_size(void)
#elif !defined(PATH_MAX)
static size_t
-max_path_size(void)
+max_path_size(const char* const path)
{
+ (void)path;
+
return zix_system_page_size();
}
@@ -440,7 +442,7 @@ zix_current_path(ZixAllocator* const allocator)
#elif USE_PATHCONF
// Others don't so we have to query PATH_MAX at runtime to allocate the result
- const size_t size = max_path_size();
+ const size_t size = max_path_size(".");
char* const buffer = (char*)zix_calloc(allocator, size, 1);
char* const current = getcwd(buffer, size);
if (!current) {