Skip to content

Commit 542d306

Browse files
arndbdavem330
authored andcommitted
socket: fix unused-function warning
When procfs is disabled, the fdinfo code causes a harmless warning: net/socket.c:1000:13: error: 'sock_show_fdinfo' defined but not used [-Werror=unused-function] static void sock_show_fdinfo(struct seq_file *m, struct file *f) Move the function definition up so we can use a single #ifdef around it. Fixes: b465334 ("net: Allow to show socket-specific information in /proc/[pid]/fdinfo/[fd]") Suggested-by: Al Viro <[email protected]> Acked-by: Kirill Tkhai <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent daea5b4 commit 542d306

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

net/socket.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,18 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
128128
static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
129129
struct pipe_inode_info *pipe, size_t len,
130130
unsigned int flags);
131-
static void sock_show_fdinfo(struct seq_file *m, struct file *f);
131+
132+
#ifdef CONFIG_PROC_FS
133+
static void sock_show_fdinfo(struct seq_file *m, struct file *f)
134+
{
135+
struct socket *sock = f->private_data;
136+
137+
if (sock->ops->show_fdinfo)
138+
sock->ops->show_fdinfo(m, sock);
139+
}
140+
#else
141+
#define sock_show_fdinfo NULL
142+
#endif
132143

133144
/*
134145
* Socket files have a set of 'special' operations as well as the generic file ones. These don't appear
@@ -151,9 +162,7 @@ static const struct file_operations socket_file_ops = {
151162
.sendpage = sock_sendpage,
152163
.splice_write = generic_splice_sendpage,
153164
.splice_read = sock_splice_read,
154-
#ifdef CONFIG_PROC_FS
155165
.show_fdinfo = sock_show_fdinfo,
156-
#endif
157166
};
158167

159168
/*
@@ -997,14 +1006,6 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from)
9971006
return res;
9981007
}
9991008

1000-
static void sock_show_fdinfo(struct seq_file *m, struct file *f)
1001-
{
1002-
struct socket *sock = f->private_data;
1003-
1004-
if (sock->ops->show_fdinfo)
1005-
sock->ops->show_fdinfo(m, sock);
1006-
}
1007-
10081009
/*
10091010
* Atomic setting of ioctl hooks to avoid race
10101011
* with module unload.

0 commit comments

Comments
 (0)