Skip to content

Commit c7e8fc1

Browse files
authored
Merge pull request #272 from chaoticgd/tidy
Tidy up the code a bit
2 parents bde85c8 + d794ca1 commit c7e8fc1

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/ccc/elf.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace ccc {
99

10-
extern const std::map<std::string, KnownElfSectionClass> KNOWN_ELF_SECTIONS = {
10+
const std::map<std::string, KnownElfSectionClass> KNOWN_ELF_SECTIONS = {
1111
{".bss", KnownElfSectionClass::DATA},
1212
{".data", KnownElfSectionClass::DATA},
1313
{".lit", KnownElfSectionClass::DATA},
@@ -35,7 +35,8 @@ Result<ElfFile> ElfFile::parse(std::vector<u8> image)
3535
CCC_CHECK(header, "ELF file header out of range.");
3636
elf.file_header = *header;
3737

38-
const ElfSectionHeader* shstr_section_header = get_unaligned<ElfSectionHeader>(elf.image, header->shoff + header->shstrndx * sizeof(ElfSectionHeader));
38+
const ElfSectionHeader* shstr_section_header = get_unaligned<ElfSectionHeader>(
39+
elf.image, header->shoff + header->shstrndx * sizeof(ElfSectionHeader));
3940
CCC_CHECK(shstr_section_header, "ELF section name header out of range.");
4041

4142
for (u32 i = 0; i < header->shnum; i++) {
@@ -44,7 +45,7 @@ Result<ElfFile> ElfFile::parse(std::vector<u8> image)
4445
CCC_CHECK(section_header, "ELF section header out of range.");
4546

4647
std::optional<std::string_view> name = get_string(elf.image, shstr_section_header->offset + section_header->name);
47-
CCC_CHECK(name, "ELF section name out of range.");
48+
CCC_CHECK(name.has_value(), "ELF section name out of range.");
4849

4950
ElfSection& section = elf.sections.emplace_back();
5051
section.name = *name;

src/ccc/symbol_database.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ size_t SymbolList<SymbolType>::binary_search(SymbolHandle<SymbolType> handle) co
491491
template <typename SymbolType>
492492
void SymbolList<SymbolType>::link_address_map(SymbolType& symbol)
493493
{
494-
if constexpr ((SymbolType::FLAGS & WITH_ADDRESS_MAP)) {
494+
if constexpr (SymbolType::FLAGS & WITH_ADDRESS_MAP) {
495495
if (symbol.address().valid()) {
496496
m_address_to_handle.emplace(symbol.address().value, symbol.handle());
497497
}

src/ccc/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ccc {
77

88
static CustomErrorCallback custom_error_callback = nullptr;
99

10-
Error format_error(const char* source_file, int source_line, const char* format, ...)
10+
Error format_error(const char* source_file, s32 source_line, const char* format, ...)
1111
{
1212
va_list args;
1313
va_start(args, format);

src/ccc/util.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ enum ErrorLevel {
5252

5353
typedef void (*CustomErrorCallback)(const Error& error, ErrorLevel level);
5454

55-
Error format_error(const char* source_file, int source_line, const char* format, ...);
55+
Error format_error(const char* source_file, s32 source_line, const char* format, ...);
5656
void report_error(const Error& error);
5757
void report_warning(const Error& warning);
5858
void set_custom_error_callback(CustomErrorCallback callback);
@@ -155,9 +155,9 @@ class [[nodiscard]] CCC_WARN_UNUSED Result {
155155
};
156156

157157
template <>
158-
class [[nodiscard]] CCC_WARN_UNUSED Result<void> : public Result<int> {
158+
class [[nodiscard]] CCC_WARN_UNUSED Result<void> : public Result<s32> {
159159
public:
160-
Result() : Result<int>(0) {}
160+
Result() : Result<s32>(0) {}
161161

162162
// Used to propagate errors up the call stack.
163163
template <typename OtherValue>
@@ -168,7 +168,7 @@ class [[nodiscard]] CCC_WARN_UNUSED Result<void> : public Result<int> {
168168
}
169169
};
170170

171-
#define CCC_FAILURE(...) ccc::Result<int>::failure(ccc::format_error(__FILE__, __LINE__, __VA_ARGS__))
171+
#define CCC_FAILURE(...) ccc::Result<s32>::failure(ccc::format_error(__FILE__, __LINE__, __VA_ARGS__))
172172

173173
#define CCC_CHECK(condition, ...) \
174174
if (!(condition)) { \
@@ -197,7 +197,7 @@ class [[nodiscard]] CCC_WARN_UNUSED Result<void> : public Result<int> {
197197
}
198198

199199
template <typename... Args>
200-
void warn_impl(const char* source_file, int source_line, const char* format, Args... args)
200+
void warn_impl(const char* source_file, s32 source_line, const char* format, Args... args)
201201
{
202202
Error warning = format_error(source_file, source_line, format, args...);
203203
report_warning(warning);

0 commit comments

Comments
 (0)