Skip to content

Commit

Permalink
[NETNS]: Fix compiler error in net_namespace.c
Browse files Browse the repository at this point in the history
Because net_free is called by copy_net_ns before its declaration, the
compiler gives an error. This patch puts net_free before copy_net_ns
to fix this.

The compiler error:
net/core/net_namespace.c: In function 'copy_net_ns':
net/core/net_namespace.c:97: error: implicit declaration of function 'net_free'
net/core/net_namespace.c: At top level:
net/core/net_namespace.c:104: warning: conflicting types for 'net_free'
net/core/net_namespace.c:104: error: static declaration of 'net_free' follows non-static declaration
net/core/net_namespace.c:97: error: previous implicit declaration of 'net_free' was here

The error was introduced by the '[NET]: Hide the dead code in the
net_namespace.c' patch (6a1a3b9).

Signed-off-by: Johann Felix Soden <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
johfel authored and David S. Miller committed Nov 7, 2007
1 parent d012753 commit 45a19b0
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ static struct net *net_alloc(void)
return kmem_cache_zalloc(net_cachep, GFP_KERNEL);
}

static void net_free(struct net *net)
{
if (!net)
return;

if (unlikely(atomic_read(&net->use_count) != 0)) {
printk(KERN_EMERG "network namespace not free! Usage: %d\n",
atomic_read(&net->use_count));
return;
}

kmem_cache_free(net_cachep, net);
}

struct net *copy_net_ns(unsigned long flags, struct net *old_net)
{
struct net *new_net = NULL;
Expand Down Expand Up @@ -100,20 +114,6 @@ struct net *copy_net_ns(unsigned long flags, struct net *old_net)
return new_net;
}

static void net_free(struct net *net)
{
if (!net)
return;

if (unlikely(atomic_read(&net->use_count) != 0)) {
printk(KERN_EMERG "network namespace not free! Usage: %d\n",
atomic_read(&net->use_count));
return;
}

kmem_cache_free(net_cachep, net);
}

static void cleanup_net(struct work_struct *work)
{
struct pernet_operations *ops;
Expand Down

0 comments on commit 45a19b0

Please sign in to comment.