Skip to content

Commit

Permalink
ipv6: coding style: comparison for equality with NULL
Browse files Browse the repository at this point in the history
The ipv6 code uses a mixture of coding styles. In some instances check for NULL
pointer is done as x == NULL and sometimes as !x. !x is preferred according to
checkpatch and this patch makes the code consistent by adopting the latter
form.

No changes detected by objdiff.

Signed-off-by: Ian Morris <ipm@chirality.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
lz7tq4 authored and davem330 committed Mar 31, 2015
1 parent bc48878 commit 63159f2
Show file tree
Hide file tree
Showing 25 changed files with 173 additions and 174 deletions.
88 changes: 44 additions & 44 deletions net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
return ERR_PTR(-EINVAL);

ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL);
if (ndev == NULL)
if (!ndev)
return ERR_PTR(err);

rwlock_init(&ndev->lock);
Expand All @@ -346,7 +346,7 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
ndev->cnf.mtu6 = dev->mtu;
ndev->cnf.sysctl = NULL;
ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl);
if (ndev->nd_parms == NULL) {
if (!ndev->nd_parms) {
kfree(ndev);
return ERR_PTR(err);
}
Expand Down Expand Up @@ -481,7 +481,7 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,

nlh = nlmsg_put(skb, portid, seq, event, sizeof(struct netconfmsg),
flags);
if (nlh == NULL)
if (!nlh)
return -EMSGSIZE;

ncm = nlmsg_data(nlh);
Expand Down Expand Up @@ -519,7 +519,7 @@ void inet6_netconf_notify_devconf(struct net *net, int type, int ifindex,
int err = -ENOBUFS;

skb = nlmsg_new(inet6_netconf_msgsize_devconf(type), GFP_ATOMIC);
if (skb == NULL)
if (!skb)
goto errout;

err = inet6_netconf_fill_devconf(skb, ifindex, devconf, 0, 0,
Expand Down Expand Up @@ -574,18 +574,18 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
break;
default:
dev = __dev_get_by_index(net, ifindex);
if (dev == NULL)
if (!dev)
goto errout;
in6_dev = __in6_dev_get(dev);
if (in6_dev == NULL)
if (!in6_dev)
goto errout;
devconf = &in6_dev->cnf;
break;
}

err = -ENOBUFS;
skb = nlmsg_new(inet6_netconf_msgsize_devconf(-1), GFP_ATOMIC);
if (skb == NULL)
if (!skb)
goto errout;

err = inet6_netconf_fill_devconf(skb, ifindex, devconf,
Expand Down Expand Up @@ -854,7 +854,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr,

ifa = kzalloc(sizeof(struct inet6_ifaddr), GFP_ATOMIC);

if (ifa == NULL) {
if (!ifa) {
ADBG("ipv6_add_addr: malloc failed\n");
err = -ENOBUFS;
goto out;
Expand Down Expand Up @@ -1558,7 +1558,7 @@ int ipv6_chk_addr_and_flags(struct net *net, const struct in6_addr *addr,
: ifp->flags;
if (ipv6_addr_equal(&ifp->addr, addr) &&
!(ifp_flags&banned_flags) &&
(dev == NULL || ifp->idev->dev == dev ||
(!dev || ifp->idev->dev == dev ||
!(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) {
rcu_read_unlock_bh();
return 1;
Expand All @@ -1580,7 +1580,7 @@ static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
if (!net_eq(dev_net(ifp->idev->dev), net))
continue;
if (ipv6_addr_equal(&ifp->addr, addr)) {
if (dev == NULL || ifp->idev->dev == dev)
if (!dev || ifp->idev->dev == dev)
return true;
}
}
Expand Down Expand Up @@ -1649,7 +1649,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *add
if (!net_eq(dev_net(ifp->idev->dev), net))
continue;
if (ipv6_addr_equal(&ifp->addr, addr)) {
if (dev == NULL || ifp->idev->dev == dev ||
if (!dev || ifp->idev->dev == dev ||
!(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) {
result = ifp;
in6_ifa_hold(ifp);
Expand Down Expand Up @@ -2114,7 +2114,7 @@ static struct rt6_info *addrconf_get_prefix_route(const struct in6_addr *pfx,
struct fib6_table *table;

table = fib6_get_table(dev_net(dev), RT6_TABLE_PREFIX);
if (table == NULL)
if (!table)
return NULL;

read_lock_bh(&table->tb6_lock);
Expand Down Expand Up @@ -2278,7 +2278,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)

in6_dev = in6_dev_get(dev);

if (in6_dev == NULL) {
if (!in6_dev) {
net_dbg_ratelimited("addrconf: device %s not configured\n",
dev->name);
return;
Expand Down Expand Up @@ -2377,7 +2377,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)

ifp = ipv6_get_ifaddr(net, &addr, dev, 1);

if (ifp == NULL && valid_lft) {
if (!ifp && valid_lft) {
int max_addresses = in6_dev->cnf.max_addresses;

#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
Expand Down Expand Up @@ -2486,7 +2486,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
dev = __dev_get_by_index(net, ireq.ifr6_ifindex);

err = -ENODEV;
if (dev == NULL)
if (!dev)
goto err_exit;

#if IS_ENABLED(CONFIG_IPV6_SIT)
Expand Down Expand Up @@ -2658,7 +2658,7 @@ static int inet6_addr_del(struct net *net, int ifindex, u32 ifa_flags,
return -ENODEV;

idev = __in6_dev_get(dev);
if (idev == NULL)
if (!idev)
return -ENXIO;

read_lock_bh(&idev->lock);
Expand Down Expand Up @@ -2810,7 +2810,7 @@ static void init_loopback(struct net_device *dev)
ASSERT_RTNL();

idev = ipv6_find_idev(dev);
if (idev == NULL) {
if (!idev) {
pr_debug("%s: add_dev failed\n", __func__);
return;
}
Expand Down Expand Up @@ -3019,7 +3019,7 @@ static void addrconf_sit_config(struct net_device *dev)
*/

idev = ipv6_find_idev(dev);
if (idev == NULL) {
if (!idev) {
pr_debug("%s: add_dev failed\n", __func__);
return;
}
Expand All @@ -3044,7 +3044,7 @@ static void addrconf_gre_config(struct net_device *dev)
ASSERT_RTNL();

idev = ipv6_find_idev(dev);
if (idev == NULL) {
if (!idev) {
pr_debug("%s: add_dev failed\n", __func__);
return;
}
Expand Down Expand Up @@ -3241,7 +3241,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
neigh_ifdown(&nd_tbl, dev);

idev = __in6_dev_get(dev);
if (idev == NULL)
if (!idev)
return -ENODEV;

/*
Expand Down Expand Up @@ -3996,7 +3996,7 @@ inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh)

ifm = nlmsg_data(nlh);
pfx = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL], &peer_pfx);
if (pfx == NULL)
if (!pfx)
return -EINVAL;

ifa_flags = tb[IFA_FLAGS] ? nla_get_u32(tb[IFA_FLAGS]) : ifm->ifa_flags;
Expand Down Expand Up @@ -4108,7 +4108,7 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)

ifm = nlmsg_data(nlh);
pfx = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL], &peer_pfx);
if (pfx == NULL)
if (!pfx)
return -EINVAL;

if (tb[IFA_CACHEINFO]) {
Expand All @@ -4123,7 +4123,7 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)
}

dev = __dev_get_by_index(net, ifm->ifa_index);
if (dev == NULL)
if (!dev)
return -ENODEV;

ifa_flags = tb[IFA_FLAGS] ? nla_get_u32(tb[IFA_FLAGS]) : ifm->ifa_flags;
Expand All @@ -4133,7 +4133,7 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)
IFA_F_NOPREFIXROUTE | IFA_F_MCAUTOJOIN;

ifa = ipv6_get_ifaddr(net, pfx, dev, 1);
if (ifa == NULL) {
if (!ifa) {
/*
* It would be best to check for !NLM_F_CREATE here but
* userspace already relies on not having to provide this.
Expand Down Expand Up @@ -4208,7 +4208,7 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
u32 preferred, valid;

nlh = nlmsg_put(skb, portid, seq, event, sizeof(struct ifaddrmsg), flags);
if (nlh == NULL)
if (!nlh)
return -EMSGSIZE;

put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope),
Expand Down Expand Up @@ -4269,7 +4269,7 @@ static int inet6_fill_ifmcaddr(struct sk_buff *skb, struct ifmcaddr6 *ifmca,
scope = RT_SCOPE_SITE;

nlh = nlmsg_put(skb, portid, seq, event, sizeof(struct ifaddrmsg), flags);
if (nlh == NULL)
if (!nlh)
return -EMSGSIZE;

put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
Expand All @@ -4295,7 +4295,7 @@ static int inet6_fill_ifacaddr(struct sk_buff *skb, struct ifacaddr6 *ifaca,
scope = RT_SCOPE_SITE;

nlh = nlmsg_put(skb, portid, seq, event, sizeof(struct ifaddrmsg), flags);
if (nlh == NULL)
if (!nlh)
return -EMSGSIZE;

put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
Expand Down Expand Up @@ -4468,7 +4468,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh)
goto errout;

addr = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL], &peer);
if (addr == NULL) {
if (!addr) {
err = -EINVAL;
goto errout;
}
Expand Down Expand Up @@ -4511,7 +4511,7 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
int err = -ENOBUFS;

skb = nlmsg_new(inet6_ifaddr_msgsize(), GFP_ATOMIC);
if (skb == NULL)
if (!skb)
goto errout;

err = inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0);
Expand Down Expand Up @@ -4664,24 +4664,24 @@ static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev)
if (nla_put(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci))
goto nla_put_failure;
nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32));
if (nla == NULL)
if (!nla)
goto nla_put_failure;
ipv6_store_devconf(&idev->cnf, nla_data(nla), nla_len(nla));

/* XXX - MC not implemented */

nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64));
if (nla == NULL)
if (!nla)
goto nla_put_failure;
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla));

nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64));
if (nla == NULL)
if (!nla)
goto nla_put_failure;
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla));

nla = nla_reserve(skb, IFLA_INET6_TOKEN, sizeof(struct in6_addr));
if (nla == NULL)
if (!nla)
goto nla_put_failure;

if (nla_put_u8(skb, IFLA_INET6_ADDR_GEN_MODE, idev->addr_gen_mode))
Expand Down Expand Up @@ -4727,7 +4727,7 @@ static int inet6_set_iftoken(struct inet6_dev *idev, struct in6_addr *token)

ASSERT_RTNL();

if (token == NULL)
if (!token)
return -EINVAL;
if (ipv6_addr_any(token))
return -EINVAL;
Expand Down Expand Up @@ -4843,7 +4843,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
void *protoinfo;

nlh = nlmsg_put(skb, portid, seq, event, sizeof(*hdr), flags);
if (nlh == NULL)
if (!nlh)
return -EMSGSIZE;

hdr = nlmsg_data(nlh);
Expand All @@ -4862,7 +4862,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
nla_put_u32(skb, IFLA_LINK, dev->iflink)))
goto nla_put_failure;
protoinfo = nla_nest_start(skb, IFLA_PROTINFO);
if (protoinfo == NULL)
if (!protoinfo)
goto nla_put_failure;

if (inet6_fill_ifla6_attrs(skb, idev) < 0)
Expand Down Expand Up @@ -4923,7 +4923,7 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
int err = -ENOBUFS;

skb = nlmsg_new(inet6_if_nlmsg_size(), GFP_ATOMIC);
if (skb == NULL)
if (!skb)
goto errout;

err = inet6_fill_ifinfo(skb, idev, 0, 0, event, 0);
Expand Down Expand Up @@ -4956,7 +4956,7 @@ static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
struct prefix_cacheinfo ci;

nlh = nlmsg_put(skb, portid, seq, event, sizeof(*pmsg), flags);
if (nlh == NULL)
if (!nlh)
return -EMSGSIZE;

pmsg = nlmsg_data(nlh);
Expand Down Expand Up @@ -4995,7 +4995,7 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
int err = -ENOBUFS;

skb = nlmsg_new(inet6_prefix_nlmsg_size(), GFP_ATOMIC);
if (skb == NULL)
if (!skb)
goto errout;

err = inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0);
Expand Down Expand Up @@ -5596,7 +5596,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
char path[sizeof("net/ipv6/conf/") + IFNAMSIZ];

t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL);
if (t == NULL)
if (!t)
goto out;

for (i = 0; t->addrconf_vars[i].data; i++) {
Expand All @@ -5608,7 +5608,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
snprintf(path, sizeof(path), "net/ipv6/conf/%s", dev_name);

t->sysctl_header = register_net_sysctl(net, path, t->addrconf_vars);
if (t->sysctl_header == NULL)
if (!t->sysctl_header)
goto free;

p->sysctl = t;
Expand All @@ -5624,7 +5624,7 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)
{
struct addrconf_sysctl_table *t;

if (p->sysctl == NULL)
if (!p->sysctl)
return;

t = p->sysctl;
Expand Down Expand Up @@ -5667,11 +5667,11 @@ static int __net_init addrconf_init_net(struct net *net)
struct ipv6_devconf *all, *dflt;

all = kmemdup(&ipv6_devconf, sizeof(ipv6_devconf), GFP_KERNEL);
if (all == NULL)
if (!all)
goto err_alloc_all;

dflt = kmemdup(&ipv6_devconf_dflt, sizeof(ipv6_devconf_dflt), GFP_KERNEL);
if (dflt == NULL)
if (!dflt)
goto err_alloc_dflt;

/* these will be inherited by all namespaces */
Expand Down
Loading

0 comments on commit 63159f2

Please sign in to comment.