Blob Blame History Raw
From 08e2bede433a2f513aba0b28686a31cb0b769079 Mon Sep 17 00:00:00 2001
From: Mattias Ellert <mattias.ellert@physics.uu.se>
Date: Sat, 28 Oct 2023 17:55:58 +0200
Subject: [PATCH 2/3] PATH_MAX / MAXPATHLEN might be undefined

XrdSys/XrdSysPlatform.hh defines MAXPATHLEN if needed.

/<<PKGBUILDDIR>>/tests/XrdCl/XrdClURL.cc: In member function 'virtual void URLTest_LocalURLs_Test::TestBody()':
/<<PKGBUILDDIR>>/tests/XrdCl/XrdClURL.cc:17:12: error: 'PATH_MAX' was not declared in this scope
   17 |   char url[PATH_MAX];
      |            ^~~~~~~~
/<<PKGBUILDDIR>>/tests/XrdCl/XrdClURL.cc:21:18: error: 'url' was not declared in this scope
   21 |         snprintf(url, sizeof(url), "%s%s%s", protocol, path, params);
      |                  ^~~
/<<PKGBUILDDIR>>/tests/XrdCl/XrdClURL.cc: In member function 'virtual void URLTest_RemoteURLs_Test::TestBody()':
/<<PKGBUILDDIR>>/tests/XrdCl/XrdClURL.cc:47:12: error: 'PATH_MAX' was not declared in this scope
   47 |   char url[PATH_MAX];
      |            ^~~~~~~~
/<<PKGBUILDDIR>>/tests/XrdCl/XrdClURL.cc:57:26: error: 'url' was not declared in this scope
   57 |                 snprintf(url, sizeof(url), "%s%s%s%s%s%s%s%s%s%s%s%s",
      |                          ^~~
/<<PKGBUILDDIR>>/tests/XrdCl/XrdClURL.cc:63:26: error: 'path_params' was not declared in this scope
   63 |                 snprintf(path_params, sizeof(path_params), "%s%s", *path == '/' ? path+1 : path, params);
      |                          ^~~~~~~~~~~
---
 tests/XrdCl/XrdClURL.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/XrdCl/XrdClURL.cc b/tests/XrdCl/XrdClURL.cc
index 24e7fdc2a..046f41a8c 100644
--- a/tests/XrdCl/XrdClURL.cc
+++ b/tests/XrdCl/XrdClURL.cc
@@ -1,6 +1,8 @@
 #undef NDEBUG
 
 #include <XrdCl/XrdClURL.hh>
+#include "XrdSys/XrdSysPlatform.hh"
+
 #include <gtest/gtest.h>
 
 #include <climits>
@@ -14,7 +16,7 @@ class URLTest : public ::testing::Test {};
 
 TEST(URLTest, LocalURLs)
 {
-  char url[PATH_MAX];
+  char url[MAXPATHLEN];
   for (const auto& protocol : { "", "file://" }) {
     for (const auto& path : { "/dev", "/dev/", "/dev/null" }) {
       for (const auto& params : { "", "?param=value", "?param1=value1&param2=value2" }) {
@@ -44,8 +46,8 @@ TEST(URLTest, LocalURLs)
 
 TEST(URLTest, RemoteURLs)
 {
-  char url[PATH_MAX];
-  char path_params[PATH_MAX];
+  char url[MAXPATHLEN];
+  char path_params[MAXPATHLEN];
   for (const char *protocol : { "", "http", "root", "https", "roots" }) {
     int default_port = *protocol == 'h' ? (strlen(protocol) == 4 ? 80 : 443) : 1094;
     for (const char *user : { "", "alice", "bob", "user_123", "xrootd" }) {
-- 
2.41.0