summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2020-10-02 14:52:19 +0200
committerPetr Štetiar <ynezz@true.cz>2020-10-03 09:46:18 +0200
commit671c7554bfdeab758f605d1e1a2420117e96a628 (patch)
tree4ac2b2da8733c08cb061b4b60cc36ad43fb36b92
parentea5bbd57d0e1f3ff5fd3b8580741c46093caa845 (diff)
downloaduci-671c7554bfdeab758f605d1e1a2420117e96a628.tar.gz
uci: silence UBSAN error by using offsetof macro from compiler
Fixes following ubdefined-behavior as reported by clang version 10.0.0-4ubuntu1~18.04.2: delta.c:139:52: runtime error: member access within null pointer of type 'struct uci_element' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior delta.c:139:52 Signed-off-by: Petr Štetiar <ynezz@true.cz>
-rw-r--r--uci.h6
1 files changed, 1 insertions, 5 deletions
diff --git a/uci.h b/uci.h
index 43f2052..b385e2b 100644
--- a/uci.h
+++ b/uci.h
@@ -34,6 +34,7 @@ extern "C" {
#include <setjmp.h>
#include <stdio.h>
#include <stdint.h>
+#include <stddef.h>
#define UCI_CONFDIR "/etc/config"
#define UCI_SAVEDIR "/tmp/.uci"
@@ -509,11 +510,6 @@ struct uci_parse_option {
};
-/* linked list handling */
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.