summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorCebtenzzre <cebtenzzre@gmail.com>2023-09-07 13:22:29 -0400
committerGitHub <noreply@github.com>2023-09-07 13:22:29 -0400
commit00d62adb79bf914a95fb9a2e8f42f3029e76d62c (patch)
tree36d294e4df3ded0cd0f3c96ab7bd64dd800002ec /common
parent4fa2cc1750b861880de42515cb19c13b2d776ee2 (diff)
fix some warnings from gcc and clang-tidy (#3038)
Co-authored-by: xaedes <xaedes@gmail.com>
Diffstat (limited to 'common')
-rw-r--r--common/common.cpp2
-rw-r--r--common/common.h3
-rw-r--r--common/grammar-parser.cpp1
3 files changed, 5 insertions, 1 deletions
diff --git a/common/common.cpp b/common/common.cpp
index 28b7c630..6e5d5b4d 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -57,7 +57,7 @@ int32_t get_num_physical_cores() {
siblings.insert(line);
}
}
- if (siblings.size() > 0) {
+ if (!siblings.empty()) {
return static_cast<int32_t>(siblings.size());
}
#elif defined(__APPLE__) && defined(__MACH__)
diff --git a/common/common.h b/common/common.h
index 85ac0df9..012bf5e1 100644
--- a/common/common.h
+++ b/common/common.h
@@ -20,6 +20,9 @@
#define DIRECTORY_SEPARATOR '/'
#endif // _WIN32
+#define die(msg) do { fputs("error: " msg "\n", stderr); exit(1); } while (0)
+#define die_fmt(fmt, ...) do { fprintf(stderr, "error: " fmt "\n", ##__VA_ARGS__); exit(1); } while (0)
+
//
// CLI argument parsing
//
diff --git a/common/grammar-parser.cpp b/common/grammar-parser.cpp
index e76bd11c..177d1e3a 100644
--- a/common/grammar-parser.cpp
+++ b/common/grammar-parser.cpp
@@ -415,6 +415,7 @@ namespace grammar_parser {
std::vector<const llama_grammar_element *> parse_state::c_rules() {
std::vector<const llama_grammar_element *> ret;
+ ret.reserve(rules.size());
for (const auto & rule : rules) {
ret.push_back(rule.data());
}