Skip to content

Commit 3b1be1e

Browse files
HadrienG2bgoglin
authored andcommitted
Apply PR suggestions: only copy grouping-dependent members if grouping is set, move after declarations
1 parent ca2eb00 commit 3b1be1e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

hwloc/distances.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,17 @@ static int hwloc_internal_distances_dup_one(struct hwloc_topology *new, struct h
185185
/* This function may be called with topology->tma set, it cannot free() or realloc() */
186186
int hwloc_internal_distances_dup(struct hwloc_topology *new, struct hwloc_topology *old)
187187
{
188-
new->grouping = old->grouping;
189-
new->grouping_verbose = old->grouping_verbose;
190-
new->grouping_nbaccuracies = old->grouping_nbaccuracies;
191-
memcpy(new->grouping_accuracies, old->grouping_accuracies, sizeof(old->grouping_accuracies));
192-
new->grouping_next_subkind = old->grouping_next_subkind;
193-
194188
struct hwloc_internal_distances_s *olddist;
195189
int err;
190+
191+
new->grouping = old->grouping;
192+
if (old->grouping) {
193+
new->grouping_verbose = old->grouping_verbose;
194+
new->grouping_nbaccuracies = old->grouping_nbaccuracies;
195+
memcpy(new->grouping_accuracies, old->grouping_accuracies, sizeof(old->grouping_accuracies));
196+
new->grouping_next_subkind = old->grouping_next_subkind;
197+
}
198+
196199
new->next_dist_id = old->next_dist_id;
197200
for(olddist = old->first_dist; olddist; olddist = olddist->next) {
198201
err = hwloc_internal_distances_dup_one(new, olddist);

0 commit comments

Comments
 (0)