From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751388Ab3LOOka (ORCPT ); Sun, 15 Dec 2013 09:40:30 -0500 Received: from mailp.voltaire.com ([193.47.165.129]:55965 "EHLO mellanox.co.il" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750825Ab3LOOk3 (ORCPT ); Sun, 15 Dec 2013 09:40:29 -0500 From: Doron Tsur To: linux-kernel@vger.kernel.org Cc: itaib@mellanox.com, Doron Tsur Subject: [PATCH] include/uapi/linux/netlink.h -Wall -Wextra -Werror support fix Date: Sun, 15 Dec 2013 16:40:09 +0200 Message-Id: <1387118409-30636-1-git-send-email-doront@mellanox.com> X-Mailer: git-send-email 1.7.8.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For code using: #include NLMSG_OK -I/include Tested-by: Doron Tsur Test log: Compilation environments: Ubuntu 13.10, x86_64, gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 Ubuntu 13.04, x86_64, gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3 [ -ftrack-macro-expansion=2 issue submitted: gcc.gnu.org/bugzilla/show_bug.cgi?id=59495 ] Kernel headers installed at: make -C .../linux-stable headers_install \ INSTALL_HDR_PATH=/builds/kernel_tests_user_headers/ Pre-patch compilation: gcc -Wall -Wextra -Werror -I/builds/kernel_tests_pre_patch_user_headers/include include-uapi-linux-netlink.h.test.c In file included from include-uapi-linux-netlink.h.test.c:2:0: include-uapi-linux-netlink.h.test.c: In function ‘main’: /builds/kernel_tests_pre_patch_user_headers/include/linux/netlink.h:89:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] (nlh)->nlmsg_len <= (len)) ^ include-uapi-linux-netlink.h.test.c:26:5: note: in expansion of macro ‘NLMSG_OK’ NLMSG_OK(&auxiliary_netlink_header, active_len)); ^ cc1: all warnings being treated as errors Post-patch: $ gcc -Wall -Wextra -Werror -I/builds/kernel_tests_user_headers/include/ include-uapi-linux-netlink.h.test.c $ ./a.out nlmsg_len= 1, len = 1 NLMSG_OK(nlh,len) test result: 0 nlmsg_len= 1, len = 3000 NLMSG_OK(nlh,len) test result: 0 nlmsg_len= 3000, len = 1 NLMSG_OK(nlh,len) test result: 0 nlmsg_len= 3000, len = 3000 NLMSG_OK(nlh,len) test result: 1 Signed-off-by: Doron Tsur --- include/uapi/linux/netlink.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/uapi/linux/netlink.h b/include/uapi/linux/netlink.h index 1a85940..1884d4e 100644 --- a/include/uapi/linux/netlink.h +++ b/include/uapi/linux/netlink.h @@ -86,7 +86,7 @@ struct nlmsghdr { (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ - (nlh)->nlmsg_len <= (len)) + (int)(nlh)->nlmsg_len <= (len)) #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len))) #define NLMSG_NOOP 0x1 /* Nothing. */ -- 1.7.1