Skip to content

Commit

Permalink
Merge branch 'net-bool'
Browse files Browse the repository at this point in the history
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 9, 2015
2 parents 8cec75b + 0cbf334 commit 4d886d6
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 61 deletions.
6 changes: 3 additions & 3 deletions include/linux/can/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct can_priv {
#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. */
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)
{
const struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
Expand All @@ -94,12 +94,12 @@ static inline int can_dropped_invalid_skb(struct net_device *dev,
} else
goto inval_skb;

return 0;
return false;

inval_skb:
kfree_skb(skb);
dev->stats.tx_dropped++;
return 1;
return true;
}

static inline bool can_is_canfd_skb(const struct sk_buff *skb)
Expand Down
6 changes: 3 additions & 3 deletions include/linux/dccp.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ struct dccp_service_list {
#define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1)
#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)
{
if (likely(sl != NULL)) {
u32 i = sl->dccpsl_nr;
while (i--)
if (sl->dccpsl_list[i] == service)
return 1;
return true;
}
return 0;
return false;
}

struct dccp_ackvec;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/genetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
extern void genl_lock(void);
extern void genl_unlock(void);
#ifdef CONFIG_LOCKDEP
extern int lockdep_genl_is_held(void);
extern bool lockdep_genl_is_held(void);
#endif

/* for synchronisation between af_netlink and genetlink */
Expand Down
76 changes: 38 additions & 38 deletions include/linux/ieee80211.h

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions include/linux/inetdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ __be32 inet_confirm_addr(struct net *net, struct in_device *in_dev, __be32 dst,
__be32 local, int scope);
struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
__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);
}
Expand All @@ -180,15 +180,15 @@ static __inline__ int inet_ifa_match(__be32 addr, struct in_ifaddr *ifa)
* 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;
if (addr & (mask = ~mask))
return 1;
return true;
hmask = ntohl(mask);
if (hmask & (hmask+1))
return 1;
return 0;
return true;
return false;
}

#define for_primary_ifa(in_dev) { struct in_ifaddr *ifa; \
Expand Down
6 changes: 3 additions & 3 deletions include/linux/netfilter/nfnetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
void nfnl_lock(__u8 subsys_id);
void nfnl_unlock(__u8 subsys_id);
#ifdef CONFIG_PROVE_LOCKING
int lockdep_nfnl_is_held(__u8 subsys_id);
bool lockdep_nfnl_is_held(__u8 subsys_id);
#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 */

Expand Down
6 changes: 3 additions & 3 deletions include/linux/rtnetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ extern wait_queue_head_t netdev_unregistering_wq;
extern struct mutex net_mutex;

#ifdef CONFIG_PROVE_LOCKING
extern int lockdep_rtnl_is_held(void);
extern bool lockdep_rtnl_is_held(void);
#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 */

Expand Down
2 changes: 1 addition & 1 deletion net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int rtnl_is_locked(void)
EXPORT_SYMBOL(rtnl_is_locked);

#ifdef CONFIG_PROVE_LOCKING
int lockdep_rtnl_is_held(void)
bool lockdep_rtnl_is_held(void)
{
return lockdep_is_held(&rtnl_mutex);
}
Expand Down
4 changes: 2 additions & 2 deletions net/dccp/dccp.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,13 @@ void dccp_send_close(struct sock *sk, const int active);
int dccp_invalid_packet(struct sk_buff *skb);
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 struct dccp_sock *dp = dccp_sk(sk);

if (dp->dccps_service == service)
return 0;
return false;
return !dccp_list_has_service(dp->dccps_service_list, service);
}

Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nfnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void nfnl_unlock(__u8 subsys_id)
EXPORT_SYMBOL_GPL(nfnl_unlock);

#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);
}
Expand Down
2 changes: 1 addition & 1 deletion net/netlink/genetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void genl_unlock(void)
EXPORT_SYMBOL(genl_unlock);

#ifdef CONFIG_LOCKDEP
int lockdep_genl_is_held(void)
bool lockdep_genl_is_held(void)
{
return lockdep_is_held(&genl_mutex);
}
Expand Down

0 comments on commit 4d886d6

Please sign in to comment.