mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-04 21:08:14 +02:00
Add _DBUS_STATIC_ASSERT (based on GLib's G_STATIC_ASSERT) and use it
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39636 Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
This commit is contained in:
parent
70fb675a10
commit
213acdb71c
4 changed files with 12 additions and 0 deletions
|
|
@ -78,6 +78,8 @@ typedef struct
|
|||
|
||||
} DBusRealError;
|
||||
|
||||
_DBUS_STATIC_ASSERT (sizeof (DBusRealError) == sizeof (DBusError));
|
||||
|
||||
/**
|
||||
* Returns a longer message describing an error name.
|
||||
* If the error name is unknown, returns the name
|
||||
|
|
|
|||
|
|
@ -222,6 +222,8 @@ typedef struct
|
|||
int n_entries_on_init; /**< used to detect table resize since initialization */
|
||||
} DBusRealHashIter;
|
||||
|
||||
_DBUS_STATIC_ASSERT (sizeof (DBusRealHashIter) == sizeof (DBusHashIter));
|
||||
|
||||
static DBusHashEntry* find_direct_function (DBusHashTable *table,
|
||||
void *key,
|
||||
dbus_bool_t create_if_not_found,
|
||||
|
|
|
|||
|
|
@ -362,6 +362,12 @@ dbus_bool_t _dbus_read_uuid_file (const DBusString *filename,
|
|||
|
||||
dbus_bool_t _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str);
|
||||
|
||||
#define _DBUS_PASTE2(a, b) a ## b
|
||||
#define _DBUS_PASTE(a, b) _DBUS_PASTE2 (a, b)
|
||||
#define _DBUS_STATIC_ASSERT(expr) \
|
||||
typedef struct { char _assertion[(expr) ? 1 : -1]; } \
|
||||
_DBUS_PASTE (_DBUS_STATIC_ASSERT_, __LINE__)
|
||||
|
||||
DBUS_END_DECLS
|
||||
|
||||
#endif /* DBUS_INTERNALS_H */
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#ifndef DBUS_STRING_PRIVATE_H
|
||||
#define DBUS_STRING_PRIVATE_H
|
||||
|
||||
#include <dbus/dbus-internals.h>
|
||||
#include <dbus/dbus-memory.h>
|
||||
#include <dbus/dbus-types.h>
|
||||
|
||||
|
|
@ -51,6 +52,7 @@ typedef struct
|
|||
unsigned int align_offset : 3; /**< str - align_offset is the actual malloc block */
|
||||
} DBusRealString;
|
||||
|
||||
_DBUS_STATIC_ASSERT (sizeof (DBusRealString) == sizeof (DBusString));
|
||||
|
||||
/**
|
||||
* @defgroup DBusStringInternals DBusString implementation details
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue