Skip to content

Commit

Permalink
fix: lint errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vfusco committed Feb 8, 2024
1 parent dce99c0 commit 0cc0a42
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 57 deletions.
10 changes: 5 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ CLANG_FORMAT_FILES:=$(filter-out %.pb.h,$(strip $(CLANG_FORMAT_FILES)))

EMPTY:=
SPACE:=$(EMPTY) $(EMPTY)
CLANG_TIDY_HEADER_FILTER=$(PWD)/($(subst $(SPACE),|,$(LINTER_HEADERS)))
CLANG_TIDY_HEADER_FILTER=$(CURDIR)/($(subst $(SPACE),|,$(LINTER_HEADERS)))

CXXFLAGS+=$(OPTFLAGS) -std=c++17 -fvisibility=hidden -fPIC -MMD $(CC_MARCH) $(INCS) $(GCFLAGS) $(UBFLAGS) $(DEFS) $(WARNS) $(MYCFLAGS)
CFLAGS+=$(OPTFLAGS) -std=c99 -fvisibility=hidden -fPIC -MMD $(CC_MARCH) $(INCS) $(GCFLAGS) $(UBFLAGS) $(DEFS) $(WARNS) $(MYCFLAGS)
Expand Down Expand Up @@ -353,13 +353,13 @@ test-server-manager: $(TEST_SERVER_MANAGER_OBJS)
$(PROTOC) -I$(HEALTHCHECK_DIR) --cpp_out=. $<

%.clang-tidy: %.cpp $(PROTO_SOURCES)
@$(CLANG_TIDY) --header-filter='$(CLANG_TIDY_HEADER_FILTER)' $< -- $(CXXFLAGS) 2>/dev/null
@$(CXX) $(CXXFLAGS) $< -MM -MT $@ -MF $@.d > /dev/null 2>&1
$(CLANG_TIDY) --header-filter='$(CLANG_TIDY_HEADER_FILTER)' $< -- $(CXXFLAGS) 2>/dev/null
$(CXX) $(CXXFLAGS) $< -MM -MT $@ -MF $@.d > /dev/null 2>&1
@touch $@

%.clang-tidy: %.c $(PROTO_SOURCES)
@$(CLANG_TIDY) --header-filter='$(CLANG_TIDY_HEADER_FILTER)' $< -- $(CFLAGS) 2>/dev/null
@$(CC) $(CFLAGS) $< -MM -MT $@ -MF $@.d > /dev/null 2>&1
$(CLANG_TIDY) --header-filter='$(CLANG_TIDY_HEADER_FILTER)' $< -- $(CFLAGS) 2>/dev/null
$(CC) $(CFLAGS) $< -MM -MT $@ -MF $@.d > /dev/null 2>&1
@touch $@

%.o: %.cpp
Expand Down
1 change: 1 addition & 0 deletions src/back-merkle-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//

#include "back-merkle-tree.h"
#include <cassert>
#include <limits>

/// \file
Expand Down
2 changes: 2 additions & 0 deletions src/complete-merkle-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "complete-merkle-tree.h"

#include <cassert>

/// \file
/// \brief Complete Merkle tree implementation.

Expand Down
1 change: 0 additions & 1 deletion src/i-hasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <array>
#include <cstddef>
#include <cstdint>

#include "meta.h"

Expand Down
5 changes: 2 additions & 3 deletions src/machine-merkle-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <cstdint>
#include <deque>
#include <iosfwd>
#include <type_traits>
#include <unordered_map>

#include "keccak-256-hasher.h"
Expand All @@ -44,7 +43,7 @@ namespace cartesi {
///
/// To optimize for space, subtrees corresponding to pristine
/// memory are represented by <tt>nullptr</tt> nodes.
/// Additionaly, the tree is truncated below *page* nodes
/// Additionally, the tree is truncated below *page* nodes
/// subintending LOG2_PAGE_SIZE bits of address space.
/// The trees corresponding to pages are rebuilt from the
/// original data whenever needed and never stored.
Expand Down Expand Up @@ -158,7 +157,7 @@ class machine_merkle_tree final {
/// \brief Maps a page_index to a node.
/// \param page_index Page index.
/// \param node Node subintending page.
/// \return 1 if succeeded, 0 othewise.
/// \return 1 if succeeded, 0 otherwise.
int set_page_node_map(address_type page_index, tree_node *node);

/// \brief Creates and returns a new tree node.
Expand Down
8 changes: 3 additions & 5 deletions src/merkle-tree-proof.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
/// \file
/// \brief Merkle tree proof structure

#include <cassert>
#include "i-hasher.h"
#include <cstdint>
#include <exception>
#include <iostream>
#include <vector>

namespace cartesi {
Expand Down Expand Up @@ -221,7 +219,7 @@ class merkle_tree_proof final {
throw std::out_of_range{"log2_root_size is too large"};
}
if (new_log2_target_size < get_log2_target_size()) {
throw std::out_of_range{"log2_taget_size is too small"};
throw std::out_of_range{"log2_target_size is too small"};
}
merkle_tree_proof<HASH_TYPE, ADDRESS_TYPE> sliced(new_log2_root_size, new_log2_target_size);
hash_type hash = get_target_hash();
Expand Down Expand Up @@ -254,7 +252,7 @@ class merkle_tree_proof final {

private:
/// \brief Converts log2_size to index into siblings array
/// \return Index into siblings array, or throws exception if out of bouds
/// \return Index into siblings array, or throws exception if out of bounds
int log2_size_to_index(int log2_size) const {
// We know log2_root_size > 0, so log2_root_size-1 >= 0
const int index = m_log2_root_size - 1 - log2_size;
Expand Down
1 change: 0 additions & 1 deletion src/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#ifndef META_H
#define META_H

#include <cinttypes>
#include <type_traits>

/// \file
Expand Down
1 change: 1 addition & 0 deletions src/pristine-merkle-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//

#include "pristine-merkle-tree.h"
#include <cassert>
#include <stdexcept>

/// \file
Expand Down
2 changes: 0 additions & 2 deletions src/pristine-merkle-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
#ifndef PRISTINE_MERKLE_TREE_H
#define PRISTINE_MERKLE_TREE_H

#include <cassert>
#include <cstdint>
#include <vector>

#include "keccak-256-hasher.h"
#include "meta.h"

/// \file
/// \brief Pristine Merkle tree interface.
Expand Down
1 change: 0 additions & 1 deletion src/protobuf-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
#pragma GCC diagnostic ignored "-Wtype-limits"
#include "cartesi-machine.pb.h"
#include "versioning.pb.h"
#pragma GCC diagnostic pop

#include "machine-merkle-tree.h"
Expand Down
18 changes: 11 additions & 7 deletions src/server-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@
// limitations under the License.
//

#if defined(__clang__) && defined(__APPLE__)
#if !defined(__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__) && defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
#define __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
#endif
#endif

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <map>
#include <new>
#include <optional>
#include <sstream>
#include <string>
#include <unordered_map>
#include <variant>
Expand Down Expand Up @@ -178,7 +182,7 @@ static std::string request_metadata(const grpc::ServerContext &context) {
// The idea is as follows:
// 1) Completion queue returns tag-1 identifying an <RPC-name> server call
// 2) Processing of tag-1 starts the appropriate client call
// using stub->Async<RPC-name>() and reader->Finish(), and specifes tag-2 for
// using stub->Async<RPC-name>() and reader->Finish(), and specifies tag-2 for
// completion
// 4) Completion queue returns tag-2 identifying the client call is complete
// 5) Processing of tag-2 passes result back using write->Finish(), and
Expand Down Expand Up @@ -459,7 +463,7 @@ class auto_lock final {
}
}

/// \brief Desctructor automatically releases lock
/// \brief Destructor automatically releases lock
~auto_lock() {
m_lock = false;
}
Expand Down Expand Up @@ -1996,7 +2000,7 @@ static std::string read_memory_range(async_context &actx, const MemoryRangeConfi
return data ? std::move(*data) : std::string{};
}

/// \brief Checkes if all values are null
/// \brief Checks if all values are null
/// \param begin First element
/// \param end One past last element
/// \return True if all are null, false otherwie
Expand Down Expand Up @@ -2399,7 +2403,7 @@ static void process_pending_query(handler_context &hctx, async_context &actx, ep
set_htif_yield_ack_data(actx, ROLLUP_INSPECT_STATE);
auto max_mcycle = actx.session.current_mcycle + actx.session.server_cycles.max_inspect_state;
// Loop getting reports until the machine exceeds max_mcycle, rejects the query, accepts the query,
// or behaves inaproppriately
// or behaves inappropriately
q.status = completion_status::accepted;
auto start_time = std::chrono::system_clock::now();
auto current_mcycle = actx.session.current_mcycle;
Expand Down Expand Up @@ -2509,7 +2513,7 @@ static void process_pending_inputs(handler_context &hctx, async_context &actx, e
check_htif_yield_ack_data(actx, ROLLUP_ADVANCE_STATE);
auto max_mcycle = actx.session.current_mcycle + actx.session.server_cycles.max_advance_state;
// Loop getting vouchers and notices until the machine exceeds
// max_mcycle, rejects the input, accepts the input, or behaves inaproppriately
// max_mcycle, rejects the input, accepts the input, or behaves inappropriately
auto start_time = std::chrono::system_clock::now();
auto mcycle_increment = actx.session.server_cycles.advance_state_increment;
auto deadline_increment = actx.session.server_deadline.advance_state_increment;
Expand Down
Loading

0 comments on commit 0cc0a42

Please sign in to comment.