Skip to content

Commit

Permalink
Clean up CSTYLEDs
Browse files Browse the repository at this point in the history
69 CSTYLED BEGINs remain, appx. 30 of which can be removed if cstyle(1)
had a useful policy regarding
  CALL(ARG1,
  	ARG2,
  	ARG3);
above 2 lines. As it stands, it spits out *both*
  sysctl_os.c: 385: continuation line should be indented by 4 spaces
  sysctl_os.c: 385: indent by spaces instead of tabs
which is very cool

Another >10 could be fixed by removing "ulong" &al. handling.
I don't foresee anyone actually using it intentionally
(does it even exist in modern headers? why did it in the first place?).

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes openzfs#12993
  • Loading branch information
nabijaczleweli authored and behlendorf committed Jan 26, 2022
1 parent a3fecf4 commit 7ada752
Show file tree
Hide file tree
Showing 127 changed files with 522 additions and 748 deletions.
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ cstyle:
! -name 'zfs_config.*' ! -name '*.mod.c' \
! -name 'opt_global.h' ! -name '*_if*.h' \
! -path './module/zstd/lib/*' \
! -path './include/sys/lua/*' \
! -path './module/lua/l*.[ch]' \
! -path './module/zfs/lz4.c' \
$(cstyle_line)

Expand Down
7 changes: 3 additions & 4 deletions include/os/freebsd/spl/sys/ccompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,17 @@ typedef struct {
volatile int counter;
} atomic_t;

/* BEGIN CSTYLED */
#define hlist_for_each(p, head) \
for (p = (head)->first; p; p = (p)->next)

#define hlist_entry(ptr, type, field) container_of(ptr, type, field)

#define container_of(ptr, type, member) \
/* CSTYLED */ \
({ \
const __typeof(((type *)0)->member) *__p = (ptr); \
(type *)((uintptr_t)__p - offsetof(type, member)); \
const __typeof(((type *)0)->member) *__p = (ptr); \
(type *)((uintptr_t)__p - offsetof(type, member)); \
})
/* END CSTYLED */

static inline void
hlist_add_head(struct hlist_node *n, struct hlist_head *h)
Expand Down
12 changes: 5 additions & 7 deletions include/os/freebsd/spl/sys/ctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@
#define isalnum(ch) (isalpha(ch) || isdigit(ch))
#define iscntrl(C) (uchar(C) <= 0x1f || uchar(C) == 0x7f)
#define isgraph(C) ((C) >= 0x21 && (C) <= 0x7E)
/* BEGIN CSTYLED */
#define ispunct(C) \
(((C) >= 0x21 && (C) <= 0x2F) || \
((C) >= 0x3A && (C) <= 0x40) || \
((C) >= 0x5B && (C) <= 0x60) || \
((C) >= 0x7B && (C) <= 0x7E))
/* END CSTYLED */
#define ispunct(C) \
(((C) >= 0x21 && (C) <= 0x2F) || \
((C) >= 0x3A && (C) <= 0x40) || \
((C) >= 0x5B && (C) <= 0x60) || \
((C) >= 0x7B && (C) <= 0x7E))

#endif
54 changes: 26 additions & 28 deletions include/os/freebsd/spl/sys/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,69 +64,68 @@ void spl_dumpstack(void);
#define likely(expr) expect((expr) != 0, 1)
#define unlikely(expr) expect((expr) != 0, 0)

/* BEGIN CSTYLED */
#define PANIC(fmt, a...) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, fmt, ## a)

#define VERIFY(cond) \
(void) (unlikely(!(cond)) && \
#define VERIFY(cond) \
(void) (unlikely(!(cond)) && \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"%s", "VERIFY(" #cond ") failed\n"))

#define VERIFY3B(LEFT, OP, RIGHT) do { \
#define VERIFY3B(LEFT, OP, RIGHT) do { \
const boolean_t _verify3_left = (boolean_t)(LEFT); \
const boolean_t _verify3_right = (boolean_t)(RIGHT);\
const boolean_t _verify3_right = (boolean_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"failed (%d " #OP " %d)\n", \
(boolean_t) (_verify3_left), \
(boolean_t) (_verify3_right)); \
"failed (%d " #OP " %d)\n", \
(boolean_t)(_verify3_left), \
(boolean_t)(_verify3_right)); \
} while (0)

#define VERIFY3S(LEFT, OP, RIGHT) do { \
#define VERIFY3S(LEFT, OP, RIGHT) do { \
const int64_t _verify3_left = (int64_t)(LEFT); \
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"failed (%lld " #OP " %lld)\n", \
(long long) (_verify3_left), \
(long long) (_verify3_right)); \
"failed (%lld " #OP " %lld)\n", \
(long long) (_verify3_left), \
(long long) (_verify3_right)); \
} while (0)

#define VERIFY3U(LEFT, OP, RIGHT) do { \
#define VERIFY3U(LEFT, OP, RIGHT) do { \
const uint64_t _verify3_left = (uint64_t)(LEFT); \
const uint64_t _verify3_right = (uint64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"failed (%llu " #OP " %llu)\n", \
(unsigned long long) (_verify3_left), \
(unsigned long long) (_verify3_right)); \
"failed (%llu " #OP " %llu)\n", \
(unsigned long long) (_verify3_left), \
(unsigned long long) (_verify3_right)); \
} while (0)

#define VERIFY3P(LEFT, OP, RIGHT) do { \
#define VERIFY3P(LEFT, OP, RIGHT) do { \
const uintptr_t _verify3_left = (uintptr_t)(LEFT); \
const uintptr_t _verify3_right = (uintptr_t)(RIGHT);\
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"failed (%px " #OP " %px)\n", \
(void *) (_verify3_left), \
(void *) (_verify3_right)); \
"failed (%px " #OP " %px)\n", \
(void *) (_verify3_left), \
(void *) (_verify3_right)); \
} while (0)

#define VERIFY0(RIGHT) do { \
const int64_t _verify3_left = (int64_t)(0); \
#define VERIFY0(RIGHT) do { \
const int64_t _verify3_left = (int64_t)(0); \
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left == _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(0 == " #RIGHT ") " \
"failed (0 == %lld)\n", \
(long long) (_verify3_right)); \
"VERIFY3(0 == " #RIGHT ") " \
"failed (0 == %lld)\n", \
(long long) (_verify3_right)); \
} while (0)
#define CTASSERT_GLOBAL(x) CTASSERT(x)
#define CTASSERT_GLOBAL(x) CTASSERT(x)

/*
* Debugging disabled (--disable-debug)
Expand Down Expand Up @@ -167,7 +166,6 @@ void spl_dumpstack(void);
((void)(likely(!!(A) == !!(B)) || \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"(" #A ") is equivalent to (" #B ")")))
/* END CSTYLED */

#endif /* NDEBUG */

Expand Down
35 changes: 18 additions & 17 deletions include/os/freebsd/spl/sys/mod_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@
#define ZMOD_RW CTLFLAG_RWTUN
#define ZMOD_RD CTLFLAG_RDTUN

/* BEGIN CSTYLED */
#define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc) \
SYSCTL_DECL(_vfs_ ## scope_prefix); \
SYSCTL_##type(_vfs_ ## scope_prefix, OID_AUTO, name, perm, &name_prefix ## name, 0, desc)
SYSCTL_##type(_vfs_ ## scope_prefix, OID_AUTO, name, perm, \
&name_prefix ## name, 0, desc)

#define ZFS_MODULE_PARAM_ARGS SYSCTL_HANDLER_ARGS

#define ZFS_MODULE_PARAM_CALL_IMPL(parent, name, perm, args, desc) \
SYSCTL_DECL(parent); \
SYSCTL_PROC(parent, OID_AUTO, name, perm | args, desc)

#define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, func, _, perm, desc) \
ZFS_MODULE_PARAM_CALL_IMPL(_vfs_ ## scope_prefix, name, perm, func ## _args(name_prefix ## name), desc)
#define ZFS_MODULE_PARAM_CALL( \
scope_prefix, name_prefix, name, func, _, perm, desc) \
ZFS_MODULE_PARAM_CALL_IMPL(_vfs_ ## scope_prefix, name, perm, \
func ## _args(name_prefix ## name), desc)

#define ZFS_MODULE_VIRTUAL_PARAM_CALL ZFS_MODULE_PARAM_CALL

Expand Down Expand Up @@ -96,29 +98,28 @@
CTLTYPE_STRING, NULL, 0, fletcher_4_param, "A"

#include <sys/kernel.h>
#define module_init(fn) \
#define module_init(fn) \
static void \
wrap_ ## fn(void *dummy __unused) \
{ \
fn(); \
} \
{ \
fn(); \
} \
SYSINIT(zfs_ ## fn, SI_SUB_LAST, SI_ORDER_FIRST, wrap_ ## fn, NULL)

#define module_init_early(fn) \
#define module_init_early(fn) \
static void \
wrap_ ## fn(void *dummy __unused) \
{ \
fn(); \
} \
{ \
fn(); \
} \
SYSINIT(zfs_ ## fn, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_FIRST, wrap_ ## fn, NULL)

#define module_exit(fn) \
#define module_exit(fn) \
static void \
wrap_ ## fn(void *dummy __unused) \
{ \
fn(); \
} \
{ \
fn(); \
} \
SYSUNINIT(zfs_ ## fn, SI_SUB_LAST, SI_ORDER_FIRST, wrap_ ## fn, NULL)
/* END CSTYLED */

#endif /* SPL_MOD_H */
6 changes: 2 additions & 4 deletions include/os/freebsd/spl/sys/rwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ typedef struct sx krwlock_t;
#define RW_WRITE_HELD(x) (rw_write_held((x)))
#define RW_LOCK_HELD(x) (rw_lock_held((x)))
#define RW_ISWRITER(x) (rw_iswriter(x))
/* BEGIN CSTYLED */
#define rw_init(lock, desc, type, arg) do { \
const char *_name; \
ASSERT((type) == 0 || (type) == RW_DEFAULT); \
KASSERT(((lock)->lock_object.lo_flags & LO_ALLMASK) != \
LO_EXPECTED, ("lock %s already initialized", #lock)); \
bzero((lock), sizeof(struct sx)); \
bzero((lock), sizeof (struct sx)); \
for (_name = #lock; *_name != '\0'; _name++) { \
if (*_name >= 'a' && *_name <= 'z') \
break; \
Expand All @@ -87,11 +86,10 @@ typedef struct sx krwlock_t;
#define rw_tryupgrade(lock) sx_try_upgrade(lock)
#define rw_read_held(lock) \
((lock)->sx_lock != SX_LOCK_UNLOCKED && \
((lock)->sx_lock & SX_LOCK_SHARED))
((lock)->sx_lock & SX_LOCK_SHARED))
#define rw_write_held(lock) sx_xlocked(lock)
#define rw_lock_held(lock) (rw_read_held(lock) || rw_write_held(lock))
#define rw_iswriter(lock) sx_xlocked(lock)
#define rw_owner(lock) sx_xholder(lock)

/* END CSTYLED */
#endif /* _OPENSOLARIS_SYS_RWLOCK_H_ */
2 changes: 1 addition & 1 deletion include/os/freebsd/spl/sys/sdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#define _OPENSOLARIS_SYS_SDT_H_

#include_next <sys/sdt.h>
/* BEGIN CSTYLED */
#ifdef KDTRACE_HOOKS
/* CSTYLED */
SDT_PROBE_DECLARE(sdt, , , set__error);

#define SET_ERROR(err) \
Expand Down
2 changes: 1 addition & 1 deletion include/os/freebsd/spl/sys/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ typedef u_int uint_t;
typedef u_char uchar_t;
typedef u_short ushort_t;
typedef u_long ulong_t;
typedef int minor_t;
/* END CSTYLED */
typedef int minor_t;
#ifndef _OFF64_T_DECLARED
#define _OFF64_T_DECLARED
typedef off_t off64_t;
Expand Down
30 changes: 15 additions & 15 deletions include/os/linux/kernel/linux/mod_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ typedef struct kernel_param zfs_kernel_param_t;
#define ZMOD_RW 0644
#define ZMOD_RD 0444

/* BEGIN CSTYLED */
#define INT int
#define LONG long
/* BEGIN CSTYLED */
#define UINT uint
#define ULONG ulong
#define LONG long
#define STRING charp
/* END CSTYLED */
#define STRING charp

enum scope_prefix_types {
zfs,
Expand Down Expand Up @@ -108,12 +108,11 @@ enum scope_prefix_types {
* on Linux:
* dmu_prefetch_max
*/
/* BEGIN CSTYLED */
#define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc) \
CTASSERT_GLOBAL((sizeof (scope_prefix) == sizeof (enum scope_prefix_types))); \
CTASSERT_GLOBAL( \
sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \
module_param(name_prefix ## name, type, perm); \
MODULE_PARM_DESC(name_prefix ## name, desc)
/* END CSTYLED */

/*
* Declare a module parameter / sysctl node
Expand All @@ -137,23 +136,24 @@ enum scope_prefix_types {
* on Linux:
* spa_slop_shift
*/
/* BEGIN CSTYLED */
#define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \
CTASSERT_GLOBAL((sizeof (scope_prefix) == sizeof (enum scope_prefix_types))); \
module_param_call(name_prefix ## name, setfunc, getfunc, &name_prefix ## name, perm); \
#define ZFS_MODULE_PARAM_CALL( \
scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \
CTASSERT_GLOBAL( \
sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \
module_param_call(name_prefix ## name, setfunc, getfunc, \
&name_prefix ## name, perm); \
MODULE_PARM_DESC(name_prefix ## name, desc)
/* END CSTYLED */

/*
* As above, but there is no variable with the name name_prefix ## name,
* so NULL is passed to module_param_call instead.
*/
/* BEGIN CSTYLED */
#define ZFS_MODULE_VIRTUAL_PARAM_CALL(scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \
CTASSERT_GLOBAL((sizeof (scope_prefix) == sizeof (enum scope_prefix_types))); \
#define ZFS_MODULE_VIRTUAL_PARAM_CALL( \
scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \
CTASSERT_GLOBAL(\
sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \
module_param_call(name_prefix ## name, setfunc, getfunc, NULL, perm); \
MODULE_PARM_DESC(name_prefix ## name, desc)
/* END CSTYLED */

#define ZFS_MODULE_PARAM_ARGS const char *buf, zfs_kernel_param_t *kp

Expand Down
10 changes: 4 additions & 6 deletions include/os/linux/spl/sys/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,11 @@ typedef struct ace_object {

#define ACE_TYPE_FLAGS (ACE_OWNER|ACE_GROUP|ACE_EVERYONE|ACE_IDENTIFIER_GROUP)

/* BEGIN CSTYLED */
#define ACE_ALL_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \
ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \
ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \
ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \
ACE_WRITE_OWNER|ACE_SYNCHRONIZE)
/* END CSTYLED */
ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS|\
ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES|\
ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \
ACE_WRITE_OWNER|ACE_SYNCHRONIZE)

#define VSA_ACE 0x0010
#define VSA_ACECNT 0x0020
Expand Down
Loading

0 comments on commit 7ada752

Please sign in to comment.