diff options
author | Michal Zidek <mzidek@redhat.com> | 2013-09-10 23:09:04 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-12-10 12:04:50 +0100 |
commit | 8bf65dbab8703697c85b033beb5c189fce17b036 (patch) | |
tree | eb99c28b6e004fc6c05ede4a7cdc30569cce7dbf /src/util | |
parent | 65f4003b93157b32eb0dcd6955d37dd009dc960e (diff) | |
download | sssd-8bf65dbab8703697c85b033beb5c189fce17b036.tar.gz sssd-8bf65dbab8703697c85b033beb5c189fce17b036.tar.xz sssd-8bf65dbab8703697c85b033beb5c189fce17b036.zip |
Properly align buffer when storing pointers.
Properly align buffer address to sizeof(char *) when storing
pointers to strings.
resolves:
https://fedorahosted.org/sssd/ticket/1359
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/util_safealign.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/util_safealign.h b/src/util/util_safealign.h index c39ba159b..685d65966 100644 --- a/src/util/util_safealign.h +++ b/src/util/util_safealign.h @@ -32,6 +32,16 @@ #include <string.h> #include <stdint.h> +/* Use this macro to suppress alignment warnings (use it + * only to suppress false-positives) */ +#define DISCARD_ALIGN(ptr) ((void *)(ptr)) + +#define IS_ALIGNED(ptr, type) \ + ((uintptr_t)(ptr) % sizeof(type) == 0) + +#define PADDING_SIZE(base, type) \ + ((sizeof(type) - ((base) % sizeof(type))) % sizeof(type)) + #define SIZE_T_OVERFLOW(current, add) \ (((size_t)(add)) > (SIZE_MAX - ((size_t)(current)))) |