Skip to content

Commit f6561a4

Browse files
authored
feat: fix build warnings for all targets (#236)
fix: CMake import issues fix: virtual destructor warning chore: removed auto generated files
1 parent 3e42413 commit f6561a4

File tree

18 files changed

+55
-179
lines changed

18 files changed

+55
-179
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ MigrationBackup/
361361
cmake-build/
362362
xcode-build/
363363
cmake-build*/
364+
build_support/
364365

365366
# pip
366367
*.egg-info

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ endif()
3232

3333
project(
3434
casbin
35-
VERSION 1.44.0
35+
VERSION 1.53.2
3636
DESCRIPTION "An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++"
3737
HOMEPAGE_URL https://github.com/casbin/casbin-cpp
3838
LANGUAGES CXX C

build_support/clang_format_exclusions.txt

Whitespace-only changes.

build_support/run_clang_format.py

Lines changed: 0 additions & 131 deletions
This file was deleted.

casbin/config/config.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ void Config::ParseBuffer(std::istream* buf) {
7777
else {
7878
std::vector<std::string> option_val = Split(line, "=", 2);
7979
if (option_val.size() != 2) {
80-
char* error = new char;
81-
sprintf(error, "parse the content error : line %d , %s = ? ", line_num, option_val[0].c_str());
82-
throw IllegalArgumentException(std::string(error));
80+
std::string error = "parse the content error : line " + std::to_string(line_num) + " , " + option_val[0] + " = ?";
81+
throw IllegalArgumentException(error);
8382
}
8483
std::string option = Trim(option_val[0]);
8584
std::string value = Trim(option_val[1]);

casbin/enforcer_cached.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ CachedEnforcer::CachedEnforcer(const CachedEnforcer& ce)
108108
this->enableCache = ce.enableCache;
109109
}
110110

111-
CachedEnforcer::CachedEnforcer(CachedEnforcer&& ce)
111+
CachedEnforcer::CachedEnforcer(CachedEnforcer&& ce) noexcept
112112
: Enforcer(ce) {
113-
this->m = move(ce.m);
113+
this->m = std::move(ce.m);
114114
this->enableCache = ce.enableCache;
115115
}
116116

117-
void CachedEnforcer::EnableCache(const bool& enableCache) {
118-
this->enableCache = enableCache;
117+
void CachedEnforcer::EnableCache(const bool& shouldEnableCache) {
118+
this->enableCache = shouldEnableCache;
119119
}
120120

121121
std::pair<bool, bool> CachedEnforcer::getCachedResult(const std::string& key) {

casbin/enforcer_synced.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void SyncedEnforcer ::SetWatcher(std::shared_ptr<Watcher> w) {
139139

140140
// LoadModel reloads the model from the model CONF file.
141141
void SyncedEnforcer ::LoadModel() {
142-
std::unique_lock<std::shared_mutex>(policyMutex);
142+
std::unique_lock<std::shared_mutex> lock(policyMutex);
143143
Enforcer::LoadModel();
144144
}
145145

casbin/management_api.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ bool Enforcer ::AddNamedPolicy(const std::string& p_type, const std::vector<std:
144144
return this->addPolicy("p", p_type, str_slice);
145145
}
146146

147-
std::vector<std::string> policy;
148-
for (int i = 0; i < params.size(); i++)
149-
policy.push_back(params[i]);
150-
return this->addPolicy("p", p_type, policy);
147+
return this->addPolicy("p", p_type, params);
151148
}
152149

153150
// AddNamedPolicies adds authorization rules to the current named policy.

casbin/persist/adapter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
namespace casbin {
2626

2727
// LoadPolicyLine loads a text line as a policy rule to model.
28-
void LoadPolicyLine(std::string line, const std::shared_ptr<Model>& model) {
29-
if (line == "" || line.find("#") == 0)
28+
void LoadPolicyLine(const std::string& line, const std::shared_ptr<Model>& model) {
29+
if (line.empty() || line.find('#') == 0)
3030
return;
3131

3232
std::vector<std::string> tokens = Split(line, ",", -1);

casbin/persist/adapter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
namespace casbin {
2626

2727
// LoadPolicyLine loads a text line as a policy rule to model.
28-
void LoadPolicyLine(std::string line, const std::shared_ptr<Model>& model);
28+
void LoadPolicyLine(const std::string& line, const std::shared_ptr<Model>& model);
2929

3030
/**
3131
* Adapter is the interface for Casbin adapters.
@@ -34,6 +34,8 @@ class Adapter {
3434
public:
3535
bool filtered;
3636

37+
virtual ~Adapter() = default;
38+
3739
/**
3840
* LoadPolicy loads all policy rules from the storage.
3941
*

0 commit comments

Comments
 (0)