Skip to content

Commit e8eeed3

Browse files
trying to fix null-dereference warnings
1 parent 37c3ce7 commit e8eeed3

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ else()
160160
"-Wcast-align" #Warn if a cast causes memory alignment changes
161161
"-Wshadow" #Warn if local variable shadows another variable
162162
"-Wformat=2" #Sanity checks for printf-like formatting
163-
"-Wno-format-nonliteral" # But don't worry about non-literal formtting (i.e. run-time printf format strings)
163+
"-Wno-format-nonliteral" # But don't worry about non-literal formatting (i.e. run-time printf format strings)
164164
"-Wlogical-op" #Checks for logical op when bit-wise expected
165165
"-Wmissing-declarations" #Warn if a global function is defined with no declaration
166166
"-Wmissing-include-dirs" #Warn if a user include directory is missing
@@ -178,10 +178,10 @@ else()
178178
"-Wduplicated-cond" #Warn about identical conditions in if-else chains
179179
"-Wduplicated-branches" #Warn when different branches of an if-else chain are equivalent
180180
"-Wnull-dereference" #Warn about null pointer dereference execution paths
181-
"-Wuninitialized" #Warn about unitialized values
181+
"-Wuninitialized" #Warn about uninitialized values
182182
"-Winit-self" #Warn about self-initialization
183183
"-Wcatch-value=3" #Warn when catch statements don't catch by reference
184-
"-Wextra-semi" #Warn about redudnant semicolons
184+
"-Wextra-semi" #Warn about redundant semicolons
185185
"-Wimplicit-fallthrough=3" #Warn about case fallthroughs, but allow 'fallthrough' comments to suppress warnings
186186
#GCC-like optional
187187
#"-Wsuggest-final-types" #Suggest where 'final' would help if specified on a type methods

vpr/src/place/grid_tile_lookup.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ GridTileLookup::GridTileLookup() {
44
const auto& device_ctx = g_vpr_ctx.device();
55
const int num_layers = device_ctx.grid.get_num_layers();
66

7-
//Will store the max number of tile locations for each logical block type
8-
max_placement_locations.resize(device_ctx.logical_block_types.size());
7+
if (device_ctx.logical_block_types.empty()) {
8+
throw std::runtime_error("Logical block types are empty.");
9+
} else {
10+
// Will store the max number of tile locations for each logical block type
11+
max_placement_locations.resize(device_ctx.logical_block_types.size());
12+
}
913

1014
for (const auto& type : device_ctx.logical_block_types) {
1115
vtr::NdMatrix<int, 3> type_count({static_cast<unsigned long>(num_layers), device_ctx.grid.width(), device_ctx.grid.height()});

vpr/src/route/route_common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,11 @@ static vtr::vector<ParentBlockId, std::vector<RRNodeId>> load_rr_clb_sources(con
601601

602602
static vtr::vector<ParentNetId, uint8_t> load_is_clock_net(const Netlist<>& net_list,
603603
bool is_flat) {
604-
vtr::vector<ParentNetId, uint8_t> is_clock_net;
604+
vtr::vector<ParentNetId, uint8_t> is_clock_net(net_list.nets().size());
605605

606606
auto& atom_ctx = g_vpr_ctx.atom();
607607
std::set<AtomNetId> clock_nets = find_netlist_physical_clock_nets(atom_ctx.nlist);
608608

609-
is_clock_net.resize(net_list.nets().size());
610609
for (auto net_id : net_list.nets()) {
611610
std::size_t net_id_num = std::size_t(net_id);
612611
if (is_flat) {

vpr/src/route/router_lookahead_map_utils.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,9 +1219,7 @@ static void run_intra_tile_dijkstra(const RRGraphView& rr_graph,
12191219
node_expanded.resize(rr_graph.num_nodes());
12201220
std::fill(node_expanded.begin(), node_expanded.end(), false);
12211221

1222-
vtr::vector<RRNodeId, float> node_seen_cost;
1223-
node_seen_cost.resize(rr_graph.num_nodes());
1224-
std::fill(node_seen_cost.begin(), node_seen_cost.end(), -1.);
1222+
vtr::vector<RRNodeId, float> node_seen_cost(rr_graph.num_nodes(), -1.f);
12251223

12261224
struct t_pq_entry {
12271225
float delay;

0 commit comments

Comments
 (0)