Skip to content

Commit

Permalink
distances: fix clang warning about NULL pointer substraction in conta…
Browse files Browse the repository at this point in the history
…iner_offset

warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]

Substracting NULL is really required anymore since NULL is always 0 since C99 anyway.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Apr 27, 2022
1 parent 1e62d6a commit b294ce8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hwloc/distances.c
@@ -1,5 +1,5 @@
/*
* Copyright © 2010-2021 Inria. All rights reserved.
* Copyright © 2010-2022 Inria. All rights reserved.
* Copyright © 2011-2012 Université Bordeaux
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
Expand Down Expand Up @@ -860,7 +860,7 @@ struct hwloc_distances_container_s {
struct hwloc_distances_s distances;
};

#define HWLOC_DISTANCES_CONTAINER_OFFSET ((char*)&((struct hwloc_distances_container_s*)NULL)->distances - (char*)NULL)
#define HWLOC_DISTANCES_CONTAINER_OFFSET ((uintptr_t)(&((struct hwloc_distances_container_s*)NULL)->distances) - (uintptr_t)NULL)
#define HWLOC_DISTANCES_CONTAINER(_d) (struct hwloc_distances_container_s *) ( ((char*)_d) - HWLOC_DISTANCES_CONTAINER_OFFSET )

static struct hwloc_internal_distances_s *
Expand Down

0 comments on commit b294ce8

Please sign in to comment.