Merge lp:~marcustomlinson/unity-scopes-api/fix-clang-warnings into lp:unity-scopes-api/devel

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Michi Henning
Approved revision: 648
Merged at revision: 645
Proposed branch: lp:~marcustomlinson/unity-scopes-api/fix-clang-warnings
Merge into: lp:unity-scopes-api/devel
Diff against target: 604 lines (+53/-84)
22 files modified
include/unity/scopes/internal/ScopeImpl.h (+1/-1)
include/unity/scopes/internal/SettingsDB.h (+4/-14)
src/scopes/internal/CannedQueryImpl.cpp (+1/-1)
src/scopes/internal/Executor.cpp (+0/-2)
src/scopes/internal/IniSettingsSchema.cpp (+2/-4)
src/scopes/internal/OnlineAccountClientImpl.cpp (+1/-1)
src/scopes/internal/PreviewReplyImpl.cpp (+1/-1)
src/scopes/internal/PreviewReplyObject.cpp (+1/-1)
src/scopes/internal/ReplyImpl.cpp (+1/-1)
src/scopes/internal/RuntimeConfig.cpp (+5/-5)
src/scopes/internal/RuntimeImpl.cpp (+3/-4)
src/scopes/internal/SearchMetadataImpl.cpp (+2/-2)
src/scopes/internal/SearchReplyImpl.cpp (+2/-2)
src/scopes/internal/SettingsDB.cpp (+13/-22)
src/scopes/internal/Utils.cpp (+1/-1)
src/scopes/internal/smartscopes/SSRegistryObject.cpp (+1/-3)
src/scopes/internal/smartscopes/SmartScope.cpp (+1/-1)
src/scopes/internal/smartscopes/SmartScopesClient.cpp (+2/-2)
src/scopes/internal/zmq_middleware/ZmqObject.cpp (+0/-2)
test/gtest/scopes/StandAloneScope/SimpleScope.cpp (+0/-1)
test/gtest/scopes/ThrowingClient/ThrowingClient_test.cpp (+1/-1)
test/gtest/scopes/internal/SettingsDB/SettingsDB_test.cpp (+10/-12)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/fix-clang-warnings
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michi Henning (community) Approve
Review via email: mp+278555@code.launchpad.net

Commit message

Fixed Clang compiler warnings such as: missing "override" specifier, unused variables and functions, and other small bits of suspicious logic.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

+1, thanks for that!

It's amazing how line 150 of the diff slipped through. My left arm for a language with a sane type system… :-(

Line 191 of the diff needs to read:

make_directories(dir, 0700);

We want to create the directories for the entire path, not just the top-level dir.

Unfortunately, it appears that all of this is a lost labour of love now, at least on Wily. I just tried compiling with clang 3.6.2 on Wily. It came up with a bunch more warnings, which I started to fix. Unfortunately, our code no longer links due to unresolved references to symbols in libjson and libunity-api. It looks like the inlining algorithms for gcc and clang have gone out of sync. gcc inlines things that clang doesn't and then the clang-compiled client code looks for a external symbols in these libraries that don't exist :-(

Still, building with clang is still useful on Vivid (while it lasts).

I'me also attaching a diff that fixes a bunch more warnings from clang 3.6.0 on Vivid+overlay. Could you apply that diff too please?

It's awfully easy to miss warnings with ccache enabled because a warning is emitted only once when a file is first compiled. If the file has no errors, all future builds are warning-free because the object file is taken from the cache…

review: Needs Fixing
Revision history for this message
Michi Henning (michihenning) wrote :

Hmmm... Looks like it's impossible to add an attachment to an MR. I've uploaded the diff here:

https://www.dropbox.com/s/s1ia48983mlnqon/diff-for-clang?dl=0

Revision history for this message
Michi Henning (michihenning) wrote :

Actually, it's not inlining, it's the abi tags in gcc. See here: https://llvm.org/bugs/show_bug.cgi?id=23529

The name mangling differs between clang and gcc, so the symbols are in the library, but with a different mangled name :(

647. By Marcus Tomlinson

Applied patch with further warning fixes

648. By Marcus Tomlinson

make_directories(cache_dir_ -> make_directories(dir

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

> +1, thanks for that!
>
> It's amazing how line 150 of the diff slipped through. My left arm for a
> language with a sane type system… :-(
>
> Line 191 of the diff needs to read:
>
> make_directories(dir, 0700);

done (line 251)

>
> We want to create the directories for the entire path, not just the top-level
> dir.
>
> Unfortunately, it appears that all of this is a lost labour of love now, at
> least on Wily. I just tried compiling with clang 3.6.2 on Wily. It came up
> with a bunch more warnings, which I started to fix. Unfortunately, our code no
> longer links due to unresolved references to symbols in libjson and libunity-
> api. It looks like the inlining algorithms for gcc and clang have gone out of
> sync. gcc inlines things that clang doesn't and then the clang-compiled client
> code looks for a external symbols in these libraries that don't exist :-(
>
> Still, building with clang is still useful on Vivid (while it lasts).
>
> I'me also attaching a diff that fixes a bunch more warnings from clang 3.6.0
> on Vivid+overlay. Could you apply that diff too please?

done.

>
> It's awfully easy to miss warnings with ccache enabled because a warning is
> emitted only once when a file is first compiled. If the file has no errors,
> all future builds are warning-free because the object file is taken from the
> cache…

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Looks good!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/unity/scopes/internal/ScopeImpl.h'
--- include/unity/scopes/internal/ScopeImpl.h 2015-05-29 10:17:42 +0000
+++ include/unity/scopes/internal/ScopeImpl.h 2015-11-26 05:49:23 +0000
@@ -103,7 +103,7 @@
103 virtual QueryCtrlProxy activate_result_action(Result const& result,103 virtual QueryCtrlProxy activate_result_action(Result const& result,
104 ActionMetadata const& metadata,104 ActionMetadata const& metadata,
105 std::string const& action_id,105 std::string const& action_id,
106 ActivationListenerBase::SPtr const& reply);106 ActivationListenerBase::SPtr const& reply) override;
107107
108 virtual ChildScopeList child_scopes() override;108 virtual ChildScopeList child_scopes() override;
109 virtual bool set_child_scopes(ChildScopeList const& child_scopes) override;109 virtual bool set_child_scopes(ChildScopeList const& child_scopes) override;
110110
=== modified file 'include/unity/scopes/internal/SettingsDB.h'
--- include/unity/scopes/internal/SettingsDB.h 2015-07-13 14:28:15 +0000
+++ include/unity/scopes/internal/SettingsDB.h 2015-11-26 05:49:23 +0000
@@ -18,7 +18,6 @@
1818
19#pragma once19#pragma once
2020
21#include <unity/scopes/internal/Logger.h>
22#include <unity/scopes/internal/SettingsSchema.h>21#include <unity/scopes/internal/SettingsSchema.h>
23#include <unity/scopes/Variant.h>22#include <unity/scopes/Variant.h>
24#include <unity/util/DefinesPtrs.h>23#include <unity/util/DefinesPtrs.h>
@@ -47,15 +46,9 @@
47 NONCOPYABLE(SettingsDB);46 NONCOPYABLE(SettingsDB);
48 UNITY_DEFINES_PTRS(SettingsDB);47 UNITY_DEFINES_PTRS(SettingsDB);
4948
50 static UPtr create_from_ini_file(std::string const& db_path,49 static UPtr create_from_ini_file(std::string const& db_path, std::string const& ini_file_path);
51 std::string const& ini_file_path,50 static UPtr create_from_json_string(std::string const& db_path, std::string const& json_string);
52 boost::log::sources::severity_channel_logger_mt<>& logger);51 static UPtr create_from_schema(std::string const& db_path, unity::scopes::internal::SettingsSchema const& schema);
53 static UPtr create_from_json_string(std::string const& db_path,
54 std::string const& json_string,
55 boost::log::sources::severity_channel_logger_mt<>& logger);
56 static UPtr create_from_schema(std::string const& db_path,
57 unity::scopes::internal::SettingsSchema const& schema,
58 boost::log::sources::severity_channel_logger_mt<>& logger);
5952
60 ~SettingsDB() = default;53 ~SettingsDB() = default;
6154
@@ -65,9 +58,7 @@
65 VariantMap settings(); // Returns the current settings (checking the DB each time).58 VariantMap settings(); // Returns the current settings (checking the DB each time).
6659
67private:60private:
68 SettingsDB(std::string const& db_path,61 SettingsDB(std::string const& db_path, unity::scopes::internal::SettingsSchema const& schema);
69 unity::scopes::internal::SettingsSchema const& schema,
70 boost::log::sources::severity_channel_logger_mt<>& logger);
7162
72 void process_doc_(std::string const& id, unity::util::IniParser const& parer);63 void process_doc_(std::string const& id, unity::util::IniParser const& parer);
73 void process_all_docs();64 void process_all_docs();
@@ -80,7 +71,6 @@
80 VariantArray definitions_; // Returned by SettingsSchema71 VariantArray definitions_; // Returned by SettingsSchema
81 std::map<std::string, Variant> def_map_; // Allows fast access to the Variants in definitions_72 std::map<std::string, Variant> def_map_; // Allows fast access to the Variants in definitions_
82 unity::scopes::VariantMap values_;73 unity::scopes::VariantMap values_;
83 boost::log::sources::severity_channel_logger_mt<>& logger_;
84};74};
8575
86} // namespace internal76} // namespace internal
8777
=== modified file 'src/scopes/internal/CannedQueryImpl.cpp'
--- src/scopes/internal/CannedQueryImpl.cpp 2015-02-26 12:47:37 +0000
+++ src/scopes/internal/CannedQueryImpl.cpp 2015-11-26 05:49:23 +0000
@@ -232,7 +232,7 @@
232 {232 {
233 return from_percent_encoding(value);233 return from_percent_encoding(value);
234 }234 }
235 catch (InvalidArgumentException const& e)235 catch (InvalidArgumentException const&)
236 {236 {
237 std::stringstream err;237 std::stringstream err;
238 err << "Failed to decode key '" << key_name << "' of uri '" << uri << "'";238 err << "Failed to decode key '" << key_name << "' of uri '" << uri << "'";
239239
=== modified file 'src/scopes/internal/Executor.cpp'
--- src/scopes/internal/Executor.cpp 2014-08-08 08:35:09 +0000
+++ src/scopes/internal/Executor.cpp 2015-11-26 05:49:23 +0000
@@ -49,10 +49,8 @@
49 case ENOENT:49 case ENOENT:
50 case EACCES:50 case EACCES:
51 throw std::runtime_error("AppArmor profile does not exist");51 throw std::runtime_error("AppArmor profile does not exist");
52 break;
53 case EINVAL:52 case EINVAL:
54 throw std::runtime_error("AppArmor interface not available");53 throw std::runtime_error("AppArmor interface not available");
55 break;
56 default:54 default:
57 throw std::runtime_error("Unknown AppArmor error");55 throw std::runtime_error("Unknown AppArmor error");
58 }56 }
5957
=== modified file 'src/scopes/internal/IniSettingsSchema.cpp'
--- src/scopes/internal/IniSettingsSchema.cpp 2015-03-02 03:59:01 +0000
+++ src/scopes/internal/IniSettingsSchema.cpp 2015-11-26 05:49:23 +0000
@@ -56,8 +56,6 @@
56 Variant const& default_value);56 Variant const& default_value);
57 ~Setting() = default;57 ~Setting() = default;
5858
59 string id() const;
60
61 enum Type { BooleanT, ListT, NumberT, StringT };59 enum Type { BooleanT, ListT, NumberT, StringT };
6260
63 Variant to_schema_definition();61 Variant to_schema_definition();
@@ -240,7 +238,7 @@
240 }238 }
241 }239 }
242 }240 }
243 catch (LogicException const& e)241 catch (LogicException const&)
244 {242 {
245 throw ResourceException(string("IniSettingsSchema(): invalid value type for \"") + dflt_val_key + "\" definition, "243 throw ResourceException(string("IniSettingsSchema(): invalid value type for \"") + dflt_val_key + "\" definition, "
246 "setting = \"" + id_ + "\"");244 "setting = \"" + id_ + "\"");
@@ -276,7 +274,7 @@
276 definitions_.push_back(s.to_schema_definition());274 definitions_.push_back(s.to_schema_definition());
277 }275 }
278 }276 }
279 catch (std::exception const& e)277 catch (std::exception const&)
280 {278 {
281 throw ResourceException("IniSettingsSchema(): cannot parse settings file \"" + ini_file + "\"");279 throw ResourceException("IniSettingsSchema(): cannot parse settings file \"" + ini_file + "\"");
282 }280 }
283281
=== modified file 'src/scopes/internal/OnlineAccountClientImpl.cpp'
--- src/scopes/internal/OnlineAccountClientImpl.cpp 2015-01-26 06:02:10 +0000
+++ src/scopes/internal/OnlineAccountClientImpl.cpp 2015-11-26 05:49:23 +0000
@@ -653,7 +653,7 @@
653 g_main_loop_run(main_loop_.get());653 g_main_loop_run(main_loop_.get());
654 }654 }
655 // LCOV_EXCL_START655 // LCOV_EXCL_START
656 catch (std::exception const& e)656 catch (std::exception const&)
657 {657 {
658 std::lock_guard<std::mutex> lock(mutex_);658 std::lock_guard<std::mutex> lock(mutex_);
659 thread_exception_ = std::current_exception();659 thread_exception_ = std::current_exception();
660660
=== modified file 'src/scopes/internal/PreviewReplyImpl.cpp'
--- src/scopes/internal/PreviewReplyImpl.cpp 2015-01-09 03:16:51 +0000
+++ src/scopes/internal/PreviewReplyImpl.cpp 2015-11-26 05:49:23 +0000
@@ -52,7 +52,7 @@
52 {52 {
53 ColumnLayoutImpl::validate_layouts(layouts);53 ColumnLayoutImpl::validate_layouts(layouts);
54 }54 }
55 catch (unity::LogicException const &e)55 catch (unity::LogicException const&)
56 {56 {
57 throw unity::LogicException("PreviewReplyImpl::register_layout(): Failed to validate layouts");57 throw unity::LogicException("PreviewReplyImpl::register_layout(): Failed to validate layouts");
58 }58 }
5959
=== modified file 'src/scopes/internal/PreviewReplyObject.cpp'
--- src/scopes/internal/PreviewReplyObject.cpp 2014-11-18 07:04:04 +0000
+++ src/scopes/internal/PreviewReplyObject.cpp 2015-11-26 05:49:23 +0000
@@ -67,7 +67,7 @@
67 {67 {
68 ColumnLayoutImpl::validate_layouts(list);68 ColumnLayoutImpl::validate_layouts(list);
69 }69 }
70 catch (unity::LogicException const &e)70 catch (unity::LogicException const&)
71 {71 {
72 throw unity::LogicException("PreviewReplyObject::process_data(): Failed to validate layouts");72 throw unity::LogicException("PreviewReplyObject::process_data(): Failed to validate layouts");
73 }73 }
7474
=== modified file 'src/scopes/internal/ReplyImpl.cpp'
--- src/scopes/internal/ReplyImpl.cpp 2015-02-04 06:07:15 +0000
+++ src/scopes/internal/ReplyImpl.cpp 2015-11-26 05:49:23 +0000
@@ -127,7 +127,7 @@
127 {127 {
128 fwd()->finished(CompletionDetails(CompletionDetails::Error, error_message)); // Oneway, can't block128 fwd()->finished(CompletionDetails(CompletionDetails::Error, error_message)); // Oneway, can't block
129 }129 }
130 catch (std::exception const& e)130 catch (std::exception const&)
131 {131 {
132 BOOST_LOG(mw_proxy_->mw_base()->runtime()->logger())132 BOOST_LOG(mw_proxy_->mw_base()->runtime()->logger())
133 << "ReplyImpl::error(): exception from finished(): " << error_message;133 << "ReplyImpl::error(): exception from finished(): " << error_message;
134134
=== modified file 'src/scopes/internal/RuntimeConfig.cpp'
--- src/scopes/internal/RuntimeConfig.cpp 2015-06-11 07:17:56 +0000
+++ src/scopes/internal/RuntimeConfig.cpp 2015-11-26 05:49:23 +0000
@@ -108,7 +108,7 @@
108 {108 {
109 cache_directory_ = default_cache_directory();109 cache_directory_ = default_cache_directory();
110 }110 }
111 catch (ResourceException const& e)111 catch (ResourceException const&)
112 {112 {
113 throw_ex("No " + cache_dir_key + " configured and failed to get default");113 throw_ex("No " + cache_dir_key + " configured and failed to get default");
114 }114 }
@@ -121,7 +121,7 @@
121 {121 {
122 app_directory_ = default_app_directory();122 app_directory_ = default_app_directory();
123 }123 }
124 catch (ResourceException const& e)124 catch (ResourceException const&)
125 {125 {
126 throw_ex("No " + app_dir_key + " configured and failed to get default");126 throw_ex("No " + app_dir_key + " configured and failed to get default");
127 }127 }
@@ -129,7 +129,7 @@
129129
130 // UNITY_SCOPES_CONFIG_DIR env var can be used to override the value of ConfigDir key of Runtime.ini130 // UNITY_SCOPES_CONFIG_DIR env var can be used to override the value of ConfigDir key of Runtime.ini
131 char const* scopes_cfg_dir_override = getenv("UNITY_SCOPES_CONFIG_DIR");131 char const* scopes_cfg_dir_override = getenv("UNITY_SCOPES_CONFIG_DIR");
132 config_directory_ = (scopes_cfg_dir_override != nullptr && scopes_cfg_dir_override != '\0') ?132 config_directory_ = (scopes_cfg_dir_override != nullptr && *scopes_cfg_dir_override != '\0') ?
133 string(scopes_cfg_dir_override) : get_optional_string(runtime_config_group, config_dir_key);133 string(scopes_cfg_dir_override) : get_optional_string(runtime_config_group, config_dir_key);
134 if (config_directory_.empty())134 if (config_directory_.empty())
135 {135 {
@@ -137,7 +137,7 @@
137 {137 {
138 config_directory_ = default_config_directory();138 config_directory_ = default_config_directory();
139 }139 }
140 catch (ResourceException const& e)140 catch (ResourceException const&)
141 {141 {
142 throw_ex("No " + config_dir_key + " configured and failed to get default");142 throw_ex("No " + config_dir_key + " configured and failed to get default");
143 }143 }
@@ -155,7 +155,7 @@
155 {155 {
156 log_directory_ = default_log_directory();156 log_directory_ = default_log_directory();
157 }157 }
158 catch (ResourceException const& e)158 catch (ResourceException const&)
159 {159 {
160 throw_ex("No " + log_dir_key + " configured and failed to get default");160 throw_ex("No " + log_dir_key + " configured and failed to get default");
161 }161 }
162162
=== modified file 'src/scopes/internal/RuntimeImpl.cpp'
--- src/scopes/internal/RuntimeImpl.cpp 2015-11-23 07:29:31 +0000
+++ src/scopes/internal/RuntimeImpl.cpp 2015-11-26 05:49:23 +0000
@@ -136,7 +136,7 @@
136 app_dir_ = config.app_directory();136 app_dir_ = config.app_directory();
137 config_dir_ = config.config_directory();137 config_dir_ = config.config_directory();
138 }138 }
139 catch (unity::Exception const& e)139 catch (unity::Exception const&)
140 {140 {
141 destroy();141 destroy();
142 string msg = "Cannot instantiate run time for " + (scope_id.empty() ? "client" : scope_id) +142 string msg = "Cannot instantiate run time for " + (scope_id.empty() ? "client" : scope_id) +
@@ -382,7 +382,7 @@
382 boost::system::error_code ec;382 boost::system::error_code ec;
383 if (boost::filesystem::exists(settings_schema, ec))383 if (boost::filesystem::exists(settings_schema, ec))
384 {384 {
385 shared_ptr<SettingsDB> db(SettingsDB::create_from_ini_file(settings_db, settings_schema, logger()));385 shared_ptr<SettingsDB> db(SettingsDB::create_from_ini_file(settings_db, settings_schema));
386 scope_base->p->set_settings_db(db);386 scope_base->p->set_settings_db(db);
387 }387 }
388 else388 else
@@ -594,8 +594,7 @@
594 string dir = cache_dir_ + "/" + confinement_type();594 string dir = cache_dir_ + "/" + confinement_type();
595 if (!confined()) // Avoid apparmor noise595 if (!confined()) // Avoid apparmor noise
596 {596 {
597 string dir = cache_dir_ + "/" + confinement_type();597 make_directories(dir, 0700);
598 make_directories(cache_dir_, 0700);
599 }598 }
600 // A confined scope is allowed to create this dir.599 // A confined scope is allowed to create this dir.
601 dir += "/" + demangled_id(scope_id_);600 dir += "/" + demangled_id(scope_id_);
602601
=== modified file 'src/scopes/internal/SearchMetadataImpl.cpp'
--- src/scopes/internal/SearchMetadataImpl.cpp 2015-04-09 15:59:17 +0000
+++ src/scopes/internal/SearchMetadataImpl.cpp 2015-11-26 05:49:23 +0000
@@ -56,7 +56,7 @@
56 it = find_or_throw("SearchMetadataImpl()", var, "location");56 it = find_or_throw("SearchMetadataImpl()", var, "location");
57 location_ = Location(it->second.get_dict());57 location_ = Location(it->second.get_dict());
58 }58 }
59 catch (std::exception &e)59 catch (std::exception const&)
60 {60 {
61 }61 }
6262
@@ -71,7 +71,7 @@
71 }71 }
72 aggregated_keywords_ = keywords_s;72 aggregated_keywords_ = keywords_s;
73 }73 }
74 catch (std::exception &e)74 catch (std::exception const&)
75 {75 {
76 }76 }
77}77}
7878
=== modified file 'src/scopes/internal/SearchReplyImpl.cpp'
--- src/scopes/internal/SearchReplyImpl.cpp 2015-07-27 10:45:03 +0000
+++ src/scopes/internal/SearchReplyImpl.cpp 2015-11-26 05:49:23 +0000
@@ -72,7 +72,7 @@
72 {72 {
73 DepartmentImpl::validate_departments(parent, current_department_);73 DepartmentImpl::validate_departments(parent, current_department_);
74 }74 }
75 catch (unity::LogicException const &e)75 catch (unity::LogicException const&)
76 {76 {
77 throw unity::LogicException("SearchReplyImpl::register_departments(): Failed to validate departments");77 throw unity::LogicException("SearchReplyImpl::register_departments(): Failed to validate departments");
78 }78 }
@@ -172,7 +172,7 @@
172 {172 {
173 internal::FilterBaseImpl::validate_filters(filters);173 internal::FilterBaseImpl::validate_filters(filters);
174 }174 }
175 catch (unity::LogicException const &e)175 catch (unity::LogicException const&)
176 {176 {
177 throw unity::LogicException("SearchReplyImpl::push(): Failed to validate filters");177 throw unity::LogicException("SearchReplyImpl::push(): Failed to validate filters");
178 }178 }
179179
=== modified file 'src/scopes/internal/SettingsDB.cpp'
--- src/scopes/internal/SettingsDB.cpp 2015-07-13 14:28:15 +0000
+++ src/scopes/internal/SettingsDB.cpp 2015-11-26 05:49:23 +0000
@@ -82,53 +82,44 @@
8282
83} // namespace83} // namespace
8484
85SettingsDB::UPtr SettingsDB::create_from_ini_file(string const& db_path,85SettingsDB::UPtr SettingsDB::create_from_ini_file(string const& db_path, string const& ini_file_path)
86 string const& ini_file_path,
87 boost::log::sources::severity_channel_logger_mt<>& logger)
88{86{
89 // Parse schema87 // Parse schema
90 try88 try
91 {89 {
92 SettingsSchema::UPtr schema = IniSettingsSchema::create(ini_file_path);90 SettingsSchema::UPtr schema = IniSettingsSchema::create(ini_file_path);
93 return create_from_schema(db_path, *schema, logger);91 return create_from_schema(db_path, *schema);
94 }92 }
95 catch (exception const& e)93 catch (exception const&)
96 {94 {
97 throw ResourceException("SettingsDB::create_from_ini_file(): schema = " + ini_file_path + ", db = " + db_path);95 throw ResourceException("SettingsDB::create_from_ini_file(): schema = " + ini_file_path + ", db = " + db_path);
98 }96 }
99}97}
10098
101SettingsDB::UPtr SettingsDB::create_from_json_string(string const& db_path,99SettingsDB::UPtr SettingsDB::create_from_json_string(string const& db_path, string const& json_string)
102 string const& json_string,
103 boost::log::sources::severity_channel_logger_mt<>& logger)
104{100{
105 // Parse schema101 // Parse schema
106 try102 try
107 {103 {
108 auto schema = JsonSettingsSchema::create(json_string);104 auto schema = JsonSettingsSchema::create(json_string);
109 return create_from_schema(db_path, *schema, logger);105 return create_from_schema(db_path, *schema);
110 }106 }
111 catch (exception const& e)107 catch (exception const&)
112 {108 {
113 throw ResourceException("SettingsDB::create_from_json_string(): cannot parse schema, db = " + db_path);109 throw ResourceException("SettingsDB::create_from_json_string(): cannot parse schema, db = " + db_path);
114 }110 }
115}111}
116112
117SettingsDB::UPtr SettingsDB::create_from_schema(string const& db_path,113SettingsDB::UPtr SettingsDB::create_from_schema(string const& db_path, SettingsSchema const& schema)
118 SettingsSchema const& schema,
119 boost::log::sources::severity_channel_logger_mt<>& logger)
120{114{
121 return UPtr(new SettingsDB(db_path, move(schema), logger));115 return UPtr(new SettingsDB(db_path, move(schema)));
122}116}
123117
124SettingsDB::SettingsDB(string const& db_path,118SettingsDB::SettingsDB(string const& db_path, SettingsSchema const& schema)
125 SettingsSchema const& schema,
126 boost::log::sources::severity_channel_logger_mt<>& logger)
127 : db_path_(db_path)119 : db_path_(db_path)
128 , last_write_time_nsec_(-1)120 , last_write_time_nsec_(-1)
129 , last_write_time_sec_(-1)121 , last_write_time_sec_(-1)
130 , last_write_inode_(0)122 , last_write_inode_(0)
131 , logger_(logger)
132{123{
133 // Initialize the def_map_ so we can look things124 // Initialize the def_map_ so we can look things
134 // up quickly.125 // up quickly.
@@ -173,7 +164,7 @@
173 {164 {
174 values_[id] = Variant(stod(value));165 values_[id] = Variant(stod(value));
175 }166 }
176 catch (invalid_argument & e)167 catch (invalid_argument const&)
177 {168 {
178 }169 }
179 }170 }
@@ -182,7 +173,7 @@
182 values_[id] = Variant(p.get_string(GROUP_NAME, id));173 values_[id] = Variant(p.get_string(GROUP_NAME, id));
183 }174 }
184 }175 }
185 catch (LogicException & e)176 catch (LogicException const&)
186 {177 {
187 }178 }
188}179}
@@ -222,7 +213,7 @@
222 {213 {
223 if (e.error() == EACCES) // very unlikely; only if permissions changed after we acquired the lock214 if (e.error() == EACCES) // very unlikely; only if permissions changed after we acquired the lock
224 {215 {
225 throw e;216 throw;
226 }217 }
227 throw ResourceException(e.what());218 throw ResourceException(e.what());
228 }219 }
@@ -244,7 +235,7 @@
244 {235 {
245 if (e.error() == EACCES)236 if (e.error() == EACCES)
246 {237 {
247 throw e;238 throw;
248 }239 }
249240
250 // Failure in obtaining the lock shouldn't be reported to the scope, it's not fatal;241 // Failure in obtaining the lock shouldn't be reported to the scope, it's not fatal;
251242
=== modified file 'src/scopes/internal/Utils.cpp'
--- src/scopes/internal/Utils.cpp 2015-09-15 07:36:09 +0000
+++ src/scopes/internal/Utils.cpp 2015-11-26 05:49:23 +0000
@@ -90,7 +90,7 @@
90 result << static_cast<char>(k);90 result << static_cast<char>(k);
91 valid = true;91 valid = true;
92 }92 }
93 catch (logic_error const& e) // covers both invalid_argument and out_of_range93 catch (logic_error const&) // covers both invalid_argument and out_of_range
94 {94 {
95 stringstream err;95 stringstream err;
96 err << "from_percent_encoding(): unsupported conversion of '" << hexnum << "'";96 err << "from_percent_encoding(): unsupported conversion of '" << hexnum << "'";
9797
=== modified file 'src/scopes/internal/smartscopes/SSRegistryObject.cpp'
--- src/scopes/internal/smartscopes/SSRegistryObject.cpp 2015-01-20 08:25:39 +0000
+++ src/scopes/internal/smartscopes/SSRegistryObject.cpp 2015-11-26 05:49:23 +0000
@@ -324,9 +324,7 @@
324 // Store both JSON (for internal comparison) and DB (for external use)324 // Store both JSON (for internal comparison) and DB (for external use)
325 changed = true;325 changed = true;
326 std::string settings_db = RuntimeConfig::default_config_directory() + "/" + scope.id + "/settings.ini";326 std::string settings_db = RuntimeConfig::default_config_directory() + "/" + scope.id + "/settings.ini";
327 SettingsDB::SPtr db(SettingsDB::create_from_schema(settings_db,327 SettingsDB::SPtr db(SettingsDB::create_from_schema(settings_db, *schema));
328 *schema,
329 middleware_->runtime()->logger()));
330 settings_defs_[scope.id] = SSSettingsDef{settings, db, needs_location_data};328 settings_defs_[scope.id] = SSSettingsDef{settings, db, needs_location_data};
331 }329 }
332 }330 }
333331
=== modified file 'src/scopes/internal/smartscopes/SmartScope.cpp'
--- src/scopes/internal/smartscopes/SmartScope.cpp 2015-06-01 10:23:00 +0000
+++ src/scopes/internal/smartscopes/SmartScope.cpp 2015-11-26 05:49:23 +0000
@@ -117,7 +117,7 @@
117 {117 {
118 reply->register_category(category->id, category->title, category->icon, rdr);118 reply->register_category(category->id, category->title, category->icon, rdr);
119 }119 }
120 catch (std::exception const& e)120 catch (std::exception const&)
121 {121 {
122 BOOST_LOG(this->ss_client_->logger())122 BOOST_LOG(this->ss_client_->logger())
123 << "SmartScope: failed to register category: \"" << category->id123 << "SmartScope: failed to register category: \"" << category->id
124124
=== modified file 'src/scopes/internal/smartscopes/SmartScopesClient.cpp'
--- src/scopes/internal/smartscopes/SmartScopesClient.cpp 2015-11-02 05:24:35 +0000
+++ src/scopes/internal/smartscopes/SmartScopesClient.cpp 2015-11-26 05:49:23 +0000
@@ -339,7 +339,7 @@
339 {339 {
340 scope.keywords.emplace(keyword.get_string());340 scope.keywords.emplace(keyword.get_string());
341 }341 }
342 catch (unity::LogicException const& e)342 catch (unity::LogicException const&)
343 {343 {
344 BOOST_LOG(logger_)344 BOOST_LOG(logger_)
345 << "SmartScopesClient.get_remote_scopes(): Scope: \"" << scope.id345 << "SmartScopesClient.get_remote_scopes(): Scope: \"" << scope.id
@@ -854,7 +854,7 @@
854 query_result->wait();854 query_result->wait();
855 query_result->get(); // may throw on error855 query_result->get(); // may throw on error
856 }856 }
857 catch (std::exception const& e)857 catch (std::exception const&)
858 {858 {
859 BOOST_LOG(logger_)859 BOOST_LOG(logger_)
860 << "SmartScopesClient.get_preview_results(): Failed to retrieve preview results for query "860 << "SmartScopesClient.get_preview_results(): Failed to retrieve preview results for query "
861861
=== modified file 'src/scopes/internal/zmq_middleware/ZmqObject.cpp'
--- src/scopes/internal/zmq_middleware/ZmqObject.cpp 2015-09-08 02:58:39 +0000
+++ src/scopes/internal/zmq_middleware/ZmqObject.cpp 2015-11-26 05:49:23 +0000
@@ -50,8 +50,6 @@
50 std::mutex shared_mutex;50 std::mutex shared_mutex;
51}51}
5252
53#define MONITOR_ENDPOINT "ipc:///tmp/scopes-monitor"
54
55ZmqObjectProxy::ZmqObjectProxy(ZmqMiddleware* mw_base,53ZmqObjectProxy::ZmqObjectProxy(ZmqMiddleware* mw_base,
56 string const& endpoint,54 string const& endpoint,
57 string const& identity,55 string const& identity,
5856
=== modified file 'test/gtest/scopes/StandAloneScope/SimpleScope.cpp'
--- test/gtest/scopes/StandAloneScope/SimpleScope.cpp 2015-08-05 05:14:14 +0000
+++ test/gtest/scopes/StandAloneScope/SimpleScope.cpp 2015-11-26 05:49:23 +0000
@@ -77,7 +77,6 @@
77PreviewQueryBase::UPtr EchoScope::preview(Result const& /* result */, ActionMetadata const& /* metadata */)77PreviewQueryBase::UPtr EchoScope::preview(Result const& /* result */, ActionMetadata const& /* metadata */)
78{78{
79 abort();79 abort();
80 return nullptr;
81}80}
8281
83extern "C"82extern "C"
8483
=== modified file 'test/gtest/scopes/ThrowingClient/ThrowingClient_test.cpp'
--- test/gtest/scopes/ThrowingClient/ThrowingClient_test.cpp 2015-02-06 06:33:23 +0000
+++ test/gtest/scopes/ThrowingClient/ThrowingClient_test.cpp 2015-11-26 05:49:23 +0000
@@ -100,7 +100,7 @@
100 }100 }
101 }101 }
102102
103 virtual void info(OperationInfo const& /* op_info */)103 virtual void info(OperationInfo const& /* op_info */) override
104 {104 {
105 lock_guard<mutex> lock(mutex_);105 lock_guard<mutex> lock(mutex_);
106106
107107
=== modified file 'test/gtest/scopes/internal/SettingsDB/SettingsDB_test.cpp'
--- test/gtest/scopes/internal/SettingsDB/SettingsDB_test.cpp 2015-09-09 04:50:11 +0000
+++ test/gtest/scopes/internal/SettingsDB/SettingsDB_test.cpp 2015-11-26 05:49:23 +0000
@@ -81,15 +81,13 @@
81 ::close(fd);81 ::close(fd);
82}82}
8383
84BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(test_logger, boost::log::sources::severity_channel_logger_mt<>)
85
86TEST(SettingsDB, basic)84TEST(SettingsDB, basic)
87{85{
88 auto schema = TEST_SRC_DIR "/schema.ini";86 auto schema = TEST_SRC_DIR "/schema.ini";
8987
90 {88 {
91 unlink(db_name.c_str());89 unlink(db_name.c_str());
92 auto db = SettingsDB::create_from_ini_file(db_name, schema, test_logger::get());90 auto db = SettingsDB::create_from_ini_file(db_name, schema);
9391
94 // If db doesn't exist, default values are returned.92 // If db doesn't exist, default values are returned.
95 EXPECT_EQ(4, db->settings().size());93 EXPECT_EQ(4, db->settings().size());
@@ -165,7 +163,7 @@
165163
166 // This schema does not specify a default value for location and unit.164 // This schema does not specify a default value for location and unit.
167 auto schema = TEST_SRC_DIR "/no_default_schema.ini";165 auto schema = TEST_SRC_DIR "/no_default_schema.ini";
168 auto db = SettingsDB::create_from_ini_file(db_name, schema, test_logger::get());166 auto db = SettingsDB::create_from_ini_file(db_name, schema);
169167
170 // Check that we now can see only the other two values. (DB doesn't exist yet.)168 // Check that we now can see only the other two values. (DB doesn't exist yet.)
171 EXPECT_EQ(2, db->settings().size());169 EXPECT_EQ(2, db->settings().size());
@@ -188,7 +186,7 @@
188186
189 // This schema does not specify a default value for location and unit.187 // This schema does not specify a default value for location and unit.
190 auto schema = TEST_SRC_DIR "/no_default_schema.ini";188 auto schema = TEST_SRC_DIR "/no_default_schema.ini";
191 auto db = SettingsDB::create_from_ini_file(db_name, schema, test_logger::get());189 auto db = SettingsDB::create_from_ini_file(db_name, schema);
192190
193 // Add records to supply the values.191 // Add records to supply the values.
194 write_db("db_loctemp.ini");192 write_db("db_loctemp.ini");
@@ -218,7 +216,7 @@
218216
219 {217 {
220 unlink(db_name.c_str());218 unlink(db_name.c_str());
221 auto db = SettingsDB::create_from_ini_file(db_name, schema, test_logger::get());219 auto db = SettingsDB::create_from_ini_file(db_name, schema);
222220
223 // If db doesn't exist, default values are returned.221 // If db doesn't exist, default values are returned.
224 EXPECT_EQ(1, db->settings().size());222 EXPECT_EQ(1, db->settings().size());
@@ -237,7 +235,7 @@
237235
238 {236 {
239 unlink(db_name.c_str());237 unlink(db_name.c_str());
240 auto db = SettingsDB::create_from_ini_file(db_name, schema, test_logger::get());238 auto db = SettingsDB::create_from_ini_file(db_name, schema);
241239
242 // If db doesn't exist, default values are returned.240 // If db doesn't exist, default values are returned.
243 EXPECT_EQ(4, db->settings().size());241 EXPECT_EQ(4, db->settings().size());
@@ -288,7 +286,7 @@
288286
289 {287 {
290 unlink(db_name.c_str());288 unlink(db_name.c_str());
291 auto db = SettingsDB::create_from_json_string(db_name, ok_schema, test_logger::get());289 auto db = SettingsDB::create_from_json_string(db_name, ok_schema);
292290
293 // If db doesn't exist, default values are returned.291 // If db doesn't exist, default values are returned.
294 EXPECT_EQ(1, db->settings().size());292 EXPECT_EQ(1, db->settings().size());
@@ -305,7 +303,7 @@
305{303{
306 try304 try
307 {305 {
308 auto db = SettingsDB::create_from_ini_file("unused", "no_such_file", test_logger::get());306 auto db = SettingsDB::create_from_ini_file("unused", "no_such_file");
309 FAIL();307 FAIL();
310 }308 }
311 catch (ResourceException const& e)309 catch (ResourceException const& e)
@@ -318,7 +316,7 @@
318316
319 try317 try
320 {318 {
321 auto db = SettingsDB::create_from_json_string("unused", "syntax error", test_logger::get());319 auto db = SettingsDB::create_from_json_string("unused", "syntax error");
322 FAIL();320 FAIL();
323 }321 }
324 catch (ResourceException const& e)322 catch (ResourceException const& e)
@@ -334,7 +332,7 @@
334 // Open DB that doesn't exist yet.332 // Open DB that doesn't exist yet.
335 unlink(db_name.c_str());333 unlink(db_name.c_str());
336 auto schema = TEST_SRC_DIR "/schema.ini";334 auto schema = TEST_SRC_DIR "/schema.ini";
337 auto db = SettingsDB::create_from_ini_file(db_name, schema, test_logger::get());335 auto db = SettingsDB::create_from_ini_file(db_name, schema);
338336
339 // Add a record, which creates the DB337 // Add a record, which creates the DB
340 write_db("db_location.ini");338 write_db("db_location.ini");
@@ -363,7 +361,7 @@
363 write_db("db_location_munich.ini");361 write_db("db_location_munich.ini");
364362
365 auto schema = TEST_SRC_DIR "/schema.ini";363 auto schema = TEST_SRC_DIR "/schema.ini";
366 auto db = SettingsDB::create_from_ini_file(db_name, schema, test_logger::get());364 auto db = SettingsDB::create_from_ini_file(db_name, schema);
367365
368 EXPECT_EQ(4, db->settings().size());366 EXPECT_EQ(4, db->settings().size());
369 EXPECT_EQ("Munich", db->settings()["locationSetting"].get_string());367 EXPECT_EQ("Munich", db->settings()["locationSetting"].get_string());

Subscribers

People subscribed via source and target branches

to all changes: