[ox/clargs] Enable unsafe buffer warnings
Some checks failed
Build / build (push) Has been cancelled

This commit is contained in:
Gary Talent 2024-11-26 22:05:32 -06:00
parent 9b8a8c4e46
commit dbbaaa46b9
3 changed files with 15 additions and 4 deletions

View File

@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 3.10)
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
# enable warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunsafe-buffer-usage")
endif()
add_library(
OxClArgs

View File

@ -12,16 +12,17 @@
namespace ox {
ClArgs::ClArgs(int argc, const char **args) noexcept {
auto const argv = ox::SpanView{args, static_cast<size_t>(argc)};
for (auto i = 0u; i < static_cast<unsigned>(argc); ++i) {
auto arg = String(args[i]);
auto arg = String(argv[i]);
if (arg[0] == '-') {
while (arg[0] == '-' && arg.len()) {
arg = arg.substr(1);
}
m_bools[arg] = true;
// parse additional arguments
if (i < static_cast<unsigned>(argc) && args[i + 1]) {
auto val = String(args[i + 1]);
if (i < static_cast<unsigned>(argc) && argv[i + 1]) {
auto val = String(argv[i + 1]);
if (val.len() && val[i] != '-') {
if (val == "false") {
m_bools[arg] = false;

View File

@ -10,9 +10,12 @@
#include "array.hpp"
#include "bit.hpp"
#include "def.hpp"
#include "iterator.hpp"
#include "vector.hpp"
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
namespace ox {
template<typename T>
@ -258,3 +261,5 @@ class Span {
};
}
OX_CLANG_NOWARN_END