From: Dmitry V. Levin Date: Mon, 18 Mar 2019 02:40:16 +0000 (+0000) Subject: Fix preprocessor indentation X-Git-Tag: v5.0~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e84debd3c00ee2d7969e0704759f356bf7839c4a;p=strace Fix preprocessor indentation Indent the C preprocessor directives to reflect their nesting using the following script: $ cppi -l $(git grep -El '^[[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif|else|endif|define|pragma)[[:space:]]' |grep -v '\.sh$') |while read f; do cppi < "$f" > "$f".cppi; mv "$f".cppi "$f" done --- diff --git a/linux/s390/rt_sigframe.h b/linux/s390/rt_sigframe.h index 51819b7b..df17b868 100644 --- a/linux/s390/rt_sigframe.h +++ b/linux/s390/rt_sigframe.h @@ -10,11 +10,11 @@ # include -#ifdef __s390x__ -# define SIGNAL_FRAMESIZE 160 -#else /* __s390__ */ -# define SIGNAL_FRAMESIZE 96 -#endif +# ifdef __s390x__ +# define SIGNAL_FRAMESIZE 160 +# else /* __s390__ */ +# define SIGNAL_FRAMESIZE 96 +# endif typedef struct { uint8_t callee_used_stack[SIGNAL_FRAMESIZE]; diff --git a/list.h b/list.h index cf68fa78..98563e4d 100644 --- a/list.h +++ b/list.h @@ -8,7 +8,7 @@ */ #ifndef STRACE_LIST_H -#define STRACE_LIST_H +# define STRACE_LIST_H /* * struct list_item and related macros and functions provide an interface @@ -87,7 +87,7 @@ * https://lwn.net/Articles/336255/ */ -#include "macros.h" +# include "macros.h" struct list_item { struct list_item *prev; @@ -99,7 +99,7 @@ struct list_item { * * @param l_ List head variable name. */ -#define EMPTY_LIST(l_) struct list_item l_ = { &l_, &l_ } +# define EMPTY_LIST(l_) struct list_item l_ = { &l_, &l_ } /** Initialise an empty list. */ static inline void @@ -130,7 +130,7 @@ list_is_empty(const struct list_item *l) * @param type Type of the list's item. * @param field Name of the field that holds the respective struct list_item. */ -#define list_elem(var, type, field) containerof((var), type, field) +# define list_elem(var, type, field) containerof((var), type, field) /** * Get the first element in a list. @@ -139,7 +139,7 @@ list_is_empty(const struct list_item *l) * @param type Type of the list's item. * @param field Name of the field that holds the respective struct list_item. */ -#define list_head(head, type, field) \ +# define list_head(head, type, field) \ (list_is_empty(head) ? NULL : list_elem((head)->next, type, field)) /** * Get the last element in a list. @@ -148,7 +148,7 @@ list_is_empty(const struct list_item *l) * @param type Type of the list's item. * @param field Name of the field that holds the respective struct list_item. */ -#define list_tail(head, type, field) \ +# define list_tail(head, type, field) \ (list_is_empty(head) ? NULL : list_elem((head)->prev, type, field)) /** @@ -157,7 +157,7 @@ list_is_empty(const struct list_item *l) * @param var Pointer to a list item. * @param field Name of the field that holds the respective struct list_item. */ -#define list_next(var, field) \ +# define list_next(var, field) \ list_elem((var)->field.next, typeof(*(var)), field) /** * Get the previous element in a list. @@ -165,7 +165,7 @@ list_is_empty(const struct list_item *l) * @param var Pointer to a list item. * @param field Name of the field that holds the respective struct list_item. */ -#define list_prev(var, field) \ +# define list_prev(var, field) \ list_elem((var)->field.prev, typeof(*(var)), field) /** @@ -279,7 +279,7 @@ list_replace(struct list_item *old, struct list_item *new) * @param field_ Name of the field containing the respective struct list_item * inside list items. */ -#define list_foreach(var_, head_, field_) \ +# define list_foreach(var_, head_, field_) \ for (var_ = list_elem((head_)->next, typeof(*var_), field_); \ &(var_->field_) != (head_); var_ = list_next(var_, field_)) @@ -292,7 +292,7 @@ list_replace(struct list_item *old, struct list_item *new) * inside list items. * @param _tmp Temporary variable for storing pointer to the next item. */ -#define list_foreach_safe(var_, head_, field_, _tmp) \ +# define list_foreach_safe(var_, head_, field_, _tmp) \ for (var_ = list_elem((head_)->next, typeof(*var_), field_), \ _tmp = list_elem((var_)->field_.next, typeof(*var_), field_); \ &var_->field_ != head_; var_ = _tmp, _tmp = list_next(_tmp, field_)) diff --git a/macros.h b/macros.h index 11fef3b3..264bc20e 100644 --- a/macros.h +++ b/macros.h @@ -41,12 +41,12 @@ (offsetof(type_, member_) + sizeof(((type_ *)0)->member_)) # endif -#ifndef cast_ptr -# define cast_ptr(type_, var_) \ +# ifndef cast_ptr +# define cast_ptr(type_, var_) \ ((type_) (uintptr_t) (const volatile void *) (var_)) -#endif +# endif -#ifndef containerof +# ifndef containerof /** * Return a pointer to a structure that contains the provided variable. * @@ -55,10 +55,10 @@ * @param member_ Name of the member field. * @return Pointer to the container structure. */ -# define containerof(ptr_, struct_, member_) \ +# define containerof(ptr_, struct_, member_) \ cast_ptr(struct_ *, \ (const volatile char *) (ptr_) - offsetof(struct_, member_)) -#endif +# endif static inline bool is_filled(const char *ptr, char fill, size_t size) diff --git a/print_fields.h b/print_fields.h index 1e261ddc..99f32a1e 100644 --- a/print_fields.h +++ b/print_fields.h @@ -177,7 +177,7 @@ print_x25_addr(&(where_).field_); \ } while (0) -#define PRINT_FIELD_NET_PORT(prefix_, where_, field_) \ +# define PRINT_FIELD_NET_PORT(prefix_, where_, field_) \ do { \ STRACE_PRINTF("%s%s=", (prefix_), #field_); \ \ diff --git a/tests/move_pages.c b/tests/move_pages.c index 2f88f792..66ab3be8 100644 --- a/tests/move_pages.c +++ b/tests/move_pages.c @@ -106,16 +106,16 @@ print_status_array(const int *const status, const unsigned long count) if (status[i] >= 0) { printf("%d", status[i]); } else { -#if !XLAT_RAW +# if !XLAT_RAW errno = -status[i]; -#endif -#if XLAT_RAW +# endif +# if XLAT_RAW printf("%d", status[i]); -#elif XLAT_VERBOSE +# elif XLAT_VERBOSE printf("%d /* -%s */", status[i], errno2name()); -#else +# else printf("-%s", errno2name()); -#endif +# endif } } printf("]"); @@ -141,13 +141,13 @@ print_stat_pages(const unsigned long pid, const unsigned long count, } else { print_status_array(status, count); } -#if XLAT_RAW +# if XLAT_RAW printf(", 0x2) = %s\n", errstr); -#elif XLAT_VERBOSE +# elif XLAT_VERBOSE printf(", 0x2 /* MPOL_MF_MOVE */) = %s\n", errstr); -#else /* XLAT_ABBREV */ +# else /* XLAT_ABBREV */ printf(", MPOL_MF_MOVE) = %s\n", errstr); -#endif +# endif } static void @@ -173,13 +173,13 @@ print_move_pages(const unsigned long pid, printf("%p", status); else printf("[]"); -#if XLAT_RAW +# if XLAT_RAW printf(", 0x4) = %s\n", errstr); -#elif XLAT_VERBOSE +# elif XLAT_VERBOSE printf(", 0x4 /* MPOL_MF_MOVE_ALL */) = %s\n", errstr); -#else /* XLAT_ABBREV */ +# else /* XLAT_ABBREV */ printf(", MPOL_MF_MOVE_ALL) = %s\n", errstr); -#endif +# endif } int