From 269d7e0c522298334401b68fcec25c061e20b266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Sun, 9 Oct 2022 18:48:10 +0200 Subject: [PATCH 1/6] ignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 7a510743f..e1924aeb6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ # build artifacts mergerfs obj/ +*.d +build/ src/version.hpp # Debian files @@ -23,3 +25,7 @@ debian/changelog # RPM files rpmbuild/ + +# IDEs +\.idea/ +VERSION From a98426cecb16b718f31ecf9d1d0f14bd03c714ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Sun, 9 Oct 2022 18:48:29 +0200 Subject: [PATCH 2/6] sanitize undefined in LDFLAGS --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index cd614eecc..bc4327cb0 100644 --- a/Makefile +++ b/Makefile @@ -93,6 +93,10 @@ LDFLAGS := \ -pthread \ -lrt +ifeq ($(DEBUG),1) +LDFLAGS := ${LDFLAGS} -fsanitize=undefined +endif + DESTDIR = PREFIX = /usr/local EXEC_PREFIX = $(PREFIX) From d82e00a9f1009a226617997481143c63c2451fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Sun, 9 Oct 2022 18:49:02 +0200 Subject: [PATCH 3/6] add some unit tests for branches update --- tests/tests.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/tests.cpp b/tests/tests.cpp index 3c9716762..98e1ca963 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -115,6 +115,57 @@ test_config_branches() TEST_CHECK(b.from_string("./foo/bar:/bar/baz:blah/asdf") == 0); } + +void +test_config_update_branches() +{ + uint64_t minfreespace; + Branches b(minfreespace); + + minfreespace = 1234; + + // + TEST_CHECK(b.from_string("/first:/second") == 0); + + TEST_CHECK(b.from_string("-/first") == 0); + TEST_CHECK(b.to_string() == "/second=RW"); + + TEST_CHECK(b.from_string("+>/last") == 0); + TEST_CHECK(b.to_string() == "/second=RW:/last=RW"); + + TEST_CHECK(b.from_string("+/last") == 0); + TEST_CHECK(b.to_string() == "/second=RW:/last=RW:/last=RW"); + + // + TEST_CHECK(b.from_string("/second") == 0); + + TEST_CHECK(b.from_string("+") == 0); + TEST_CHECK(b.to_string() == "/first=RW"); + + // + TEST_CHECK(b.from_string("/first:/second") == 0); + + TEST_CHECK(b.from_string("-<") == 0); + TEST_CHECK(b.to_string() == "/second=RW"); + + // + TEST_CHECK(b.from_string("=/dir") == 0); + TEST_CHECK(b.to_string() == "/dir=RW"); + TEST_CHECK(b.from_string("/dir") == 0); + TEST_CHECK(b.to_string() == "/dir=RW"); +} + void test_config_cachefiles() { @@ -274,6 +325,7 @@ TEST_LIST = {"config_int",test_config_int}, {"config_str",test_config_str}, {"config_branches",test_config_branches}, + {"config_update_branches",test_config_update_branches}, {"config_cachefiles",test_config_cachefiles}, {"config_inodecalc",test_config_inodecalc}, {"config_moveonenospc",test_config_moveonenospc}, From f5937adbcb65eb1cbda9872db80894b133141eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Sun, 9 Oct 2022 18:49:40 +0200 Subject: [PATCH 4/6] return ENOTSUP when branches empty after update --- src/branches.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/branches.cpp b/src/branches.cpp index 99a0eaf88..c8765d296 100644 --- a/src/branches.cpp +++ b/src/branches.cpp @@ -205,6 +205,9 @@ namespace l Branches::Impl tmp_branches(branches_->minfreespace()); str::split(str_,':',&paths); + if (paths.empty()) + return -ENOTSUP; + for(auto &path : paths) { rv = l::parse(path,&tmp_branches); @@ -269,6 +272,9 @@ namespace l int erase_begin(Branches::Impl *branches_) { + if (branches_->size() <= 1) + return -ENOTSUP; + branches_->erase(branches_->begin()); return 0; @@ -278,6 +284,9 @@ namespace l int erase_end(Branches::Impl *branches_) { + if (branches_->size() <= 1) + return -ENOTSUP; + branches_->pop_back(); return 0; @@ -299,6 +308,8 @@ namespace l { match = ::fnmatch(pi->c_str(),i->path.c_str(),0); } + if (match == 0 && branches_->size() == 1) + return -ENOTSUP; i = ((match == 0) ? branches_->erase(i) : (i+1)); } From ece486d0c80011232c92ef0deabe58e2f1387f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Sun, 9 Oct 2022 18:53:35 +0200 Subject: [PATCH 5/6] error out when no branches left --- src/branches.cpp | 5 +---- tests/tests.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/branches.cpp b/src/branches.cpp index c8765d296..d5a57e3df 100644 --- a/src/branches.cpp +++ b/src/branches.cpp @@ -80,11 +80,8 @@ namespace l uint64_t offset; offset = s_.find_first_not_of("+<>-="); - if(offset > 1) - offset = 2; + *values_ = ((offset != std::string::npos) ? s_.substr(offset) : ""); *instr_ = s_.substr(0,offset); - if(offset != std::string::npos) - *values_ = s_.substr(offset); } static diff --git a/tests/tests.cpp b/tests/tests.cpp index 98e1ca963..1a667f553 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -164,6 +164,16 @@ test_config_update_branches() TEST_CHECK(b.to_string() == "/dir=RW"); TEST_CHECK(b.from_string("/dir") == 0); TEST_CHECK(b.to_string() == "/dir=RW"); + + // error out when no branches left + TEST_CHECK(b.from_string("=/dir") == 0); + TEST_CHECK(b.from_string("-/dir") < 0); + TEST_CHECK(b.from_string("-<") < 0); + TEST_CHECK(b.from_string("->") < 0); + + // error out when setting empty branches + TEST_CHECK(b.from_string("=") < 0); + TEST_CHECK(b.from_string("") < 0); } void From f283cba719e62a58d1b6ccd8c615c301c4921f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Sun, 9 Oct 2022 23:53:04 +0200 Subject: [PATCH 6/6] =?UTF-8?q?py3=20+=20decode=20utf-8=20in=20git2debcl?= =?UTF-8?q?=20for=20=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/git2debcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/git2debcl b/tools/git2debcl index 8d0423ce8..69ed69c8b 100755 --- a/tools/git2debcl +++ b/tools/git2debcl @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2016, Antonio SJ Musumeci @@ -19,7 +19,7 @@ import subprocess import argparse def call(args): - return subprocess.Popen(args,stdout=subprocess.PIPE).communicate()[0].decode() + return subprocess.Popen(args,stdout=subprocess.PIPE).communicate()[0].decode('utf-8') def git_tags(): args = ["git", "tag", '-l']