From 4accb2192172a1f71c7a33f02f08eeff3b556f22 Mon Sep 17 00:00:00 2001 From: Tristan Glatard Date: Sat, 27 Jun 2020 09:43:21 -0400 Subject: [PATCH 1/2] Removed the need for a C++11 compiler --- Makefile | 2 +- functions.cpp | 2 ++ sea.h | 5 +++-- tests/test_custom.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 36e6eeee..b6adac8c 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ logger.o: logger.cpp logger.h passthrough.so: passthrough.o functions.o logger.o config.o sea.o gcc -shared passthrough.o functions.o logger.o config.o sea.o ${debug_opts} -o passthrough.so -ldl -lpthread -lstdc++ -liniparser test_custom.o: tests/test_custom.cpp passthrough.o sea.o config.o logger.o - gcc ${debug_opts} -std=c++11 -Wall -fPIC tests/test_custom.cpp passthrough.o sea.o config.o logger.o -o tests/test_custom -lstdc++ -liniparser -ldl -lgtest -lpthread + gcc ${debug_opts} -std=c++0x -Wall -fPIC tests/test_custom.cpp passthrough.o sea.o config.o logger.o -o tests/test_custom -lstdc++ -liniparser -ldl -lgtest -lpthread test: test_custom.o clean: \rm -f logger.o functions.o passthrough.o config.o sea.o passthrough.so *.gcda *.gcov *.gcno tests/test_custom diff --git a/functions.cpp b/functions.cpp index 51a82bc2..10e72d2b 100644 --- a/functions.cpp +++ b/functions.cpp @@ -245,6 +245,8 @@ extern "C" { return ((funcptr_opendir)libc_opendir)(passpath); SEA_DIR *sd = new SEA_DIR; + strcpy(sd->type, "seadir"); + sd->curr_index = 0; sd->dirnames = (char**) malloc(sizeof(char*) * sea_conf.n_sources * PATH_MAX); sd->other_dirp = (DIR**) malloc(sizeof(DIR*) * sea_conf.n_sources - 1); diff --git a/sea.h b/sea.h index ae025120..bb278dd6 100644 --- a/sea.h +++ b/sea.h @@ -11,6 +11,7 @@ #include #include #include +#include #include extern int sea_internal; @@ -27,9 +28,9 @@ void initialize_sea_if_necessary(); struct SEA_DIR { DIR* dirp; DIR** other_dirp; - char type[7] = "seadir"; // mostly useless. only used in closedir to ensure struct type is right + char type[7]; // mostly useless. only used in closedir to ensure struct type is right char** dirnames; - int curr_index = 0; + int curr_index; }; #endif diff --git a/tests/test_custom.cpp b/tests/test_custom.cpp index 2e073fcc..da42af3f 100644 --- a/tests/test_custom.cpp +++ b/tests/test_custom.cpp @@ -11,7 +11,8 @@ TEST(Passthrough, GetCanonical) { const char paths[6][PATH_MAX] = { "mount", "./mount/subdir", "../mount/", "/dev/shm/tmp", "/", NULL }; - for(auto path: paths){ + for(int i = 0 ; i < 6 ; i++){ + const char * path = paths[i]; char* actualpath; char* expected = (char*) malloc(sizeof(char*) * PATH_MAX); @@ -66,8 +67,8 @@ TEST(Passthrough, CheckIfSeaPath) { realpath("mount", path); - int i = 0; - for (auto op: oldpaths) { + for (int i = 0 ; i < 4 ; i++) { + char * op = oldpaths[i]; // need to reinitialize each time otherwise may retain tail of previous value char passpath[PATH_MAX]; realpath("source", passpath); @@ -84,7 +85,6 @@ TEST(Passthrough, CheckIfSeaPath) { ASSERT_EQ(res, 0); ASSERT_STREQ(passpath, expected); - ++i; } } From 748bded2f83682f3ee704801f85fdea4fdfbef2e Mon Sep 17 00:00:00 2001 From: Tristan Glatard Date: Sat, 27 Jun 2020 09:44:21 -0400 Subject: [PATCH 2/2] Removed unused include --- sea.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sea.h b/sea.h index bb278dd6..2f4b6bf1 100644 --- a/sea.h +++ b/sea.h @@ -11,7 +11,6 @@ #include #include #include -#include #include extern int sea_internal;