util/rb_tree: Stop relying on &iter->field != NULL

The old version of the iterators relies on a &iter->field != NULL check
which works fine on older GCC but newer GCC versions and clang have
optimizations that break if you do pointer math on a null pointer.  The
correct solution to this is to do the null comparisons before we do any
sort of &iter->field or use rb_node_data to do the reverse operation.

Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Tested-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
40 jobs for !2123 with review/fix-rb-tree-foreach in 3 minutes and 3 seconds (queued for 3 seconds)
detached
Status Name Job ID Coverage
  Containers
passed debian-10 #667807

00:00:19

passed debian-9 #667808

00:00:20

passed test-container:arm64 #667809
aarch64

00:00:21

 
  Build
failed meson-arm64 #667812

00:00:07

failed meson-armhf #667811

00:00:08

failed meson-clang #667814

00:01:01

failed meson-clover #667817

00:00:07

failed meson-clover-old-llvm #667818

00:00:07

failed meson-i386 #667820

00:00:06

failed meson-main #667810

00:00:57

failed meson-swr-glvnd #667813

00:00:07

failed meson-vulkan #667819

00:01:05

failed scons #667821

00:00:07

failed scons-old-llvm #667822

00:00:14

failed scons-swr #667815

00:00:07

failed scons-win64 #667816

00:00:07

 
  Test
skipped arm64_a306_gles2 1/4 #667843
db410c
skipped arm64_a306_gles2 2/4 #667844
db410c
skipped arm64_a306_gles2 3/4 #667845
db410c
skipped arm64_a306_gles2 4/4 #667846
db410c
skipped arm64_a630_gles2 #667832
mesa-cheza
skipped arm64_a630_gles31 1/4 #667833
mesa-cheza
skipped arm64_a630_gles31 2/4 #667834
mesa-cheza
skipped arm64_a630_gles31 3/4 #667835
mesa-cheza
skipped arm64_a630_gles31 4/4 #667836
mesa-cheza
skipped arm64_a630_gles3 1/6 #667837
mesa-cheza
skipped arm64_a630_gles3 2/6 #667838
mesa-cheza
skipped arm64_a630_gles3 3/6 #667839
mesa-cheza
skipped arm64_a630_gles3 4/6 #667840
mesa-cheza
skipped arm64_a630_gles3 5/6 #667841
mesa-cheza
skipped arm64_a630_gles3 6/6 #667842
mesa-cheza
skipped test-llvmpipe-gles2 1/4 #667823
skipped test-llvmpipe-gles2 2/4 #667824
skipped test-llvmpipe-gles2 3/4 #667825
skipped test-llvmpipe-gles2 4/4 #667826
skipped test-softpipe-gles2 1/4 #667827
skipped test-softpipe-gles2 2/4 #667828
skipped test-softpipe-gles2 3/4 #667829
skipped test-softpipe-gles2 4/4 #667830
skipped test-softpipe-gles3-limited #667831
 
Name Stage Failure
failed
meson-armhf Build
No job log
failed
meson-main Build
No job log
failed
meson-vulkan Build
No job log
failed
meson-swr-glvnd Build
No job log
failed
meson-clover Build
No job log
failed
meson-arm64 Build
No job log
failed
scons-swr Build
No job log
failed
meson-clover-old-llvm Build
No job log
failed
meson-i386 Build
No job log
failed
scons Build
No job log
failed
scons-old-llvm Build
No job log
failed
meson-clang Build
No job log
failed
scons-win64 Build
No job log