Fix cstyle warnings

This patch contains no functional changes.  It is solely intended
to resolve cstyle warnings in order to facilitate moving the spl
source code in to the zfs repository.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #681
This commit is contained in:
Brian Behlendorf 2018-02-07 11:49:38 -08:00 committed by GitHub
parent 23602fdb39
commit 5461eefe50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
121 changed files with 1600 additions and 1588 deletions

View File

@ -26,6 +26,7 @@
#define _SPL_MATH64_COMPAT_H
#ifndef abs64
/* CSTYLED */
#define abs64(x) ({ uint64_t t = (x) >> 63; ((x) ^ t) - t; })
#endif

View File

@ -36,8 +36,7 @@ enum xdr_op {
struct xdr_ops;
typedef struct {
struct xdr_ops *x_ops; /* Also used to let caller know if
xdrmem_create() succeeds (sigh..) */
struct xdr_ops *x_ops; /* Let caller know xdrmem_create() succeeds */
caddr_t x_addr; /* Current buffer addr */
caddr_t x_addr_end; /* End of the buffer */
enum xdr_op x_op; /* Stream direction */
@ -74,11 +73,12 @@ struct xdr_bytesrec {
*/
void xdrmem_create(XDR *xdrs, const caddr_t addr, const uint_t size,
const enum xdr_op op);
#define xdr_destroy(xdrs) ((void) 0) /* Currently not needed. If needed later,
we'll add it to struct xdr_ops */
#define xdr_control(xdrs, req, info) (xdrs)->x_ops->xdr_control((xdrs), \
(req), (info))
/* Currently not needed. If needed later, we'll add it to struct xdr_ops */
#define xdr_destroy(xdrs) ((void) 0)
#define xdr_control(xdrs, req, info) \
(xdrs)->x_ops->xdr_control((xdrs), (req), (info))
/*
* For precaution, the following are defined as static inlines instead of macros
@ -89,40 +89,40 @@ void xdrmem_create(XDR *xdrs, const caddr_t addr, const uint_t size,
*/
static inline bool_t xdr_char(XDR *xdrs, char *cp)
{
return xdrs->x_ops->xdr_char(xdrs, cp);
return (xdrs->x_ops->xdr_char(xdrs, cp));
}
static inline bool_t xdr_u_short(XDR *xdrs, unsigned short *usp)
{
return xdrs->x_ops->xdr_u_short(xdrs, usp);
return (xdrs->x_ops->xdr_u_short(xdrs, usp));
}
static inline bool_t xdr_short(XDR *xdrs, short *sp)
{
BUILD_BUG_ON(sizeof (short) != 2);
return xdrs->x_ops->xdr_u_short(xdrs, (unsigned short *) sp);
return (xdrs->x_ops->xdr_u_short(xdrs, (unsigned short *) sp));
}
static inline bool_t xdr_u_int(XDR *xdrs, unsigned *up)
{
return xdrs->x_ops->xdr_u_int(xdrs, up);
return (xdrs->x_ops->xdr_u_int(xdrs, up));
}
static inline bool_t xdr_int(XDR *xdrs, int *ip)
{
BUILD_BUG_ON(sizeof (int) != 4);
return xdrs->x_ops->xdr_u_int(xdrs, (unsigned *) ip);
return (xdrs->x_ops->xdr_u_int(xdrs, (unsigned *)ip));
}
static inline bool_t xdr_u_longlong_t(XDR *xdrs, u_longlong_t *ullp)
{
return xdrs->x_ops->xdr_u_longlong_t(xdrs, ullp);
return (xdrs->x_ops->xdr_u_longlong_t(xdrs, ullp));
}
static inline bool_t xdr_longlong_t(XDR *xdrs, longlong_t *llp)
{
BUILD_BUG_ON(sizeof (longlong_t) != 8);
return xdrs->x_ops->xdr_u_longlong_t(xdrs, (u_longlong_t *) llp);
return (xdrs->x_ops->xdr_u_longlong_t(xdrs, (u_longlong_t *)llp));
}
/*
@ -130,7 +130,7 @@ static inline bool_t xdr_longlong_t(XDR *xdrs, longlong_t *llp)
*/
static inline bool_t xdr_opaque(XDR *xdrs, caddr_t cp, const uint_t cnt)
{
return xdrs->x_ops->xdr_opaque(xdrs, cp, cnt);
return (xdrs->x_ops->xdr_opaque(xdrs, cp, cnt));
}
/*
@ -139,7 +139,7 @@ static inline bool_t xdr_opaque(XDR *xdrs, caddr_t cp, const uint_t cnt)
*/
static inline bool_t xdr_string(XDR *xdrs, char **sp, const uint_t maxsize)
{
return xdrs->x_ops->xdr_string(xdrs, sp, maxsize);
return (xdrs->x_ops->xdr_string(xdrs, sp, maxsize));
}
/*

View File

@ -103,11 +103,13 @@ 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 */
#define VSA_ACE 0x0010
#define VSA_ACECNT 0x0020

View File

@ -91,7 +91,7 @@ atomic_inc_32_nv(volatile uint32_t *target)
nv = ++(*target);
spin_unlock(&atomic32_lock);
return nv;
return (nv);
}
static __inline__ uint32_t
@ -103,7 +103,7 @@ atomic_dec_32_nv(volatile uint32_t *target)
nv = --(*target);
spin_unlock(&atomic32_lock);
return nv;
return (nv);
}
static __inline__ uint32_t
@ -116,7 +116,7 @@ atomic_add_32_nv(volatile uint32_t *target, uint32_t delta)
nv = *target;
spin_unlock(&atomic32_lock);
return nv;
return (nv);
}
static __inline__ uint32_t
@ -129,12 +129,11 @@ atomic_sub_32_nv(volatile uint32_t *target, uint32_t delta)
nv = *target;
spin_unlock(&atomic32_lock);
return nv;
return (nv);
}
static __inline__ uint32_t
atomic_cas_32(volatile uint32_t *target, uint32_t cmp,
uint32_t newval)
atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval)
{
uint32_t rc;
@ -145,7 +144,7 @@ atomic_cas_32(volatile uint32_t *target, uint32_t cmp,
spin_unlock(&atomic32_lock);
return rc;
return (rc);
}
static __inline__ uint32_t
@ -158,7 +157,7 @@ atomic_swap_32(volatile uint32_t *target, uint32_t newval)
*target = newval;
spin_unlock(&atomic32_lock);
return rc;
return (rc);
}
static __inline__ void
@ -202,7 +201,7 @@ atomic_inc_64_nv(volatile uint64_t *target)
nv = ++(*target);
spin_unlock(&atomic64_lock);
return nv;
return (nv);
}
static __inline__ uint64_t
@ -214,7 +213,7 @@ atomic_dec_64_nv(volatile uint64_t *target)
nv = --(*target);
spin_unlock(&atomic64_lock);
return nv;
return (nv);
}
static __inline__ uint64_t
@ -227,7 +226,7 @@ atomic_add_64_nv(volatile uint64_t *target, uint64_t delta)
nv = *target;
spin_unlock(&atomic64_lock);
return nv;
return (nv);
}
static __inline__ uint64_t
@ -240,12 +239,11 @@ atomic_sub_64_nv(volatile uint64_t *target, uint64_t delta)
nv = *target;
spin_unlock(&atomic64_lock);
return nv;
return (nv);
}
static __inline__ uint64_t
atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
uint64_t newval)
atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval)
{
uint64_t rc;
@ -255,7 +253,7 @@ atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
*target = newval;
spin_unlock(&atomic64_lock);
return rc;
return (rc);
}
static __inline__ uint64_t
@ -268,7 +266,7 @@ atomic_swap_64(volatile uint64_t *target, uint64_t newval)
*target = newval;
spin_unlock(&atomic64_lock);
return rc;
return (rc);
}
#else /* ATOMIC_SPINLOCK */
@ -300,15 +298,15 @@ atomic_swap_64(volatile uint64_t *target, uint64_t newval)
static __inline__ void *
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
{
return (void *)atomic_cas_64((volatile uint64_t *)target,
(uint64_t)cmp, (uint64_t)newval);
return ((void *)atomic_cas_64((volatile uint64_t *)target,
(uint64_t)cmp, (uint64_t)newval));
}
#else /* _LP64 */
static __inline__ void *
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
{
return (void *)atomic_cas_32((volatile uint32_t *)target,
(uint32_t)cmp, (uint32_t)newval);
return ((void *)atomic_cas_32((volatile uint32_t *)target,
(uint32_t)cmp, (uint32_t)newval));
}
#endif /* _LP64 */

View File

@ -46,22 +46,26 @@
#ifdef _BIG_ENDIAN
static __inline__ uint64_t
htonll(uint64_t n) {
htonll(uint64_t n)
{
return (n);
}
static __inline__ uint64_t
ntohll(uint64_t n) {
ntohll(uint64_t n)
{
return (n);
}
#else
static __inline__ uint64_t
htonll(uint64_t n) {
htonll(uint64_t n)
{
return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32));
}
static __inline__ uint64_t
ntohll(uint64_t n) {
ntohll(uint64_t n)
{
return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32));
}
#endif

View File

@ -52,4 +52,3 @@ typedef struct callb_cpr {
}
#endif /* _SPL_CALLB_H */

View File

@ -54,6 +54,7 @@ int spl_panic(const char *file, const char *func, int line,
const char *fmt, ...);
void spl_dumpstack(void);
/* BEGIN CSTYLED */
#define PANIC(fmt, a...) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, fmt, ## a)
@ -120,6 +121,7 @@ void spl_dumpstack(void);
((void)((!!(A) == !!(B)) || \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"(" #A ") is equivalent to (" #B ")")))
/* END CSTYLED */
#endif /* NDEBUG */

View File

@ -52,7 +52,7 @@ static inline void dfl_free(dkioc_free_list_t *dfl) {
}
static inline dkioc_free_list_t *dfl_alloc(uint64_t dfl_num_exts, int flags) {
return vmem_zalloc(DFL_SZ(dfl_num_exts), flags);
return (vmem_zalloc(DFL_SZ(dfl_num_exts), flags));
}
#endif /* _SPL_DKIOC_UTIL_H */

View File

@ -35,7 +35,8 @@
#define KSTAT_STRLEN 255
#define KSTAT_RAW_MAX (128*1024)
/* For reference valid classes are:
/*
* For reference valid classes are:
* disk, tape, net, controller, vm, kvm, hat, streams, kstat, misc
*/
@ -68,7 +69,8 @@
#define KSTAT_FLAG_WRITABLE 0x04
#define KSTAT_FLAG_PERSISTENT 0x08
#define KSTAT_FLAG_DORMANT 0x10
#define KSTAT_FLAG_UNSUPPORTED (KSTAT_FLAG_VAR_SIZE | KSTAT_FLAG_WRITABLE | \
#define KSTAT_FLAG_UNSUPPORTED \
(KSTAT_FLAG_VAR_SIZE | KSTAT_FLAG_WRITABLE | \
KSTAT_FLAG_PERSISTENT | KSTAT_FLAG_DORMANT)
@ -109,7 +111,7 @@ struct kstat_s {
uchar_t ks_type; /* kstat data type */
uchar_t ks_flags; /* kstat flags */
void *ks_data; /* kstat type-specific data */
uint_t ks_ndata; /* # of type-specific data records */
uint_t ks_ndata; /* # of data records */
size_t ks_data_size; /* size of kstat data section */
struct proc_dir_entry *ks_proc; /* proc linkage */
kstat_update_t *ks_update; /* dynamic updates */
@ -157,7 +159,7 @@ typedef struct kstat_io {
uint_t reads; /* number of read operations */
uint_t writes; /* number of write operations */
hrtime_t wtime; /* cumulative wait (pre-service) time */
hrtime_t wlentime; /* cumulative wait length*time product*/
hrtime_t wlentime; /* cumulative wait len*time product */
hrtime_t wlastupdate; /* last time wait queue changed */
hrtime_t rtime; /* cumulative run (service) time */
hrtime_t rlentime; /* cumulative run length*time product */
@ -183,10 +185,11 @@ extern void __kstat_set_raw_ops(kstat_t *ksp,
int (*headers)(char *buf, size_t size),
int (*data)(char *buf, size_t size, void *data),
void* (*addr)(kstat_t *ksp, loff_t index));
extern kstat_t *__kstat_create(const char *ks_module, int ks_instance,
const char *ks_name, const char *ks_class,
uchar_t ks_type, uint_t ks_ndata,
uchar_t ks_flags);
const char *ks_name, const char *ks_class, uchar_t ks_type,
uint_t ks_ndata, uchar_t ks_flags);
extern void __kstat_install(kstat_t *ksp);
extern void __kstat_delete(kstat_t *ksp);
extern void kstat_waitq_enter(kstat_io_t *);
@ -194,8 +197,11 @@ extern void kstat_waitq_exit(kstat_io_t *);
extern void kstat_runq_enter(kstat_io_t *);
extern void kstat_runq_exit(kstat_io_t *);
#define kstat_set_raw_ops(k,h,d,a) __kstat_set_raw_ops(k,h,d,a)
#define kstat_create(m,i,n,c,t,s,f) __kstat_create(m,i,n,c,t,s,f)
#define kstat_set_raw_ops(k, h, d, a) \
__kstat_set_raw_ops(k, h, d, a)
#define kstat_create(m, i, n, c, t, s, f) \
__kstat_create(m, i, n, c, t, s, f)
#define kstat_install(k) __kstat_install(k)
#define kstat_delete(k) __kstat_delete(k)

View File

@ -59,7 +59,7 @@ typedef struct list {
static inline int
list_is_empty(list_t *list)
{
return list_empty(&list->list_head);
return (list_empty(&list->list_head));
}
static inline void
@ -132,10 +132,10 @@ list_remove_head(list_t *list)
{
list_node_t *head = list->list_head.next;
if (head == &list->list_head)
return NULL;
return (NULL);
list_del(head);
return list_object(list, head);
return (list_object(list, head));
}
static inline void *
@ -143,28 +143,28 @@ list_remove_tail(list_t *list)
{
list_node_t *tail = list->list_head.prev;
if (tail == &list->list_head)
return NULL;
return (NULL);
list_del(tail);
return list_object(list, tail);
return (list_object(list, tail));
}
static inline void *
list_head(list_t *list)
{
if (list_is_empty(list))
return NULL;
return (NULL);
return list_object(list, list->list_head.next);
return (list_object(list, list->list_head.next));
}
static inline void *
list_tail(list_t *list)
{
if (list_is_empty(list))
return NULL;
return (NULL);
return list_object(list, list->list_head.prev);
return (list_object(list, list->list_head.prev));
}
static inline void *
@ -173,9 +173,9 @@ list_next(list_t *list, void *object)
list_node_t *node = list_d2l(list, object);
if (node->next != &list->list_head)
return list_object(list, node->next);
return (list_object(list, node->next));
return NULL;
return (NULL);
}
static inline void *
@ -184,9 +184,9 @@ list_prev(list_t *list, void *object)
list_node_t *node = list_d2l(list, object);
if (node->prev != &list->list_head)
return list_object(list, node->prev);
return (list_object(list, node->prev));
return NULL;
return (NULL);
}
static inline int

View File

@ -113,6 +113,7 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \
VERIFY3P(mutex_owner(mp), ==, NULL); \
}
/* BEGIN CSTYLED */
#define mutex_tryenter(mp) \
({ \
int _rc_; \
@ -124,6 +125,7 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \
\
_rc_; \
})
/* END CSTYLED */
#ifdef CONFIG_DEBUG_LOCK_ALLOC
#define mutex_enter_nested(mp, subclass) \

View File

@ -32,7 +32,7 @@ static __inline__ int
random_get_bytes(uint8_t *ptr, size_t len)
{
get_random_bytes((void *)ptr, (int)len);
return 0;
return (0);
}
extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len);

View File

@ -81,9 +81,9 @@ static inline kthread_t *
rw_owner(krwlock_t *rwp)
{
#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
return SEM(rwp)->owner;
return (SEM(rwp)->owner);
#else
return rwp->rw_owner;
return (rwp->rw_owner);
#endif
}
@ -131,7 +131,7 @@ RW_WRITE_HELD(krwlock_t *rwp)
static inline int
RW_LOCK_HELD(krwlock_t *rwp)
{
return spl_rwsem_is_locked(SEM(rwp));
return (spl_rwsem_is_locked(SEM(rwp)));
}
/*
@ -140,6 +140,7 @@ RW_LOCK_HELD(krwlock_t *rwp)
* will be correctly located in the users code which is important
* for the built in kernel lock analysis tools
*/
/* BEGIN CSTYLED */
#define rw_init(rwp, name, type, arg) \
({ \
static struct lock_class_key __key; \
@ -227,6 +228,7 @@ RW_LOCK_HELD(krwlock_t *rwp)
} \
_rc_; \
})
/* END CSTYLED */
int spl_rw_init(void);
void spl_rw_fini(void);

View File

@ -34,7 +34,8 @@
#define FORREAL 0 /* Usual side-effects */
#define JUSTLOOKING 1 /* Don't stop the process */
/* The "why" argument indicates the allowable side-effects of the call:
/*
* The "why" argument indicates the allowable side-effects of the call:
*
* FORREAL: Extract the next pending signal from p_sig into p_cursig;
* stop the process if a stop has been requested or if a traced signal
@ -48,7 +49,7 @@ issig(int why)
{
ASSERT(why == FORREAL || why == JUSTLOOKING);
return signal_pending(current);
return (signal_pending(current));
}
#endif /* SPL_SIGNAL_H */

View File

@ -88,7 +88,8 @@
#define RLIM64_INFINITY (~0ULL)
#endif
/* 0..MAX_PRIO-1: Process priority
/*
* 0..MAX_PRIO-1: Process priority
* 0..MAX_RT_PRIO-1: RT priority tasks
* MAX_RT_PRIO..MAX_PRIO-1: SCHED_NORMAL tasks
*
@ -122,7 +123,8 @@
#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
/* Map some simple functions.
/*
* Map some simple functions.
*/
#define bzero(ptr, size) memset(ptr, 0, size)
#define bcopy(src, dest, size) memmove(dest, src, size)

View File

@ -94,7 +94,7 @@ typedef struct taskq {
taskqid_t tq_lowest_id; /* lowest pend/work id */
struct list_head tq_free_list; /* free taskq_ent_t's */
struct list_head tq_pend_list; /* pending taskq_ent_t's */
struct list_head tq_prio_list; /* priority pending taskq_ent_t's */
struct list_head tq_prio_list; /* priority taskq_ent_t's */
struct list_head tq_delay_list; /* delayed taskq_ent_t's */
struct list_head tq_taskqs; /* all taskq_t's */
spl_wait_queue_head_t tq_work_waitq; /* new work waitq */

View File

@ -45,9 +45,12 @@
typedef void (*thread_func_t)(void *);
/* BEGIN CSTYLED */
#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
__thread_create(stk, stksize, (thread_func_t)func, \
#func, arg, len, pp, state, pri)
/* END CSTYLED */
#define thread_exit() __thread_exit()
#define thread_join(t) VERIFY(0)
#define curthread current
@ -55,8 +58,7 @@ typedef void (*thread_func_t)(void *);
#define getpid() current->pid
extern kthread_t *__thread_create(caddr_t stk, size_t stksize,
thread_func_t func, const char *name,
void *args, size_t len, proc_t *pp,
thread_func_t func, const char *name, void *args, size_t len, proc_t *pp,
int state, pri_t pri);
extern void __thread_exit(void);
extern struct task_struct *spl_kthread_create(int (*func)(void *),

View File

@ -57,4 +57,3 @@
#define NSEC_TO_TICK(ns) usecs_to_jiffies(ns / NSEC_PER_USEC)
#endif /* _SPL_TIMER_H */

View File

@ -48,9 +48,9 @@ copyin(const void *from, void *to, size_t len)
{
/* On error copyin routine returns -1 */
if (xcopyin(from, to, len))
return -1;
return (-1);
return 0;
return (0);
}
static __inline__ int
@ -58,9 +58,9 @@ copyout(const void *from, void *to, size_t len)
{
/* On error copyout routine returns -1 */
if (xcopyout(from, to, len))
return -1;
return (-1);
return 0;
return (0);
}
static __inline__ int
@ -69,7 +69,7 @@ copyinstr(const void *from, void *to, size_t len, size_t *done)
size_t rc;
if (len == 0)
return -ENAMETOOLONG;
return (-ENAMETOOLONG);
/* XXX: Should return ENAMETOOLONG if 'strlen(from) > len' */
@ -78,7 +78,7 @@ copyinstr(const void *from, void *to, size_t len, size_t *done)
if (done != NULL)
*done = rc;
return 0;
return (0);
}
#endif /* SPL_VMSYSTM_H */

View File

@ -121,8 +121,8 @@ typedef enum vtype {
typedef struct vattr {
enum vtype va_type; /* vnode type */
u_int va_mask; /* attribute bit-mask */
u_short va_mode; /* acc mode */
uint_t va_mask; /* attribute bit-mask */
ushort_t va_mode; /* acc mode */
uid_t va_uid; /* owner uid */
gid_t va_gid; /* owner gid */
long va_fsid; /* fs id */

View File

@ -20,7 +20,8 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
*
* z_compress_level/z_uncompress are nearly identical copies of the
* compress2/uncompress functions provided by the official zlib package
* available at http://zlib.net/. The only changes made we to slightly

View File

@ -20,18 +20,12 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Atomic Implementation.
*/
#include <sys/atomic.h>
#ifdef DEBUG_SUBSYSTEM
#undef DEBUG_SUBSYSTEM
#endif
#define DEBUG_SUBSYSTEM S_ATOMIC
#ifdef ATOMIC_SPINLOCK
/* Global atomic lock declarations */
DEFINE_SPINLOCK(atomic32_lock);

View File

@ -335,8 +335,8 @@ __cv_timedwait_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t expire_time,
* Compatibility wrapper for the cv_timedwait_hires() Illumos interface.
*/
static clock_t
cv_timedwait_hires_common(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res,
int flag, int state)
cv_timedwait_hires_common(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim,
hrtime_t res, int flag, int state)
{
if (res > 1) {
/*
@ -363,8 +363,8 @@ cv_timedwait_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res,
EXPORT_SYMBOL(cv_timedwait_hires);
clock_t
cv_timedwait_sig_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res,
int flag)
cv_timedwait_sig_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim,
hrtime_t res, int flag)
{
return (cv_timedwait_hires_common(cvp, mp, tim, res, flag,
TASK_INTERRUPTIBLE));

View File

@ -20,18 +20,12 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Credential Implementation.
*/
#include <sys/cred.h>
#ifdef DEBUG_SUBSYSTEM
#undef DEBUG_SUBSYSTEM
#endif
#define DEBUG_SUBSYSTEM S_CRED
static int
#ifdef HAVE_KUIDGID_T
cr_groups_search(const struct group_info *group_info, kgid_t grp)
@ -43,7 +37,7 @@ cr_groups_search(const struct group_info *group_info, gid_t grp)
int cmp;
if (!group_info)
return 0;
return (0);
left = 0;
right = group_info->ngroups;
@ -57,9 +51,9 @@ cr_groups_search(const struct group_info *group_info, gid_t grp)
else if (cmp < 0)
right = mid;
else
return 1;
return (1);
}
return 0;
return (0);
}
/* Hold a reference on the credential */
@ -96,7 +90,7 @@ crgetngroups(const cred_t *cr)
rc = NGROUPS_PER_BLOCK;
}
#endif
return rc;
return (rc);
}
/*
@ -119,7 +113,7 @@ crgetgroups(const cred_t *cr)
if (gi->nblocks > 0)
gids = KGIDP_TO_SGIDP(gi->blocks[0]);
#endif
return gids;
return (gids);
}
/* Check if the passed gid is available in supplied credential. */
@ -132,63 +126,63 @@ groupmember(gid_t gid, const cred_t *cr)
gi = cr->group_info;
rc = cr_groups_search(gi, SGID_TO_KGID(gid));
return rc;
return (rc);
}
/* Return the effective user id */
uid_t
crgetuid(const cred_t *cr)
{
return KUID_TO_SUID(cr->euid);
return (KUID_TO_SUID(cr->euid));
}
/* Return the real user id */
uid_t
crgetruid(const cred_t *cr)
{
return KUID_TO_SUID(cr->uid);
return (KUID_TO_SUID(cr->uid));
}
/* Return the saved user id */
uid_t
crgetsuid(const cred_t *cr)
{
return KUID_TO_SUID(cr->suid);
return (KUID_TO_SUID(cr->suid));
}
/* Return the filesystem user id */
uid_t
crgetfsuid(const cred_t *cr)
{
return KUID_TO_SUID(cr->fsuid);
return (KUID_TO_SUID(cr->fsuid));
}
/* Return the effective group id */
gid_t
crgetgid(const cred_t *cr)
{
return KGID_TO_SGID(cr->egid);
return (KGID_TO_SGID(cr->egid));
}
/* Return the real group id */
gid_t
crgetrgid(const cred_t *cr)
{
return KGID_TO_SGID(cr->gid);
return (KGID_TO_SGID(cr->gid));
}
/* Return the saved group id */
gid_t
crgetsgid(const cred_t *cr)
{
return KGID_TO_SGID(cr->sgid);
return (KGID_TO_SGID(cr->sgid));
}
/* Return the filesystem group id */
gid_t
crgetfsgid(const cred_t *cr)
{
return KGID_TO_SGID(cr->fsgid);
return (KGID_TO_SGID(cr->fsgid));
}
EXPORT_SYMBOL(crhold);

View File

@ -20,7 +20,7 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Error Implementation.
*/
@ -36,8 +36,7 @@
*/
unsigned int spl_panic_halt;
module_param(spl_panic_halt, uint, 0644);
MODULE_PARM_DESC(spl_panic_halt,
"Cause kernel panic on assertion failures");
MODULE_PARM_DESC(spl_panic_halt, "Cause kernel panic on assertion failures");
/*
* Limit the number of stack traces dumped to not more than 5 every

View File

@ -20,7 +20,7 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Generic Implementation.
*/
@ -109,12 +109,13 @@ spl_rand_next(uint64_t *s) {
static inline void
spl_rand_jump(uint64_t *s) {
static const uint64_t JUMP[] = { 0x8a5cd789635d2dff, 0x121fd2155c472f96 };
static const uint64_t JUMP[] =
{ 0x8a5cd789635d2dff, 0x121fd2155c472f96 };
uint64_t s0 = 0;
uint64_t s1 = 0;
int i, b;
for(i = 0; i < sizeof JUMP / sizeof *JUMP; i++)
for (i = 0; i < sizeof (JUMP) / sizeof (*JUMP); i++)
for (b = 0; b < 64; b++) {
if (JUMP[i] & 1ULL << b) {
s0 ^= s[0];
@ -187,7 +188,7 @@ nlz64(uint64_t x) {
register int n = 0;
if (x == 0)
return 64;
return (64);
if (x <= 0x00000000FFFFFFFFULL) { n = n + 32; x = x << 32; }
if (x <= 0x0000FFFFFFFFFFFFULL) { n = n + 16; x = x << 16; }
@ -196,7 +197,7 @@ nlz64(uint64_t x) {
if (x <= 0x3FFFFFFFFFFFFFFFULL) { n = n + 2; x = x << 2; }
if (x <= 0x7FFFFFFFFFFFFFFFULL) { n = n + 1; }
return n;
return (n);
}
/*
@ -207,7 +208,7 @@ static inline uint64_t
__div_u64(uint64_t u, uint32_t v)
{
(void) do_div(u, v);
return u;
return (u);
}
/*
@ -227,7 +228,7 @@ __udivdi3(uint64_t u, uint64_t v)
if (v >> 32 == 0) { // If v < 2**32:
if (u >> 32 < v) { // If u/v cannot overflow,
return __div_u64(u, v); // just do one division.
return (__div_u64(u, v)); // just do one division.
} else { // If u/v would overflow:
u1 = u >> 32; // Break u into two halves.
u0 = u & 0xFFFFFFFF;
@ -235,7 +236,7 @@ __udivdi3(uint64_t u, uint64_t v)
k = u1 - q1 * v; // First remainder, < v.
u0 += (k << 32);
q0 = __div_u64(u0, v); // Seconds quotient digit.
return (q1 << 32) + q0;
return ((q1 << 32) + q0);
}
} else { // If v >= 2**32:
n = nlz64(v); // 0 <= n <= 31.
@ -249,7 +250,7 @@ __udivdi3(uint64_t u, uint64_t v)
if ((u - q0 * v) >= v)
q0 = q0 + 1; // Now q0 is correct.
return q0;
return (q0);
}
}
EXPORT_SYMBOL(__udivdi3);
@ -263,7 +264,7 @@ __divdi3(int64_t u, int64_t v)
int64_t q, t;
q = __udivdi3(abs64(u), abs64(v));
t = (u ^ v) >> 63; // If u, v have different
return (q ^ t) - t; // signs, negate q.
return ((q ^ t) - t); // signs, negate q.
}
EXPORT_SYMBOL(__divdi3);
@ -344,9 +345,11 @@ __aeabi_uldivmod(uint64_t u, uint64_t v)
register uint32_t r2 asm("r2") = (mod & 0xFFFFFFFF);
register uint32_t r3 asm("r3") = (mod >> 32);
/* BEGIN CSTYLED */
asm volatile(""
: "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
: "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
/* END CSTYLED */
return; /* r0; */
}
@ -367,9 +370,11 @@ __aeabi_ldivmod(int64_t u, int64_t v)
register uint32_t r2 asm("r2") = (mod & 0xFFFFFFFF);
register uint32_t r3 asm("r3") = (mod >> 32);
/* BEGIN CSTYLED */
asm volatile(""
: "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
: "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
/* END CSTYLED */
return; /* r0; */
}
@ -378,7 +383,8 @@ EXPORT_SYMBOL(__aeabi_ldivmod);
#endif /* __arm || __arm__ */
#endif /* BITS_PER_LONG */
/* NOTE: The strtoxx behavior is solely based on my reading of the Solaris
/*
* NOTE: The strtoxx behavior is solely based on my reading of the Solaris
* ddi_strtol(9F) man page. I have not verified the behavior of these
* functions against their Solaris counterparts. It is possible that I
* may have misinterpreted the man page or the man page is incorrect.
@ -397,7 +403,7 @@ int ddi_strtou##type(const char *str, char **endptr, \
int flag = 1, digit; \
\
if (strlen(ptr) == 0) \
return EINVAL; \
return (EINVAL); \
\
/* Auto-detect base based on prefix */ \
if (!base) { \
@ -409,7 +415,7 @@ int ddi_strtou##type(const char *str, char **endptr, \
base = 8; /* octal */ \
ptr += 1; \
} else { \
return EINVAL; \
return (EINVAL); \
} \
} else { \
base = 10; /* decimal */ \
@ -430,7 +436,7 @@ int ddi_strtou##type(const char *str, char **endptr, \
last_value = value; \
value = value * base + digit; \
if (last_value > value) /* Overflow */ \
return ERANGE; \
return (ERANGE); \
\
flag = 1; \
ptr++; \
@ -442,7 +448,7 @@ int ddi_strtou##type(const char *str, char **endptr, \
if (endptr) \
*endptr = (char *)(flag ? ptr : str); \
\
return 0; \
return (0); \
} \
#define define_ddi_strtox(type, valtype) \
@ -463,7 +469,7 @@ int ddi_strto##type(const char *str, char **endptr, \
rc = ddi_strtou##type(str, endptr, base, result); \
} \
\
return rc; \
return (rc); \
}
define_ddi_strtoux(l, unsigned long)
@ -482,10 +488,10 @@ ddi_copyin(const void *from, void *to, size_t len, int flags)
/* Fake ioctl() issued by kernel, 'from' is a kernel address */
if (flags & FKIOCTL) {
memcpy(to, from, len);
return 0;
return (0);
}
return copyin(from, to, len);
return (copyin(from, to, len));
}
EXPORT_SYMBOL(ddi_copyin);
@ -495,10 +501,10 @@ ddi_copyout(const void *from, void *to, size_t len, int flags)
/* Fake ioctl() issued by kernel, 'from' is a kernel address */
if (flags & FKIOCTL) {
memcpy(to, from, len);
return 0;
return (0);
}
return copyout(from, to, len);
return (copyout(from, to, len));
}
EXPORT_SYMBOL(ddi_copyout);
@ -578,7 +584,7 @@ hostid_read(uint32_t *hostid)
*hostid = (value & HW_HOSTID_MASK);
kobj_close_file(file);
return 0;
return (0);
}
/*

View File

@ -20,7 +20,7 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Kobj Implementation.
*/

View File

@ -20,7 +20,7 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Kstat Implementation.
*/
@ -41,13 +41,13 @@ static int
kstat_resize_raw(kstat_t *ksp)
{
if (ksp->ks_raw_bufsize == KSTAT_RAW_MAX)
return ENOMEM;
return (ENOMEM);
vmem_free(ksp->ks_raw_buf, ksp->ks_raw_bufsize);
ksp->ks_raw_bufsize = MIN(ksp->ks_raw_bufsize * 2, KSTAT_RAW_MAX);
ksp->ks_raw_buf = vmem_alloc(ksp->ks_raw_bufsize, KM_SLEEP);
return 0;
return (0);
}
void
@ -172,7 +172,7 @@ restart:
PANIC("Undefined kstat type %d\n", ksp->ks_type);
}
return -rc;
return (-rc);
}
static int
@ -194,7 +194,7 @@ kstat_seq_show_raw(struct seq_file *f, unsigned char *p, int l)
seq_printf(f, "\n");
}
out:
return 0;
return (0);
}
static int
@ -207,7 +207,8 @@ kstat_seq_show_named(struct seq_file *f, kstat_named_t *knp)
knp->value.c[15] = '\0'; /* NULL terminate */
seq_printf(f, "%-16s", knp->value.c);
break;
/* XXX - We need to be more careful able what tokens are
/*
* NOTE - We need to be more careful able what tokens are
* used for each arch, for now this is correct for x86_64.
*/
case KSTAT_DATA_INT32:
@ -220,7 +221,8 @@ kstat_seq_show_named(struct seq_file *f, kstat_named_t *knp)
seq_printf(f, "%lld", (signed long long)knp->value.i64);
break;
case KSTAT_DATA_UINT64:
seq_printf(f, "%llu", (unsigned long long)knp->value.ui64);
seq_printf(f, "%llu",
(unsigned long long)knp->value.ui64);
break;
case KSTAT_DATA_LONG:
seq_printf(f, "%ld", knp->value.l);
@ -239,7 +241,7 @@ kstat_seq_show_named(struct seq_file *f, kstat_named_t *knp)
seq_printf(f, "\n");
return 0;
return (0);
}
static int
@ -252,7 +254,7 @@ kstat_seq_show_intr(struct seq_file *f, kstat_intr_t *kip)
kip->intrs[KSTAT_INTR_SPURIOUS],
kip->intrs[KSTAT_INTR_MULTSVC]);
return 0;
return (0);
}
static int
@ -267,7 +269,7 @@ kstat_seq_show_io(struct seq_file *f, kstat_io_t *kip)
kip->rtime, kip->rlentime, kip->rlastupdate,
kip->wcnt, kip->rcnt);
return 0;
return (0);
}
static int
@ -279,7 +281,7 @@ kstat_seq_show_timer(struct seq_file *f, kstat_timer_t *ktp)
ktp->min_time, ktp->max_time,
ktp->start_time, ktp->stop_time);
return 0;
return (0);
}
static int
@ -322,7 +324,7 @@ restart:
PANIC("Undefined kstat type %d\n", ksp->ks_type);
}
return -rc;
return (-rc);
}
int
@ -333,7 +335,7 @@ kstat_default_update(kstat_t *ksp, int rw)
if (rw == KSTAT_WRITE)
return (EACCES);
return 0;
return (0);
}
static void *
@ -476,17 +478,17 @@ proc_kstat_open(struct inode *inode, struct file *filp)
rc = seq_open(filp, &kstat_seq_ops);
if (rc)
return rc;
return (rc);
f = filp->private_data;
f->private = PDE_DATA(inode);
return rc;
return (rc);
}
static ssize_t
proc_kstat_write(struct file *filp, const char __user *buf,
size_t len, loff_t *ppos)
proc_kstat_write(struct file *filp, const char __user *buf, size_t len,
loff_t *ppos)
{
struct seq_file *f = filp->private_data;
kstat_t *ksp = f->private;
@ -542,7 +544,7 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
ksp = kmem_zalloc(sizeof (*ksp), KM_SLEEP);
if (ksp == NULL)
return ksp;
return (ksp);
mutex_enter(&kstat_module_lock);
ksp->ks_kid = kstat_id;
@ -605,7 +607,7 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
}
}
return ksp;
return (ksp);
}
EXPORT_SYMBOL(__kstat_create);
@ -707,8 +709,6 @@ __kstat_delete(kstat_t *ksp)
ksp->ks_lock = NULL;
mutex_destroy(&ksp->ks_private_lock);
kmem_free(ksp, sizeof (*ksp));
return;
}
EXPORT_SYMBOL(__kstat_delete);
@ -727,4 +727,3 @@ spl_kstat_fini(void)
ASSERT(list_empty(&kstat_module_list));
mutex_destroy(&kstat_module_lock);
}

View File

@ -20,17 +20,11 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Mutex Implementation.
*/
#include <sys/mutex.h>
#ifdef DEBUG_SUBSYSTEM
#undef DEBUG_SUBSYSTEM
#endif
#define DEBUG_SUBSYSTEM S_MUTEX
int spl_mutex_init(void) { return 0; }
void spl_mutex_fini(void) { }

View File

@ -20,7 +20,7 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Proc Implementation.
*/
@ -55,16 +55,16 @@ static struct proc_dir_entry *proc_spl_taskq = NULL;
struct proc_dir_entry *proc_spl_kstat = NULL;
static int
proc_copyin_string(char *kbuffer, int kbuffer_size,
const char *ubuffer, int ubuffer_size)
proc_copyin_string(char *kbuffer, int kbuffer_size, const char *ubuffer,
int ubuffer_size)
{
int size;
if (ubuffer_size > kbuffer_size)
return -EOVERFLOW;
return (-EOVERFLOW);
if (copy_from_user((void *)kbuffer, (void *)ubuffer, ubuffer_size))
return -EFAULT;
return (-EFAULT);
/* strip trailing whitespace */
size = strnlen(kbuffer, ubuffer_size);
@ -74,37 +74,38 @@ proc_copyin_string(char *kbuffer, int kbuffer_size,
/* empty string */
if (size < 0)
return -EINVAL;
return (-EINVAL);
/* no space to terminate */
if (size == kbuffer_size)
return -EOVERFLOW;
return (-EOVERFLOW);
kbuffer[size + 1] = 0;
return 0;
return (0);
}
static int
proc_copyout_string(char *ubuffer, int ubuffer_size,
const char *kbuffer, char *append)
{
/* NB if 'append' != NULL, it's a single character to append to the
/*
* NB if 'append' != NULL, it's a single character to append to the
* copied out string - usually "\n", for /proc entries and
* (i.e. a terminating zero byte) for sysctl entries
*/
int size = MIN(strlen(kbuffer), ubuffer_size);
if (copy_to_user(ubuffer, kbuffer, size))
return -EFAULT;
return (-EFAULT);
if (append != NULL && size < ubuffer_size) {
if (copy_to_user(ubuffer + size, append, 1))
return -EFAULT;
return (-EFAULT);
size++;
}
return size;
return (size);
}
#ifdef DEBUG_KMEM
@ -191,9 +192,11 @@ proc_dohostid(struct ctl_table *table, int write,
char *end, str[32];
if (write) {
/* We can't use proc_doulongvec_minmax() in the write
/*
* We can't use proc_doulongvec_minmax() in the write
* case here because hostid while a hex value has no
* leading 0x which confuses the helper function. */
* leading 0x which confuses the helper function.
*/
rc = proc_copyin_string(str, sizeof (str), buffer, *lenp);
if (rc < 0)
return (rc);
@ -208,7 +211,8 @@ proc_dohostid(struct ctl_table *table, int write,
if (*ppos >= len)
rc = 0;
else
rc = proc_copyout_string(buffer,*lenp,str+*ppos,"\n");
rc = proc_copyout_string(buffer,
*lenp, str + *ppos, "\n");
if (rc >= 0) {
*lenp = rc;
@ -299,7 +303,8 @@ taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag)
j = 0;
list_for_each_entry(tqt, &tq->tq_active_list, tqt_active_list) {
if (j == 0)
seq_printf(f, "\t%s:", list_names[LHEAD_ACTIVE]);
seq_printf(f, "\t%s:",
list_names[LHEAD_ACTIVE]);
else if (j == 2) {
seq_printf(f, "\n\t ");
j = 0;
@ -457,7 +462,7 @@ slab_seq_show(struct seq_file *f, void *p)
spin_unlock(&skc->skc_lock);
return 0;
return (0);
}
static void *
@ -506,7 +511,7 @@ static struct seq_operations slab_seq_ops = {
static int
proc_slab_open(struct inode *inode, struct file *filp)
{
return seq_open(filp, &slab_seq_ops);
return (seq_open(filp, &slab_seq_ops));
}
static struct file_operations proc_slab_operations = {
@ -539,13 +544,13 @@ static struct seq_operations taskq_seq_ops = {
static int
proc_taskq_all_open(struct inode *inode, struct file *filp)
{
return seq_open(filp, &taskq_all_seq_ops);
return (seq_open(filp, &taskq_all_seq_ops));
}
static int
proc_taskq_open(struct inode *inode, struct file *filp)
{
return seq_open(filp, &taskq_seq_ops);
return (seq_open(filp, &taskq_seq_ops));
}
static struct file_operations proc_taskq_all_operations = {
@ -647,7 +652,8 @@ static struct ctl_table spl_kstat_table[] = {
};
static struct ctl_table spl_table[] = {
/* NB No .strategy entries have been provided since
/*
* NB No .strategy entries have been provided since
* sysctl(8) prefers to go via /proc for portability.
*/
{

View File

@ -20,18 +20,12 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Reader/Writer Lock Implementation.
*/
#include <sys/rwlock.h>
#ifdef DEBUG_SUBSYSTEM
#undef DEBUG_SUBSYSTEM
#endif
#define DEBUG_SUBSYSTEM S_RWLOCK
#if defined(CONFIG_PREEMPT_RT_FULL)
#include <linux/rtmutex.h>

View File

@ -87,7 +87,7 @@ taskq_find_by_name(const char *name)
list_for_each_prev(tql, &tq_list) {
tq = list_entry(tql, taskq_t, tq_taskqs);
if (strcmp(name, tq->tq_name) == 0)
return tq->tq_instance;
return (tq->tq_instance);
}
return (-1);
}
@ -573,7 +573,8 @@ taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t flags)
ASSERT(tq->tq_nactive <= tq->tq_nthreads);
if ((flags & TQ_NOQUEUE) && (tq->tq_nactive == tq->tq_nthreads)) {
/* Dynamic taskq may be able to spawn another thread */
if (!(tq->tq_flags & TASKQ_DYNAMIC) || taskq_thread_spawn(tq) == 0)
if (!(tq->tq_flags & TASKQ_DYNAMIC) ||
taskq_thread_spawn(tq) == 0)
goto out;
}
@ -686,7 +687,8 @@ taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint_t flags,
if ((flags & TQ_NOQUEUE) && (tq->tq_nactive == tq->tq_nthreads)) {
/* Dynamic taskq may be able to spawn another thread */
if (!(tq->tq_flags & TASKQ_DYNAMIC) || taskq_thread_spawn(tq) == 0)
if (!(tq->tq_flags & TASKQ_DYNAMIC) ||
taskq_thread_spawn(tq) == 0)
goto out2;
flags |= TQ_FRONT;
}
@ -786,7 +788,8 @@ taskq_thread_spawn_task(void *arg)
if (taskq_thread_create(tq) == NULL) {
/* restore spawning count if failed */
spin_lock_irqsave_nested(&tq->tq_lock, flags, tq->tq_lock_class);
spin_lock_irqsave_nested(&tq->tq_lock, flags,
tq->tq_lock_class);
tq->tq_nspawn--;
spin_unlock_irqrestore(&tq->tq_lock, flags);
}
@ -1146,7 +1149,8 @@ taskq_destroy(taskq_t *tq)
while (tq->tq_nspawn) {
spin_unlock_irqrestore(&tq->tq_lock, flags);
schedule_timeout_interruptible(1);
spin_lock_irqsave_nested(&tq->tq_lock, flags, tq->tq_lock_class);
spin_lock_irqsave_nested(&tq->tq_lock, flags,
tq->tq_lock_class);
}
/*

View File

@ -20,7 +20,7 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Thread Implementation.
*/
@ -60,7 +60,7 @@ thread_generic_wrapper(void *arg)
if (func)
func(args);
return 0;
return (0);
}
void
@ -72,9 +72,11 @@ __thread_exit(void)
}
EXPORT_SYMBOL(__thread_exit);
/* thread_create() may block forever if it cannot create a thread or
/*
* thread_create() may block forever if it cannot create a thread or
* allocate memory. This is preferable to returning a NULL which Solaris
* style callers likely never check for... since it can't fail. */
* style callers likely never check for... since it can't fail.
*/
kthread_t *
__thread_create(caddr_t stk, size_t stksize, thread_func_t func,
const char *name, void *args, size_t len, proc_t *pp,
@ -103,7 +105,8 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func,
strncpy(tp->tp_name, name, tp->tp_name_size);
/* Strip trailing "_thread" from passed name which will be the func
/*
* Strip trailing "_thread" from passed name which will be the func
* name since the exposed API has no parameter for passing a name.
*/
p = strstr(tp->tp_name, "_thread");

View File

@ -20,7 +20,7 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) Vnode Implementation.
*/
@ -43,27 +43,27 @@ vtype_t
vn_mode_to_vtype(mode_t mode)
{
if (S_ISREG(mode))
return VREG;
return (VREG);
if (S_ISDIR(mode))
return VDIR;
return (VDIR);
if (S_ISCHR(mode))
return VCHR;
return (VCHR);
if (S_ISBLK(mode))
return VBLK;
return (VBLK);
if (S_ISFIFO(mode))
return VFIFO;
return (VFIFO);
if (S_ISLNK(mode))
return VLNK;
return (VLNK);
if (S_ISSOCK(mode))
return VSOCK;
return (VSOCK);
return VNON;
return (VNON);
} /* vn_mode_to_vtype() */
EXPORT_SYMBOL(vn_mode_to_vtype);
@ -71,27 +71,27 @@ mode_t
vn_vtype_to_mode(vtype_t vtype)
{
if (vtype == VREG)
return S_IFREG;
return (S_IFREG);
if (vtype == VDIR)
return S_IFDIR;
return (S_IFDIR);
if (vtype == VCHR)
return S_IFCHR;
return (S_IFCHR);
if (vtype == VBLK)
return S_IFBLK;
return (S_IFBLK);
if (vtype == VFIFO)
return S_IFIFO;
return (S_IFIFO);
if (vtype == VLNK)
return S_IFLNK;
return (S_IFLNK);
if (vtype == VSOCK)
return S_IFSOCK;
return (S_IFSOCK);
return VNON;
return (VNON);
} /* vn_vtype_to_mode() */
EXPORT_SYMBOL(vn_vtype_to_mode);
@ -135,7 +135,8 @@ vn_open(const char *path, uio_seg_t seg, int flags, int mode,
if (!(flags & FCREAT) && (flags & FWRITE))
flags |= FEXCL;
/* Note for filp_open() the two low bits must be remapped to mean:
/*
* Note for filp_open() the two low bits must be remapped to mean:
* 01 - read-only -> 00 read-only
* 10 - write-only -> 01 write-only
* 11 - read-write -> 10 read-write
@ -259,9 +260,11 @@ vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4)
} /* vn_close() */
EXPORT_SYMBOL(vn_close);
/* vn_seek() does not actually seek it only performs bounds checking on the
/*
* vn_seek() does not actually seek it only performs bounds checking on the
* proposed seek. We perform minimal checking and allow vn_rdwr() to catch
* anything more serious. */
* anything more serious.
*/
int
vn_seek(vnode_t *vp, offset_t ooff, offset_t *noffp, void *ct)
{
@ -312,7 +315,8 @@ vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4)
}
EXPORT_SYMBOL(vn_getattr);
int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4)
int
vn_fsync(vnode_t *vp, int flags, void *x3, void *x4)
{
int datasync = 0;
int error;
@ -417,11 +421,11 @@ file_find(int fd, struct task_struct *task)
list_for_each_entry(fp, &vn_file_list, f_list) {
if (fd == fp->f_fd && fp->f_task == task) {
ASSERT(atomic_read(&fp->f_ref) != 0);
return fp;
return (fp);
}
}
return NULL;
return (NULL);
} /* file_find() */
file_t *
@ -482,7 +486,8 @@ vn_getf(int fd)
goto out_fget;
#if defined(HAVE_4ARGS_VFS_GETATTR)
rc = vfs_getattr(&lfp->f_path, &stat, STATX_TYPE, AT_STATX_SYNC_AS_STAT);
rc = vfs_getattr(&lfp->f_path, &stat, STATX_TYPE,
AT_STATX_SYNC_AS_STAT);
#elif defined(HAVE_2ARGS_VFS_GETATTR)
rc = vfs_getattr(&lfp->f_path, &stat);
#else
@ -560,8 +565,6 @@ vn_areleasef(int fd, uf_info_t *fip)
releasef_locked(fp);
}
spin_unlock(&vn_file_lock);
return;
} /* releasef() */
EXPORT_SYMBOL(areleasef);
@ -669,16 +672,13 @@ int
spl_vn_init(void)
{
vn_cache = kmem_cache_create("spl_vn_cache",
sizeof(struct vnode), 64,
vn_cache_constructor,
vn_cache_destructor,
NULL, NULL, NULL, 0);
sizeof (struct vnode), 64, vn_cache_constructor,
vn_cache_destructor, NULL, NULL, NULL, 0);
vn_file_cache = kmem_cache_create("spl_vn_file_cache",
sizeof(file_t), 64,
vn_file_cache_constructor,
vn_file_cache_destructor,
NULL, NULL, NULL, 0);
sizeof (file_t), 64, vn_file_cache_constructor,
vn_file_cache_destructor, NULL, NULL, NULL, 0);
return (0);
} /* vn_init() */
@ -703,6 +703,4 @@ spl_vn_fini(void)
kmem_cache_destroy(vn_file_cache);
kmem_cache_destroy(vn_cache);
return;
} /* vn_fini() */

View File

@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
* Solaris Porting Layer (SPL) XDR Implementation.
*/
@ -163,12 +163,12 @@ xdrmem_control(XDR *xdrs, int req, void *info)
struct xdr_bytesrec *rec = (struct xdr_bytesrec *) info;
if (req != XDR_GET_BYTES_AVAIL)
return FALSE;
return (FALSE);
rec->xc_is_last_record = TRUE; /* always TRUE in xdrmem streams */
rec->xc_num_avail = xdrs->x_addr_end - xdrs->x_addr;
return TRUE;
return (TRUE);
}
static bool_t
@ -178,13 +178,13 @@ xdrmem_enc_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt)
uint_t pad;
if (size < cnt)
return FALSE; /* Integer overflow */
return (FALSE); /* Integer overflow */
if (xdrs->x_addr > xdrs->x_addr_end)
return FALSE;
return (FALSE);
if (xdrs->x_addr_end - xdrs->x_addr < size)
return FALSE;
return (FALSE);
memcpy(xdrs->x_addr, cp, cnt);
@ -196,7 +196,7 @@ xdrmem_enc_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt)
xdrs->x_addr += pad;
}
return TRUE;
return (TRUE);
}
static bool_t
@ -207,13 +207,13 @@ xdrmem_dec_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt)
uint_t pad;
if (size < cnt)
return FALSE; /* Integer overflow */
return (FALSE); /* Integer overflow */
if (xdrs->x_addr > xdrs->x_addr_end)
return FALSE;
return (FALSE);
if (xdrs->x_addr_end - xdrs->x_addr < size)
return FALSE;
return (FALSE);
memcpy(cp, xdrs->x_addr, cnt);
xdrs->x_addr += cnt;
@ -222,38 +222,38 @@ xdrmem_dec_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt)
if (pad > 0) {
/* An inverted memchr() would be useful here... */
if (memcmp(&zero, xdrs->x_addr, pad) != 0)
return FALSE;
return (FALSE);
xdrs->x_addr += pad;
}
return TRUE;
return (TRUE);
}
static bool_t
xdrmem_enc_uint32(XDR *xdrs, uint32_t val)
{
if (xdrs->x_addr + sizeof (uint32_t) > xdrs->x_addr_end)
return FALSE;
return (FALSE);
*((uint32_t *) xdrs->x_addr) = cpu_to_be32(val);
xdrs->x_addr += sizeof (uint32_t);
return TRUE;
return (TRUE);
}
static bool_t
xdrmem_dec_uint32(XDR *xdrs, uint32_t *val)
{
if (xdrs->x_addr + sizeof (uint32_t) > xdrs->x_addr_end)
return FALSE;
return (FALSE);
*val = be32_to_cpu(*((uint32_t *) xdrs->x_addr));
xdrs->x_addr += sizeof (uint32_t);
return TRUE;
return (TRUE);
}
static bool_t
@ -264,7 +264,7 @@ xdrmem_enc_char(XDR *xdrs, char *cp)
BUILD_BUG_ON(sizeof (char) != 1);
val = *((unsigned char *) cp);
return xdrmem_enc_uint32(xdrs, val);
return (xdrmem_enc_uint32(xdrs, val));
}
static bool_t
@ -275,7 +275,7 @@ xdrmem_dec_char(XDR *xdrs, char *cp)
BUILD_BUG_ON(sizeof (char) != 1);
if (!xdrmem_dec_uint32(xdrs, &val))
return FALSE;
return (FALSE);
/*
* If any of the 3 other bytes are non-zero then val will be greater
@ -283,11 +283,11 @@ xdrmem_dec_char(XDR *xdrs, char *cp)
* not have a char encoded in it.
*/
if (val > 0xff)
return FALSE;
return (FALSE);
*((unsigned char *) cp) = val;
return TRUE;
return (TRUE);
}
static bool_t
@ -295,7 +295,7 @@ xdrmem_enc_ushort(XDR *xdrs, unsigned short *usp)
{
BUILD_BUG_ON(sizeof (unsigned short) != 2);
return xdrmem_enc_uint32(xdrs, *usp);
return (xdrmem_enc_uint32(xdrs, *usp));
}
static bool_t
@ -306,18 +306,18 @@ xdrmem_dec_ushort(XDR *xdrs, unsigned short *usp)
BUILD_BUG_ON(sizeof (unsigned short) != 2);
if (!xdrmem_dec_uint32(xdrs, &val))
return FALSE;
return (FALSE);
/*
* Short ints are not in the RFC, but we assume similar logic as in
* xdrmem_dec_char().
*/
if (val > 0xffff)
return FALSE;
return (FALSE);
*usp = val;
return TRUE;
return (TRUE);
}
static bool_t
@ -325,7 +325,7 @@ xdrmem_enc_uint(XDR *xdrs, unsigned *up)
{
BUILD_BUG_ON(sizeof (unsigned) != 4);
return xdrmem_enc_uint32(xdrs, *up);
return (xdrmem_enc_uint32(xdrs, *up));
}
static bool_t
@ -333,7 +333,7 @@ xdrmem_dec_uint(XDR *xdrs, unsigned *up)
{
BUILD_BUG_ON(sizeof (unsigned) != 4);
return xdrmem_dec_uint32(xdrs, (uint32_t *) up);
return (xdrmem_dec_uint32(xdrs, (uint32_t *) up));
}
static bool_t
@ -342,9 +342,9 @@ xdrmem_enc_ulonglong(XDR *xdrs, u_longlong_t *ullp)
BUILD_BUG_ON(sizeof (u_longlong_t) != 8);
if (!xdrmem_enc_uint32(xdrs, *ullp >> 32))
return FALSE;
return (FALSE);
return xdrmem_enc_uint32(xdrs, *ullp & 0xffffffff);
return (xdrmem_enc_uint32(xdrs, *ullp & 0xffffffff));
}
static bool_t
@ -355,13 +355,13 @@ xdrmem_dec_ulonglong(XDR *xdrs, u_longlong_t *ullp)
BUILD_BUG_ON(sizeof (u_longlong_t) != 8);
if (!xdrmem_dec_uint32(xdrs, &high))
return FALSE;
return (FALSE);
if (!xdrmem_dec_uint32(xdrs, &low))
return FALSE;
return (FALSE);
*ullp = ((u_longlong_t) high << 32) | low;
return TRUE;
return (TRUE);
}
static bool_t
@ -372,18 +372,18 @@ xdr_enc_array(XDR *xdrs, caddr_t *arrp, uint_t *sizep, const uint_t maxsize,
caddr_t addr = *arrp;
if (*sizep > maxsize || *sizep > UINT_MAX / elsize)
return FALSE;
return (FALSE);
if (!xdrmem_enc_uint(xdrs, sizep))
return FALSE;
return (FALSE);
for (i = 0; i < *sizep; i++) {
if (!elproc(xdrs, addr))
return FALSE;
return (FALSE);
addr += elsize;
}
return TRUE;
return (TRUE);
}
static bool_t
@ -395,12 +395,12 @@ xdr_dec_array(XDR *xdrs, caddr_t *arrp, uint_t *sizep, const uint_t maxsize,
caddr_t addr;
if (!xdrmem_dec_uint(xdrs, sizep))
return FALSE;
return (FALSE);
size = *sizep;
if (size > maxsize || size > UINT_MAX / elsize)
return FALSE;
return (FALSE);
/*
* The Solaris man page says: "If *arrp is NULL when decoding,
@ -411,7 +411,7 @@ xdr_dec_array(XDR *xdrs, caddr_t *arrp, uint_t *sizep, const uint_t maxsize,
*arrp = kmem_alloc(size * elsize, KM_NOSLEEP);
if (*arrp == NULL)
return FALSE;
return (FALSE);
alloc = TRUE;
}
@ -422,12 +422,12 @@ xdr_dec_array(XDR *xdrs, caddr_t *arrp, uint_t *sizep, const uint_t maxsize,
if (!elproc(xdrs, addr)) {
if (alloc)
kmem_free(*arrp, size * elsize);
return FALSE;
return (FALSE);
}
addr += elsize;
}
return TRUE;
return (TRUE);
}
static bool_t
@ -437,14 +437,14 @@ xdr_enc_string(XDR *xdrs, char **sp, const uint_t maxsize)
uint_t len;
if (slen > maxsize)
return FALSE;
return (FALSE);
len = slen;
if (!xdrmem_enc_uint(xdrs, &len))
return FALSE;
return (FALSE);
return xdrmem_enc_bytes(xdrs, *sp, len);
return (xdrmem_enc_bytes(xdrs, *sp, len));
}
static bool_t
@ -454,10 +454,10 @@ xdr_dec_string(XDR *xdrs, char **sp, const uint_t maxsize)
bool_t alloc = FALSE;
if (!xdrmem_dec_uint(xdrs, &size))
return FALSE;
return (FALSE);
if (size > maxsize || size > UINT_MAX - 1)
return FALSE;
return (FALSE);
/*
* Solaris man page: "If *sp is NULL when decoding, xdr_string()
@ -468,7 +468,7 @@ xdr_dec_string(XDR *xdrs, char **sp, const uint_t maxsize)
*sp = kmem_alloc(size + 1, KM_NOSLEEP);
if (*sp == NULL)
return FALSE;
return (FALSE);
alloc = TRUE;
}
@ -481,13 +481,13 @@ xdr_dec_string(XDR *xdrs, char **sp, const uint_t maxsize)
(*sp)[size] = '\0';
return TRUE;
return (TRUE);
fail:
if (alloc)
kmem_free(*sp, size + 1);
return FALSE;
return (FALSE);
}
static struct xdr_ops xdrmem_encode_ops = {
@ -511,4 +511,3 @@ static struct xdr_ops xdrmem_decode_ops = {
.xdr_string = xdr_dec_string,
.xdr_array = xdr_dec_array
};

View File

@ -20,7 +20,8 @@
*
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
*
*
* z_compress_level/z_uncompress are nearly identical copies of the
* compress2/uncompress functions provided by the official zlib package
* available at http://zlib.net/. The only changes made we to slightly
@ -72,7 +73,7 @@ static spl_kmem_cache_t *zlib_workspace_cache;
static void *
zlib_workspace_alloc(int flags)
{
return kmem_cache_alloc(zlib_workspace_cache, flags & ~(__GFP_FS));
return (kmem_cache_alloc(zlib_workspace_cache, flags & ~(__GFP_FS)));
}
static void
@ -105,30 +106,30 @@ z_compress_level(void *dest, size_t *destLen, const void *source,
stream.avail_out = (uInt)*destLen;
if ((size_t)stream.avail_out != *destLen)
return Z_BUF_ERROR;
return (Z_BUF_ERROR);
stream.workspace = zlib_workspace_alloc(KM_SLEEP);
if (!stream.workspace)
return Z_MEM_ERROR;
return (Z_MEM_ERROR);
err = zlib_deflateInit(&stream, level);
if (err != Z_OK) {
zlib_workspace_free(stream.workspace);
return err;
return (err);
}
err = zlib_deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
zlib_deflateEnd(&stream);
zlib_workspace_free(stream.workspace);
return err == Z_OK ? Z_BUF_ERROR : err;
return (err == Z_OK ? Z_BUF_ERROR : err);
}
*destLen = stream.total_out;
err = zlib_deflateEnd(&stream);
zlib_workspace_free(stream.workspace);
return err;
return (err);
}
EXPORT_SYMBOL(z_compress_level);
@ -159,16 +160,16 @@ z_uncompress(void *dest, size_t *destLen, const void *source, size_t sourceLen)
stream.avail_out = (uInt)*destLen;
if ((size_t)stream.avail_out != *destLen)
return Z_BUF_ERROR;
return (Z_BUF_ERROR);
stream.workspace = zlib_workspace_alloc(KM_SLEEP);
if (!stream.workspace)
return Z_MEM_ERROR;
return (Z_MEM_ERROR);
err = zlib_inflateInit(&stream);
if (err != Z_OK) {
zlib_workspace_free(stream.workspace);
return err;
return (err);
}
err = zlib_inflate(&stream, Z_FINISH);
@ -178,16 +179,16 @@ z_uncompress(void *dest, size_t *destLen, const void *source, size_t sourceLen)
if (err == Z_NEED_DICT ||
(err == Z_BUF_ERROR && stream.avail_in == 0))
return Z_DATA_ERROR;
return (Z_DATA_ERROR);
return err;
return (err);
}
*destLen = stream.total_out;
err = zlib_inflateEnd(&stream);
zlib_workspace_free(stream.workspace);
return err;
return (err);
}
EXPORT_SYMBOL(z_uncompress);