From 53f74c55e7e056c8abede285167e62a8522781c2 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sat, 25 Jul 2020 18:27:55 +0300
Subject: [PATCH] Possible SDK fixes

---
 SDK/C/src/streams.cpp                       | 2 +-
 components/common/cpp/src/configuration.cpp | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/SDK/C/src/streams.cpp b/SDK/C/src/streams.cpp
index 55eec9805..e2a48c9bf 100644
--- a/SDK/C/src/streams.cpp
+++ b/SDK/C/src/streams.cpp
@@ -42,7 +42,7 @@ static void createFileWriteStream(FTLStream *s, const ftl::URI &uri) {
 	if (!root) {
 		int argc = 1;
 		const char *argv[] = {"SDK",0};
-		root = ftl::configure(argc, const_cast<char**>(argv), "sdk_default");
+		root = ftl::configure(argc, const_cast<char**>(argv), "sdk_default", {});
 	}
 
 	auto *fs = ftl::create<ftl::stream::File>(root, "ftlfile");
diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp
index 3a0fce37e..522ce44bd 100644
--- a/components/common/cpp/src/configuration.cpp
+++ b/components/common/cpp/src/configuration.cpp
@@ -388,13 +388,15 @@ bool ftl::config::update(const std::string &puri, const json_t &value) {
 	//size_t last_hash = uri.find_last_of('/');
 	//if (last_hash != string::npos) {
 		size_t last = uri.find_last_of('/');
-		//if (last != string::npos && last > last_hash) {
+		if (last != string::npos) {
 			tail = uri.substr(last+1);
 			head = uri.substr(0, last);
-		//} else {
+		} else {
 		//	tail = uri.substr(last_hash+1);
 		//	head = uri.substr(0, last_hash);
-		//}
+			LOG(WARNING) << "Expected a URI path: " << uri;
+			return false;
+		}
 	//} else {
 	//	LOG(WARNING) << "Expected a # in an update URI: " << uri;
 	//	return false;
@@ -605,6 +607,7 @@ map<string, string> ftl::config::read_options(char ***argv, int *argc) {
  */
 static void process_options(Configurable *root, const map<string, string> &opts) {
 	for (auto opt : opts) {
+		if (opt.first == "") continue;
 		if (opt.first == "config") continue;
 		if (opt.first == "root") continue;
 
-- 
GitLab