]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
gelf_getnote.c: Replace assert with eu_static_assert
authorAaron Merey <amerey@redhat.com>
Tue, 7 Oct 2025 16:34:17 +0000 (12:34 -0400)
committerAaron Merey <amerey@redhat.com>
Tue, 7 Oct 2025 16:42:26 +0000 (12:42 -0400)
Two runtime asserts in gelf_getnote() compare sizeof GElf_Nhdr with
Elf32_Ndhr and Elf64_Nhdr.  This can be done at compile time using
eu_static_assert.

Signed-off-by: Aaron Merey <amerey@redhat.com>
libelf/gelf_getnote.c

index 0f7b9d682b31c62a48be989dc7daf62adf812b8c..2cf28565e0cd36191e4c145ea71cc30f0a7a246e 100644 (file)
@@ -51,8 +51,8 @@ gelf_getnote (Elf_Data *data, size_t offset, GElf_Nhdr *result,
 
   /* It's easy to handle this type.  It has the same size for 32 and
      64 bit objects.  */
-  assert (sizeof (GElf_Nhdr) == sizeof (Elf32_Nhdr));
-  assert (sizeof (GElf_Nhdr) == sizeof (Elf64_Nhdr));
+  eu_static_assert (sizeof (GElf_Nhdr) == sizeof (Elf32_Nhdr));
+  eu_static_assert (sizeof (GElf_Nhdr) == sizeof (Elf64_Nhdr));
 
   rwlock_rdlock (((Elf_Data_Scn *) data)->s->elf->lock);