Commit 4d886d65 authored by David S. Miller's avatar David S. Miller

Merge branch 'net-bool'

Yaowei Bai says:

====================
net: small improvement

This patchset makes several functions in net return bool to improve
readability and/or simplicity because these functions only use one
or zero as their return value.

No functional changes.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 8cec75bd 0cbf3343
...@@ -78,7 +78,7 @@ struct can_priv { ...@@ -78,7 +78,7 @@ struct can_priv {
#define get_canfd_dlc(i) (min_t(__u8, (i), CANFD_MAX_DLC)) #define get_canfd_dlc(i) (min_t(__u8, (i), CANFD_MAX_DLC))
/* Drop a given socketbuffer if it does not contain a valid CAN frame. */ /* Drop a given socketbuffer if it does not contain a valid CAN frame. */
static inline int can_dropped_invalid_skb(struct net_device *dev, static inline bool can_dropped_invalid_skb(struct net_device *dev,
struct sk_buff *skb) struct sk_buff *skb)
{ {
const struct canfd_frame *cfd = (struct canfd_frame *)skb->data; const struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
...@@ -94,12 +94,12 @@ static inline int can_dropped_invalid_skb(struct net_device *dev, ...@@ -94,12 +94,12 @@ static inline int can_dropped_invalid_skb(struct net_device *dev,
} else } else
goto inval_skb; goto inval_skb;
return 0; return false;
inval_skb: inval_skb:
kfree_skb(skb); kfree_skb(skb);
dev->stats.tx_dropped++; dev->stats.tx_dropped++;
return 1; return true;
} }
static inline bool can_is_canfd_skb(const struct sk_buff *skb) static inline bool can_is_canfd_skb(const struct sk_buff *skb)
......
...@@ -202,16 +202,16 @@ struct dccp_service_list { ...@@ -202,16 +202,16 @@ struct dccp_service_list {
#define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1) #define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1)
#define DCCP_SERVICE_CODE_IS_ABSENT 0 #define DCCP_SERVICE_CODE_IS_ABSENT 0
static inline int dccp_list_has_service(const struct dccp_service_list *sl, static inline bool dccp_list_has_service(const struct dccp_service_list *sl,
const __be32 service) const __be32 service)
{ {
if (likely(sl != NULL)) { if (likely(sl != NULL)) {
u32 i = sl->dccpsl_nr; u32 i = sl->dccpsl_nr;
while (i--) while (i--)
if (sl->dccpsl_list[i] == service) if (sl->dccpsl_list[i] == service)
return 1; return true;
} }
return 0; return false;
} }
struct dccp_ackvec; struct dccp_ackvec;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
extern void genl_lock(void); extern void genl_lock(void);
extern void genl_unlock(void); extern void genl_unlock(void);
#ifdef CONFIG_LOCKDEP #ifdef CONFIG_LOCKDEP
extern int lockdep_genl_is_held(void); extern bool lockdep_genl_is_held(void);
#endif #endif
/* for synchronisation between af_netlink and genetlink */ /* for synchronisation between af_netlink and genetlink */
......
This diff is collapsed.
...@@ -171,7 +171,7 @@ __be32 inet_confirm_addr(struct net *net, struct in_device *in_dev, __be32 dst, ...@@ -171,7 +171,7 @@ __be32 inet_confirm_addr(struct net *net, struct in_device *in_dev, __be32 dst,
__be32 local, int scope); __be32 local, int scope);
struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix, struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
__be32 mask); __be32 mask);
static __inline__ int inet_ifa_match(__be32 addr, struct in_ifaddr *ifa) static __inline__ bool inet_ifa_match(__be32 addr, struct in_ifaddr *ifa)
{ {
return !((addr^ifa->ifa_address)&ifa->ifa_mask); return !((addr^ifa->ifa_address)&ifa->ifa_mask);
} }
...@@ -180,15 +180,15 @@ static __inline__ int inet_ifa_match(__be32 addr, struct in_ifaddr *ifa) ...@@ -180,15 +180,15 @@ static __inline__ int inet_ifa_match(__be32 addr, struct in_ifaddr *ifa)
* Check if a mask is acceptable. * Check if a mask is acceptable.
*/ */
static __inline__ int bad_mask(__be32 mask, __be32 addr) static __inline__ bool bad_mask(__be32 mask, __be32 addr)
{ {
__u32 hmask; __u32 hmask;
if (addr & (mask = ~mask)) if (addr & (mask = ~mask))
return 1; return true;
hmask = ntohl(mask); hmask = ntohl(mask);
if (hmask & (hmask+1)) if (hmask & (hmask+1))
return 1; return true;
return 0; return false;
} }
#define for_primary_ifa(in_dev) { struct in_ifaddr *ifa; \ #define for_primary_ifa(in_dev) { struct in_ifaddr *ifa; \
......
...@@ -45,11 +45,11 @@ int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid, ...@@ -45,11 +45,11 @@ int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
void nfnl_lock(__u8 subsys_id); void nfnl_lock(__u8 subsys_id);
void nfnl_unlock(__u8 subsys_id); void nfnl_unlock(__u8 subsys_id);
#ifdef CONFIG_PROVE_LOCKING #ifdef CONFIG_PROVE_LOCKING
int lockdep_nfnl_is_held(__u8 subsys_id); bool lockdep_nfnl_is_held(__u8 subsys_id);
#else #else
static inline int lockdep_nfnl_is_held(__u8 subsys_id) static inline bool lockdep_nfnl_is_held(__u8 subsys_id)
{ {
return 1; return true;
} }
#endif /* CONFIG_PROVE_LOCKING */ #endif /* CONFIG_PROVE_LOCKING */
......
...@@ -33,11 +33,11 @@ extern wait_queue_head_t netdev_unregistering_wq; ...@@ -33,11 +33,11 @@ extern wait_queue_head_t netdev_unregistering_wq;
extern struct mutex net_mutex; extern struct mutex net_mutex;
#ifdef CONFIG_PROVE_LOCKING #ifdef CONFIG_PROVE_LOCKING
extern int lockdep_rtnl_is_held(void); extern bool lockdep_rtnl_is_held(void);
#else #else
static inline int lockdep_rtnl_is_held(void) static inline bool lockdep_rtnl_is_held(void)
{ {
return 1; return true;
} }
#endif /* #ifdef CONFIG_PROVE_LOCKING */ #endif /* #ifdef CONFIG_PROVE_LOCKING */
......
...@@ -96,7 +96,7 @@ int rtnl_is_locked(void) ...@@ -96,7 +96,7 @@ int rtnl_is_locked(void)
EXPORT_SYMBOL(rtnl_is_locked); EXPORT_SYMBOL(rtnl_is_locked);
#ifdef CONFIG_PROVE_LOCKING #ifdef CONFIG_PROVE_LOCKING
int lockdep_rtnl_is_held(void) bool lockdep_rtnl_is_held(void)
{ {
return lockdep_is_held(&rtnl_mutex); return lockdep_is_held(&rtnl_mutex);
} }
......
...@@ -325,13 +325,13 @@ void dccp_send_close(struct sock *sk, const int active); ...@@ -325,13 +325,13 @@ void dccp_send_close(struct sock *sk, const int active);
int dccp_invalid_packet(struct sk_buff *skb); int dccp_invalid_packet(struct sk_buff *skb);
u32 dccp_sample_rtt(struct sock *sk, long delta); u32 dccp_sample_rtt(struct sock *sk, long delta);
static inline int dccp_bad_service_code(const struct sock *sk, static inline bool dccp_bad_service_code(const struct sock *sk,
const __be32 service) const __be32 service)
{ {
const struct dccp_sock *dp = dccp_sk(sk); const struct dccp_sock *dp = dccp_sk(sk);
if (dp->dccps_service == service) if (dp->dccps_service == service)
return 0; return false;
return !dccp_list_has_service(dp->dccps_service_list, service); return !dccp_list_has_service(dp->dccps_service_list, service);
} }
......
...@@ -64,7 +64,7 @@ void nfnl_unlock(__u8 subsys_id) ...@@ -64,7 +64,7 @@ void nfnl_unlock(__u8 subsys_id)
EXPORT_SYMBOL_GPL(nfnl_unlock); EXPORT_SYMBOL_GPL(nfnl_unlock);
#ifdef CONFIG_PROVE_LOCKING #ifdef CONFIG_PROVE_LOCKING
int lockdep_nfnl_is_held(u8 subsys_id) bool lockdep_nfnl_is_held(u8 subsys_id)
{ {
return lockdep_is_held(&table[subsys_id].mutex); return lockdep_is_held(&table[subsys_id].mutex);
} }
......
...@@ -39,7 +39,7 @@ void genl_unlock(void) ...@@ -39,7 +39,7 @@ void genl_unlock(void)
EXPORT_SYMBOL(genl_unlock); EXPORT_SYMBOL(genl_unlock);
#ifdef CONFIG_LOCKDEP #ifdef CONFIG_LOCKDEP
int lockdep_genl_is_held(void) bool lockdep_genl_is_held(void)
{ {
return lockdep_is_held(&genl_mutex); return lockdep_is_held(&genl_mutex);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment