summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-05-11 22:13:10 +0200
committerChristian Grothoff <christian@grothoff.org>2019-05-11 22:13:10 +0200
commitdc4902a536daa8e46dbbd79a9fa98498b5e848b3 (patch)
tree7b4b8e5ff939b2642724ce3fa642b3508a1b8a96
parentbc32b1f4b64ab0897efc1fe3125c5748e17cb561 (diff)
reindenting
-rw-r--r--src/include/gnunet_common.h494
1 files changed, 325 insertions, 169 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 1f5600381..1916024b8 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -57,9 +57,8 @@
#endif
#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
}
#endif
#endif
@@ -76,14 +75,14 @@ extern "C"
* GNUNET_SYSERR`, `GNUNET_OK != GNUNET_NO`, `GNUNET_NO !=
* GNUNET_SYSERR` and finally `GNUNET_YES != GNUNET_NO`.
*/
-#define GNUNET_OK 1
+#define GNUNET_OK 1
#define GNUNET_SYSERR -1
-#define GNUNET_YES 1
-#define GNUNET_NO 0
+#define GNUNET_YES 1
+#define GNUNET_NO 0
-#define GNUNET_MIN(a,b) (((a) < (b)) ? (a) : (b))
+#define GNUNET_MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define GNUNET_MAX(a,b) (((a) > (b)) ? (a) : (b))
+#define GNUNET_MAX(a, b) (((a) > (b)) ? (a) : (b))
/* some systems use one underscore only, and mingw uses no underscore... */
#ifndef __BYTE_ORDER
@@ -117,7 +116,7 @@ extern "C"
/**
* wrap va_arg for enums
*/
-#define GNUNET_VA_ARG_ENUM(va,X) ((enum X) va_arg (va, int))
+#define GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int))
/**
@@ -133,37 +132,37 @@ extern "C"
* Endian operations
*/
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-# define GNUNET_htobe16(x) __bswap_16 (x)
-# define GNUNET_htole16(x) (x)
-# define GNUNET_be16toh(x) __bswap_16 (x)
-# define GNUNET_le16toh(x) (x)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define GNUNET_htobe16(x) __bswap_16 (x)
+#define GNUNET_htole16(x) (x)
+#define GNUNET_be16toh(x) __bswap_16 (x)
+#define GNUNET_le16toh(x) (x)
-# define GNUNET_htobe32(x) __bswap_32 (x)
-# define GNUNET_htole32(x) (x)
-# define GNUNET_be32toh(x) __bswap_32 (x)
-# define GNUNET_le32toh(x) (x)
+#define GNUNET_htobe32(x) __bswap_32 (x)
+#define GNUNET_htole32(x) (x)
+#define GNUNET_be32toh(x) __bswap_32 (x)
+#define GNUNET_le32toh(x) (x)
-# define GNUNET_htobe64(x) __bswap_64 (x)
-# define GNUNET_htole64(x) (x)
-# define GNUNET_be64toh(x) __bswap_64 (x)
-# define GNUNET_le64toh(x) (x)
+#define GNUNET_htobe64(x) __bswap_64 (x)
+#define GNUNET_htole64(x) (x)
+#define GNUNET_be64toh(x) __bswap_64 (x)
+#define GNUNET_le64toh(x) (x)
#endif
-# if __BYTE_ORDER == __BIG_ENDIAN
-# define GNUNET_htobe16(x) (x)
-# define GNUNET_htole16(x) __bswap_16 (x)
-# define GNUNET_be16toh(x) (x)
-# define GNUNET_le16toh(x) __bswap_16 (x)
-
-# define GNUNET_htobe32(x) (x)
-# define GNUNET_htole32(x) __bswap_32 (x)
-# define GNUNET_be32toh(x) (x)
-# define GNUNET_le32toh(x) __bswap_32 (x)
-
-# define GNUNET_htobe64(x) (x)
-# define GNUNET_htole64(x) __bswap_64 (x)
-# define GNUNET_be64toh(x) (x)
-# define GNUNET_le64toh(x) __bswap_64 (x)
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define GNUNET_htobe16(x) (x)
+#define GNUNET_htole16(x) __bswap_16 (x)
+#define GNUNET_be16toh(x) (x)
+#define GNUNET_le16toh(x) __bswap_16 (x)
+
+#define GNUNET_htobe32(x) (x)
+#define GNUNET_htole32(x) __bswap_32 (x)
+#define GNUNET_be32toh(x) (x)
+#define GNUNET_le32toh(x) __bswap_32 (x)
+
+#define GNUNET_htobe64(x) (x)
+#define GNUNET_htole64(x) __bswap_64 (x)
+#define GNUNET_be64toh(x) (x)
+#define GNUNET_le64toh(x) __bswap_64 (x)
#endif
@@ -179,19 +178,19 @@ extern "C"
* on the stack with a variable-length that might be zero, write
* "int[GNUNET_NZL(n)] x;" instead of "int[n] x".
*/
-#define GNUNET_NZL(l) GNUNET_MAX(1,l)
+#define GNUNET_NZL(l) GNUNET_MAX (1, l)
/**
* gcc-ism to get packed structs.
*/
-#define GNUNET_PACKED __attribute__((packed))
+#define GNUNET_PACKED __attribute__ ((packed))
/**
* gcc-ism to get gcc bitfield layout when compiling with -mms-bitfields
*/
#if MINGW
-#define GNUNET_GCC_STRUCT_LAYOUT __attribute__((gcc_struct))
+#define GNUNET_GCC_STRUCT_LAYOUT __attribute__ ((gcc_struct))
#else
#define GNUNET_GCC_STRUCT_LAYOUT
#endif
@@ -202,20 +201,20 @@ extern "C"
* bug #33594.
*/
#ifdef __BIGGEST_ALIGNMENT__
-#define GNUNET_ALIGN __attribute__((aligned (__BIGGEST_ALIGNMENT__)))
+#define GNUNET_ALIGN __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)))
#else
-#define GNUNET_ALIGN __attribute__((aligned (8)))
+#define GNUNET_ALIGN __attribute__ ((aligned (8)))
#endif
/**
* gcc-ism to document unused arguments
*/
-#define GNUNET_UNUSED __attribute__((unused))
+#define GNUNET_UNUSED __attribute__ ((unused))
/**
* gcc-ism to document functions that don't return
*/
-#define GNUNET_NORETURN __attribute__((noreturn))
+#define GNUNET_NORETURN __attribute__ ((noreturn))
#if MINGW
#if __GNUC__ > 3
@@ -225,9 +224,7 @@ extern "C"
* so we *only* use this on W32 (see #670578 from Debian); fortunately,
* W32 doesn't run on sparc anyway.
*/
-#define GNUNET_NETWORK_STRUCT_BEGIN \
- _Pragma("pack(push)") \
- _Pragma("pack(1)")
+#define GNUNET_NETWORK_STRUCT_BEGIN _Pragma ("pack(push)") _Pragma ("pack(1)")
/**
* gcc 4.x-ism to pack structures even on W32 (to be used after structs)
@@ -235,7 +232,7 @@ extern "C"
* so we *only* use this on W32 (see #670578 from Debian); fortunately,
* W32 doesn't run on sparc anyway.
*/
-#define GNUNET_NETWORK_STRUCT_END _Pragma("pack(pop)")
+#define GNUNET_NETWORK_STRUCT_END _Pragma ("pack(pop)")
#else
#error gcc 4.x or higher required on W32 systems
@@ -261,22 +258,20 @@ GNUNET_NETWORK_STRUCT_BEGIN
*/
struct GNUNET_HashCode
{
- uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */
+ uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */
};
-
/**
* @brief A 256-bit hashcode. Used under special conditions, like when space
* is critical and security is not impacted by it.
*/
struct GNUNET_ShortHashCode
{
- uint32_t bits[256 / 8 / sizeof (uint32_t)]; /* = 8 */
+ uint32_t bits[256 / 8 / sizeof (uint32_t)]; /* = 8 */
};
-
/**
* Header for all communications.
*/
@@ -293,7 +288,6 @@ struct GNUNET_MessageHeader
* The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
*/
uint16_t type GNUNET_PACKED;
-
};
@@ -325,7 +319,7 @@ struct GNUNET_OperationResultMessage
*/
struct GNUNET_AsyncScopeId
{
- uint32_t bits[16 / sizeof (uint32_t)]; /* = 16 bytes */
+ uint32_t bits[16 / sizeof (uint32_t)]; /* = 16 bytes */
};
GNUNET_NETWORK_STRUCT_END
@@ -334,7 +328,8 @@ GNUNET_NETWORK_STRUCT_END
/**
* Saved async scope identifier or root scope.
*/
-struct GNUNET_AsyncScopeSave {
+struct GNUNET_AsyncScopeSave
+{
/**
* Saved scope. Unused if 'have_scope==GNUNET_NO'.
*/
@@ -356,9 +351,7 @@ struct GNUNET_AsyncScopeSave {
* #GNUNET_NO to stop iteration with no error,
* #GNUNET_SYSERR to abort iteration with error!
*/
-typedef int
-(*GNUNET_FileNameCallback) (void *cls,
- const char *filename);
+typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename);
/**
@@ -366,8 +359,7 @@ typedef int
*
* @param cls Closure.
*/
-typedef void
-(*GNUNET_ContinuationCallback) (void *cls);
+typedef void (*GNUNET_ContinuationCallback) (void *cls);
/**
@@ -382,9 +374,10 @@ typedef void
* @param data_size
* Size of @a data.
*/
-typedef void
-(*GNUNET_ResultCallback) (void *cls, int64_t result_code,
- const void *data, uint16_t data_size);
+typedef void (*GNUNET_ResultCallback) (void *cls,
+ int64_t result_code,
+ const void *data,
+ uint16_t data_size);
/* ****************************** logging ***************************** */
@@ -420,12 +413,11 @@ enum GNUNET_ErrorType
* @param date when was the message logged?
* @param message what is the message
*/
-typedef void
-(*GNUNET_Logger) (void *cls,
- enum GNUNET_ErrorType kind,
- const char *component,
- const char *date,
- const char *message);
+typedef void (*GNUNET_Logger) (void *cls,
+ enum GNUNET_ErrorType kind,
+ const char *component,
+ const char *date,
+ const char *message);
/**
@@ -438,7 +430,7 @@ int
GNUNET_get_log_skip (void);
-#if !defined(GNUNET_CULL_LOGGING)
+#if ! defined(GNUNET_CULL_LOGGING)
int
GNUNET_get_log_call_status (int caller_level,
const char *comp,
@@ -462,23 +454,23 @@ GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...)
/* from glib */
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
-#define _GNUNET_BOOLEAN_EXPR(expr) \
- __extension__ ({ \
- int _gnunet_boolean_var_; \
- if (expr) \
- _gnunet_boolean_var_ = 1; \
- else \
- _gnunet_boolean_var_ = 0; \
- _gnunet_boolean_var_; \
-})
-#define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR(expr), 1))
-#define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR(expr), 0))
+#define _GNUNET_BOOLEAN_EXPR(expr) \
+ __extension__({ \
+ int _gnunet_boolean_var_; \
+ if (expr) \
+ _gnunet_boolean_var_ = 1; \
+ else \
+ _gnunet_boolean_var_ = 0; \
+ _gnunet_boolean_var_; \
+ })
+#define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1))
+#define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0))
#else
#define GN_LIKELY(expr) (expr)
#define GN_UNLIKELY(expr) (expr)
#endif
-#if !defined(GNUNET_LOG_CALL_STATUS)
+#if ! defined(GNUNET_LOG_CALL_STATUS)
#define GNUNET_LOG_CALL_STATUS -1
#endif
@@ -494,35 +486,65 @@ GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...)
* @param ... arguments for format string
*/
void
-GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp,
- const char *message, ...);
-
-#if !defined(GNUNET_CULL_LOGGING)
-#define GNUNET_log_from(kind,comp,...) do { int log_line = __LINE__;\
- static int log_call_enabled = GNUNET_LOG_CALL_STATUS;\
- if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) { \
- if (GN_UNLIKELY(log_call_enabled == -1))\
- log_call_enabled = GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), (comp), __FILE__, __FUNCTION__, log_line); \
- if (GN_UNLIKELY(GNUNET_get_log_skip () > 0)) { GNUNET_log_skip (-1, GNUNET_NO); }\
- else {\
- if (GN_UNLIKELY(log_call_enabled))\
- GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
- }\
- }\
-} while (0)
-
- #define GNUNET_log(kind,...) do { int log_line = __LINE__;\
- static int log_call_enabled = GNUNET_LOG_CALL_STATUS;\
- if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) { \
- if (GN_UNLIKELY(log_call_enabled == -1))\
- log_call_enabled = GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), NULL, __FILE__, __FUNCTION__, log_line);\
- if (GN_UNLIKELY(GNUNET_get_log_skip () > 0)) { GNUNET_log_skip (-1, GNUNET_NO); }\
- else {\
- if (GN_UNLIKELY(log_call_enabled))\
- GNUNET_log_nocheck ((kind), __VA_ARGS__); \
- }\
- }\
-} while (0)
+GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
+ const char *comp,
+ const char *message,
+ ...);
+
+#if ! defined(GNUNET_CULL_LOGGING)
+#define GNUNET_log_from(kind, comp, ...) \
+ do \
+ { \
+ int log_line = __LINE__; \
+ static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
+ if ((GNUNET_EXTRA_LOGGING > 0) || \
+ ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
+ { \
+ if (GN_UNLIKELY (log_call_enabled == -1)) \
+ log_call_enabled = \
+ GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
+ (comp), \
+ __FILE__, \
+ __FUNCTION__, \
+ log_line); \
+ if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
+ { \
+ GNUNET_log_skip (-1, GNUNET_NO); \
+ } \
+ else \
+ { \
+ if (GN_UNLIKELY (log_call_enabled)) \
+ GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
+ } \
+ } \
+ } while (0)
+
+#define GNUNET_log(kind, ...) \
+ do \
+ { \
+ int log_line = __LINE__; \
+ static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
+ if ((GNUNET_EXTRA_LOGGING > 0) || \
+ ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
+ { \
+ if (GN_UNLIKELY (log_call_enabled == -1)) \
+ log_call_enabled = \
+ GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
+ NULL, \
+ __FILE__, \
+ __FUNCTION__, \
+ log_line); \
+ if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
+ { \
+ GNUNET_log_skip (-1, GNUNET_NO); \
+ } \
+ else \
+ { \
+ if (GN_UNLIKELY (log_call_enabled)) \
+ GNUNET_log_nocheck ((kind), __VA_ARGS__); \
+ } \
+ } \
+ } while (0)
#else
#define GNUNET_log(...)
#define GNUNET_log_from(...)
@@ -539,8 +561,8 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp,
*/
void
GNUNET_log_config_missing (enum GNUNET_ErrorType kind,
- const char *section,
- const char *option);
+ const char *section,
+ const char *option);
/**
@@ -554,9 +576,9 @@ GNUNET_log_config_missing (enum GNUNET_ErrorType kind,
*/
void
GNUNET_log_config_invalid (enum GNUNET_ErrorType kind,
- const char *section,
- const char *option,
- const char *required);
+ const char *section,
+ const char *option,
+ const char *required);
/**
@@ -577,8 +599,7 @@ GNUNET_abort_ (void) GNUNET_NORETURN;
* @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero
*/
void
-GNUNET_log_skip (int n,
- int check_reset);
+GNUNET_log_skip (int n, int check_reset);
/**
@@ -591,9 +612,7 @@ GNUNET_log_skip (int n,
* @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened
*/
int
-GNUNET_log_setup (const char *comp,
- const char *loglevel,
- const char *logfile);
+GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile);
/**
@@ -607,8 +626,7 @@ GNUNET_log_setup (const char *comp,
* @param logger_cls closure for @a logger
*/
void
-GNUNET_logger_add (GNUNET_Logger logger,
- void *logger_cls);
+GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
/**
@@ -619,8 +637,7 @@ GNUNET_logger_add (GNUNET_Logger logger,
* @param logger_cls closure for @a logger
*/
void
-GNUNET_logger_remove (GNUNET_Logger logger,
- void *logger_cls);
+GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
/**
@@ -798,8 +815,7 @@ GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid);
* will be overwritten by next call to #GNUNET_a2s().
*/
const char *
-GNUNET_a2s (const struct sockaddr *addr,
- socklen_t addrlen);
+GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen);
/**
@@ -817,14 +833,36 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
* @ingroup logging
* Use this for fatal errors that cannot be handled
*/
-#define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d. Aborting.\n"), __FILE__, __LINE__); GNUNET_abort_(); } } while(0)
+#define GNUNET_assert(cond) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
+ _ ("Assertion failed at %s:%d. Aborting.\n"), \
+ __FILE__, \
+ __LINE__); \
+ GNUNET_abort_ (); \
+ } \
+ } while (0)
/**
* @ingroup logging
* Use this for fatal errors that cannot be handled
*/
-#define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d. Aborting.\n"), f, l); GNUNET_abort_(); } } while(0)
+#define GNUNET_assert_at(cond, f, l) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
+ _ ("Assertion failed at %s:%d. Aborting.\n"), \
+ f, \
+ l); \
+ GNUNET_abort_ (); \
+ } \
+ } while (0)
/**
@@ -834,7 +872,19 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
* @param cond Condition to evaluate
* @param comp Component string to use for logging
*/
-#define GNUNET_assert_from(cond, comp) do { if (! (cond)) { GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, comp, _("Assertion failed at %s:%d. Aborting.\n"), __FILE__, __LINE__); GNUNET_abort_(); } } while(0)
+#define GNUNET_assert_from(cond, comp) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \
+ comp, \
+ _ ("Assertion failed at %s:%d. Aborting.\n"), \
+ __FILE__, \
+ __LINE__); \
+ GNUNET_abort_ (); \
+ } \
+ } while (0)
/**
@@ -842,7 +892,17 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
* Use this for internal assertion violations that are
* not fatal (can be handled) but should not occur.
*/
-#define GNUNET_break(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); } } while(0)
+#define GNUNET_break(cond) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
+ _ ("Assertion failed at %s:%d.\n"), \
+ __FILE__, \
+ __LINE__); \
+ } \
+ } while (0)
/**
@@ -854,7 +914,17 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
* we still want to see these problems during
* development and testing. "OP == other peer".
*/
-#define GNUNET_break_op(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, _("External protocol violation detected at %s:%d.\n"), __FILE__, __LINE__); } } while(0)
+#define GNUNET_break_op(cond) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \
+ _ ("External protocol violation detected at %s:%d.\n"), \
+ __FILE__, \
+ __LINE__); \
+ } \
+ } while (0)
/**
@@ -863,7 +933,16 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
* a failure of the command 'cmd' with the message given
* by strerror(errno).
*/
-#define GNUNET_log_strerror(level, cmd) do { GNUNET_log(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0)
+#define GNUNET_log_strerror(level, cmd) \
+ do \
+ { \
+ GNUNET_log (level, \
+ _ ("`%s' failed at %s:%d with error: %s\n"), \
+ cmd, \
+ __FILE__, \
+ __LINE__, \
+ STRERROR (errno)); \
+ } while (0)
/**
@@ -872,7 +951,17 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
* a failure of the command 'cmd' with the message given
* by strerror(errno).
*/
-#define GNUNET_log_from_strerror(level, component, cmd) do { GNUNET_log_from (level, component, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0)
+#define GNUNET_log_from_strerror(level, component, cmd) \
+ do \
+ { \
+ GNUNET_log_from (level, \
+ component, \
+ _ ("`%s' failed at %s:%d with error: %s\n"), \
+ cmd, \
+ __FILE__, \
+ __LINE__, \
+ STRERROR (errno)); \
+ } while (0)
/**
@@ -881,7 +970,17 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
* a failure of the command 'cmd' with the message given
* by strerror(errno).
*/
-#define GNUNET_log_strerror_file(level, cmd, filename) do { GNUNET_log(level, _("`%s' failed on file `%s' at %s:%d with error: %s\n"), cmd, filename, __FILE__, __LINE__, STRERROR(errno)); } while(0)
+#define GNUNET_log_strerror_file(level, cmd, filename) \
+ do \
+ { \
+ GNUNET_log (level, \
+ _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
+ cmd, \
+ filename, \
+ __FILE__, \
+ __LINE__, \
+ STRERROR (errno)); \
+ } while (0)
/**
@@ -890,7 +989,18 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
* a failure of the command 'cmd' with the message given
* by strerror(errno).
*/
-#define GNUNET_log_from_strerror_file(level, component, cmd, filename) do { GNUNET_log_from (level, component, _("`%s' failed on file `%s' at %s:%d with error: %s\n"), cmd, filename,__FILE__, __LINE__, STRERROR(errno)); } while(0)
+#define GNUNET_log_from_strerror_file(level, component, cmd, filename) \
+ do \
+ { \
+ GNUNET_log_from (level, \
+ component, \
+ _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
+ cmd, \
+ filename, \
+ __FILE__, \
+ __LINE__, \
+ STRERROR (errno)); \
+ } while (0)
/* ************************* endianess conversion ****************** */
@@ -965,12 +1075,12 @@ GNUNET_ntoh_double (double d);
* Compare memory in @a a and @a b, where both must be of
* the same pointer type.
*/
-#define GNUNET_memcmp(a,b) ({ \
- const typeof(*b) * _a = (a); \
- const typeof(*a) * _b = (b); \
- memcmp(_a, \
- _b, \
- sizeof (*a)); })
+#define GNUNET_memcmp(a, b) \
+ ({ \
+ const typeof (*b) *_a = (a); \
+ const typeof (*a) *_b = (b); \
+ memcmp (_a, _b, sizeof (*a)); \
+ })
/**
@@ -979,11 +1089,11 @@ GNUNET_ntoh_double (double d);
* @param a pointer to a struct which should be tested for the
* entire memory being zero'ed out.
*/
-#define GNUNET_is_zero(a) ({ \
- static const typeof(*a) _z; \
- memcmp((a), \
- &_z, \
- sizeof (_z)); })
+#define GNUNET_is_zero(a) \
+ ({ \
+ static const typeof (*a) _z; \
+ memcmp ((a), &_z, sizeof (_z)); \
+ })
/**
@@ -995,7 +1105,14 @@ GNUNET_ntoh_double (double d);
* @param src source of the copy, may be NULL if @a n is zero
* @param n number of bytes to copy
*/
-#define GNUNET_memcpy(dst,src,n) do { if (0 != n) { (void) memcpy (dst,src,n); } } while (0)
+#define GNUNET_memcpy(dst, src, n) \
+ do \
+ { \
+ if (0 != n) \
+ { \
+ (void) memcpy (dst, src, n); \
+ } \
+ } while (0)
/**
@@ -1018,7 +1135,8 @@ GNUNET_ntoh_double (double d);
* @param m size of the second dimension
* @param type name of the struct or union, i.e. pass 'struct Foo'.
*/
-#define GNUNET_new_array_2d(n, m, type) (type **) GNUNET_xnew_array_2d_ (n, m, sizeof (type), __FILE__, __LINE__)
+#define GNUNET_new_array_2d(n, m, type) \
+ (type **) GNUNET_xnew_array_2d_ (n, m, sizeof (type), __FILE__, __LINE__)
/**
* @ingroup memory
@@ -1030,7 +1148,8 @@ GNUNET_ntoh_double (double d);
* @param o size of the third dimension
* @param type name of the struct or union, i.e. pass 'struct Foo'.
*/
-#define GNUNET_new_array_3d(n, m, o, type) (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof (type), __FILE__, __LINE__)
+#define GNUNET_new_array_3d(n, m, o, type) \
+ (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof (type), __FILE__, __LINE__)
/**
* @ingroup memory
@@ -1041,7 +1160,7 @@ GNUNET_ntoh_double (double d);
* smaller than 40 MB.
* @return pointer to size bytes of memory, never NULL (!)
*/
-#define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__)
+#define GNUNET_malloc(size) GNUNET_xmalloc_ (size, __FILE__, __LINE__)
/**
* @ingroup memory
@@ -1051,7 +1170,7 @@ GNUNET_ntoh_double (double d);
* @param size the number of bytes in buf (and size of the allocation)
* @return pointer to size bytes of memory, never NULL (!)
*/
-#define GNUNET_memdup(buf,size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE__)
+#define GNUNET_memdup(buf, size) GNUNET_xmemdup_ (buf, size, __FILE__, __LINE__)
/**
* @ingroup memory
@@ -1061,7 +1180,8 @@ GNUNET_ntoh_double (double d);
* @param size the number of bytes to allocate
* @return pointer to size bytes of memory, NULL if we do not have enough memory
*/
-#define GNUNET_malloc_large(size) GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__)
+#define GNUNET_malloc_large(size) \
+ GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__)
/**
* @ingroup memory
@@ -1072,7 +1192,8 @@ GNUNET_ntoh_double (double d);
* @param size the number of bytes to reallocate
* @return pointer to size bytes of memory
*/
-#define GNUNET_realloc(ptr, size) GNUNET_xrealloc_(ptr, size, __FILE__, __LINE__)
+#define GNUNET_realloc(ptr, size) \
+ GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__)
/**
* @ingroup memory
@@ -1083,7 +1204,7 @@ GNUNET_ntoh_double (double d);
* @param ptr location where to free the memory. ptr must have
* been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier.
*/
-#define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__)
+#define GNUNET_free(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__)
/**
* @ingroup memory
@@ -1092,7 +1213,15 @@ GNUNET_ntoh_double (double d);
*
* @param ptr the location in memory to free
*/
-#define GNUNET_free_non_null(ptr) do { void * __x__ = ptr; if (__x__ != NULL) { GNUNET_free(__x__); } } while(0)
+#define GNUNET_free_non_null(ptr) \
+ do \
+ { \
+ void *__x__ = ptr; \
+ if (__x__ != NULL) \
+ { \
+ GNUNET_free (__x__); \
+ } \
+ } while (0)
/**
* @ingroup memory
@@ -1102,7 +1231,7 @@ GNUNET_ntoh_double (double d);
* @param a pointer to a zero-terminated string
* @return a copy of the string including zero-termination
*/
-#define GNUNET_strdup(a) GNUNET_xstrdup_(a,__FILE__,__LINE__)
+#define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__)
/**
* @ingroup memory
@@ -1113,7 +1242,8 @@ GNUNET_ntoh_double (double d);
* @param length of the string to duplicate
* @return a partial copy of the string including zero-termination
*/
-#define GNUNET_strndup(a,length) GNUNET_xstrndup_(a,length,__FILE__,__LINE__)
+#define GNUNET_strndup(a, length) \
+ GNUNET_xstrndup_ (a, length, __FILE__, __LINE__)
/**
* @ingroup memory
@@ -1150,7 +1280,13 @@ GNUNET_ntoh_double (double d);
* @param tsize the target size for the resulting vector, use 0 to
* free the vector (then, arr will be NULL afterwards).
*/
-#define GNUNET_array_grow(arr,size,tsize) GNUNET_xgrow_((void**)&(arr), sizeof((arr)[0]), &size, tsize, __FILE__, __LINE__)
+#define GNUNET_array_grow(arr, size, tsize) \
+ GNUNET_xgrow_ ((void **) &(arr), \
+ sizeof ((arr)[0]), \
+ &size, \
+ tsize, \
+ __FILE__, \
+ __LINE__)
/**
* @ingroup memory
@@ -1165,7 +1301,12 @@ GNUNET_ntoh_double (double d);
* array size
* @param element the element that will be appended to the array
*/
-#define GNUNET_array_append(arr,size,element) do { GNUNET_array_grow(arr,size,size+1); (arr)[size-1] = element; } while(0)
+#define GNUNET_array_append(arr, size, element) \
+ do \
+ { \
+ GNUNET_array_grow (arr, size, size + 1); \
+ (arr)[size - 1] = element; \
+ } while (0)
/**
* @ingroup memory
@@ -1226,8 +1367,11 @@ GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
* @return allocated memory, never NULL
*/
void **
-GNUNET_xnew_array_2d_ (size_t n, size_t m, size_t elementSize,
- const char *filename, int linenumber);
+GNUNET_xnew_array_2d_ (size_t n,
+ size_t m,
+ size_t elementSize,
+ const char *filename,
+ int linenumber);
/**
@@ -1246,8 +1390,12 @@ GNUNET_xnew_array_2d_ (size_t n, size_t m, size_t elementSize,
* @return allocated memory, never NULL
*/
void ***
-GNUNET_xnew_array_3d_ (size_t n, size_t m, size_t o, size_t elementSize,
- const char *filename, int linenumber);
+GNUNET_xnew_array_3d_ (size_t n,
+ size_t m,
+ size_t o,
+ size_t elementSize,
+ const char *filename,
+ int linenumber);
/**
@@ -1262,7 +1410,9 @@ GNUNET_xnew_array_3d_ (size_t n, size_t m, size_t o, size_t elementSize,
* @return allocated memory, never NULL
*/
void *
-GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
+GNUNET_xmemdup_ (const void *buf,
+ size_t size,
+ const char *filename,
int linenumber);
@@ -1323,7 +1473,9 @@ GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber);
* @return the duplicated string
*/
char *
-GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
+GNUNET_xstrndup_ (const char *str,
+ size_t len,
+ const char *filename,
int linenumber);
/**
@@ -1342,8 +1494,12 @@ GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
* @param linenumber line where this call is being made (for debugging)
*/
void
-GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount,
- unsigned int newCount, const char *filename, int linenumber);
+GNUNET_xgrow_ (void **old,
+ size_t elementSize,
+ unsigned int *oldCount,
+ unsigned int newCount,
+ const char *filename,
+ int linenumber);
/**
@@ -1475,7 +1631,7 @@ enum GNUNET_SCHEDULER_Priority
};
-#if 0 /* keep Emacsens' auto-indent happy */
+#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus