We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c99a474 commit 2a8875bCopy full SHA for 2a8875b
7 files changed
CMakeLists.txt
@@ -56,6 +56,9 @@ target_include_directories(cfbox PUBLIC include)
56
target_include_directories(cfbox PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
57
target_link_libraries(cfbox PRIVATE cfbox_compiler_flags)
58
59
+# ── Install target ─────────────────────────────────────────────
60
+install(TARGETS cfbox DESTINATION bin)
61
+
62
# ── GTest via CPM (FetchContent) ──────────────────────────────
63
if(NOT CMAKE_CROSSCOMPILING)
64
CPMAddPackage(
cmake/compile/CompilerFlag.cmake
@@ -27,6 +27,10 @@ target_compile_options(cfbox_compiler_flags INTERFACE
27
-Wnull-dereference
28
-Wdouble-promotion
29
-Wformat=2
30
+ -Wformat-signedness
31
+ -Wstrict-aliasing
32
+ -fno-exceptions
33
+ -fno-rtti
34
)
35
36
# ── Debug-specific flags ──────────────────────────────────────
src/applets/ar.cpp
@@ -54,9 +54,9 @@ auto ar_main(int argc, char* argv[]) -> int {
54
std::memset(hdr, ' ', 60);
55
std::memcpy(hdr, fname.c_str(), std::min(fname.size(), static_cast<std::size_t>(16)));
std::snprintf(hdr + 16, 12, "%-10lu", static_cast<unsigned long>(::time(nullptr)));
- std::snprintf(hdr + 28, 12, "%-6u", 0); // uid
- std::snprintf(hdr + 34, 12, "%-6u", 0); // gid
- std::snprintf(hdr + 40, 12, "%-8o", 0100644);
+ std::snprintf(hdr + 28, 12, "%-6u", 0u); // uid
+ std::snprintf(hdr + 34, 12, "%-6u", 0u); // gid
+ std::snprintf(hdr + 40, 12, "%-8o", 0100644u);
std::snprintf(hdr + 48, 12, "%-10zu", data->size());
hdr[58] = '`'; hdr[59] = '\n';
output.append(hdr, 60);
src/applets/hostid.cpp
@@ -22,6 +22,6 @@ auto hostid_main(int argc, char* argv[]) -> int {
22
if (parsed.has_long("version")) { cfbox::help::print_version(HELP); return 0; }
23
24
long id = gethostid();
25
- std::printf("%08lx\n", id);
+ std::printf("%08ld\n", id);
26
return 0;
}
src/applets/install.cpp
@@ -36,22 +36,20 @@ auto install_main(int argc, char* argv[]) -> int {
auto target_dir = parsed.get_any('t', "target-directory");
37
const auto& pos = parsed.positional();
38
39
- auto parse_mode = [](const std::string& s) -> std::filesystem::perms {
40
- unsigned long m = std::stoul(s, nullptr, 8);
41
- return static_cast<std::filesystem::perms>(m);
42
- };
43
-
44
std::filesystem::perms mode = std::filesystem::perms::owner_read |
45
std::filesystem::perms::owner_write |
46
std::filesystem::perms::group_read |
47
std::filesystem::perms::others_read;
48
if (mode_str) {
49
- try { mode = parse_mode(std::string{*mode_str}); }
50
- catch (...) {
+ char* end = nullptr;
+ errno = 0;
+ unsigned long m = std::strtoul(mode_str->data(), &end, 8);
+ if (errno != 0 || end == mode_str->data() || *end != '\0') {
51
std::fprintf(stderr, "cfbox install: invalid mode '%.*s'\n",
52
static_cast<int>(mode_str->size()), mode_str->data());
53
return 1;
+ mode = static_cast<std::filesystem::perms>(m);
if (mkdir_mode) {
src/applets/stat.cpp
@@ -155,8 +155,8 @@ auto stat_main(int argc, char* argv[]) -> int {
155
file_type_string(st.st_mode));
156
auto* pw = getpwuid(st.st_uid);
157
auto* gr = getgrgid(st.st_gid);
158
- std::printf("Access: (%04o/%s) Uid: (%5d/%-8s) Gid: (%5d/%-8s)\n",
159
- st.st_mode & 07777,
+ std::printf("Access: (%04o/%s) Uid: (%5u/%-8s) Gid: (%5u/%-8s)\n",
+ st.st_mode & 07777u,
160
format_perms(st.st_mode).c_str(),
161
st.st_uid, pw ? pw->pw_name : "",
162
st.st_gid, gr ? gr->gr_name : "");
src/applets/sum.cpp
@@ -40,10 +40,10 @@ auto sum_main(int argc, char* argv[]) -> int {
if (sysv) {
auto result = cfbox::checksum::sysv_sum(*data_result);
- std::printf("%d %d", result.checksum, result.blocks);
+ std::printf("%u %u", result.checksum, result.blocks);
} else {
auto result = cfbox::checksum::bsd_sum(*data_result);
- std::printf("%05d %5d", result.checksum, result.blocks);
+ std::printf("%05u %5u", result.checksum, result.blocks);
if (p != "-") std::printf(" %.*s", static_cast<int>(p.size()), p.data());
std::putchar('\n');
0 commit comments