[PATCH] SUNRPC: Address kbuild warning in net/sunrpc/debugfs.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Cross-compile test on ARCH=mn10300:

In file included from include/linux/list.h:8:0,
                 from include/linux/wait.h:6,
                 from include/linux/fs.h:6,
                 from include/linux/debugfs.h:18,
                 from net/sunrpc/debugfs.c:7:
net/sunrpc/debugfs.c: In function 'fault_disconnect_write':
include/linux/kernel.h:723:17: warning: comparison of distinct pointer
types lacks a cast
    (void) (&_min1 == &_min2);  \
                   ^
>> net/sunrpc/debugfs.c:307:8: note: in expansion of macro 'min'
    len = min(len, sizeof(buffer) - 1);

Fixes: ('SUNRPC: Transport fault injection')
Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
---

This gets rid of the pointer magic hidden inside min(). But I've
never had this warning pop with my x86 gcc, so I can't confirm
whether this patch addresses the issue.

 net/sunrpc/debugfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index 7cc1b8a..e7b4d93 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -304,7 +304,8 @@ fault_disconnect_write(struct file *filp, const char __user *user_buf,
 {
 	char buffer[16];
 
-	len = min(len, sizeof(buffer) - 1);
+	if (len >= sizeof(buffer))
+		len = sizeof(buffer) - 1;
 	if (copy_from_user(buffer, user_buf, len))
 		return -EFAULT;
 	buffer[len] = '\0';

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux