From patchwork Wed Oct 16 08:01:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 1177674 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46tPs54BBbz9sNx for ; Wed, 16 Oct 2019 19:02:00 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 245F83C1CB4 for ; Wed, 16 Oct 2019 10:01:57 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id 8D4853C14F6 for ; Wed, 16 Oct 2019 10:01:55 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 62D37200B39 for ; Wed, 16 Oct 2019 10:01:53 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C08373001571; Wed, 16 Oct 2019 08:01:51 +0000 (UTC) Received: from dhcp-3-207.nay.redhat.com (dhcp-3-207.nay.redhat.com [10.66.3.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6997760166; Wed, 16 Oct 2019 08:01:50 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Wed, 16 Oct 2019 16:01:46 +0800 Message-Id: <20191016080146.18657-1-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 16 Oct 2019 08:01:51 +0000 (UTC) X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v2] include: undefine _LINUX_TYPES_H if including old sys/capability.h X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" In some of the libcap-devel(1.96~2.16) versions, it defines the _LINUX_TYPES_H macro that makes ltp-lib can not include linux/types.h essentially. # cat -n /usr/include/sys/capability.h ... 25 /* 26 * Make sure we can be included from userland by preventing 27 * capability.h from including other kernel headers 28 */ 29 #define _LINUX_TYPES_H To get rid of this compiling errors on rhel6(libcap-devel-2.16) series platform, here undefine _LINUX_TYPES_H if test included that old sys/capability.h. == Error log == In file included from ../include/tst_netlink.h:26, from tst_crypto.c:13: /usr/include/linux/netlink.h:45: error: expected specifier-qualifier-list before ‘__u16’ /usr/include/linux/netlink.h:135: error: expected specifier-qualifier-list before ‘__u16’ tst_crypto.c: In function ‘tst_crypto_recv_ack’: tst_crypto.c:46: error: ‘struct nlmsghdr’ has no member named ‘nlmsg_seq’ tst_crypto.c:47: error: ‘struct nlmsghdr’ has no member named ‘nlmsg_type’ tst_crypto.c:47: error: ‘struct nlmsghdr’ has no member named ‘nlmsg_seq’ tst_crypto.c:55: error: ‘struct nlmsghdr’ has no member named ‘nlmsg_type’ tst_crypto.c:58: error: ‘struct nlmsghdr’ has no member named ‘nlmsg_type’ tst_crypto.c:58: error: ‘struct nlmsghdr’ has no member named ‘nlmsg_seq’ tst_crypto.c: In function ‘tst_crypto_add_alg’: ... make: *** [tst_crypto.o] Error 1 Reported-by: Ping Fang Signed-off-by: Li Wang Cc: Ping Fang Cc: Richard Palethorpe Acked-by: Richard Palethorpe --- include/lapi/capability.h | 8 ++++++++ m4/ltp-cap.m4 | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/lapi/capability.h b/include/lapi/capability.h index dac233d84..8833f0605 100644 --- a/include/lapi/capability.h +++ b/include/lapi/capability.h @@ -10,6 +10,14 @@ #ifdef HAVE_SYS_CAPABILITY_H # include +/** + * Some old libcap-devel(1.96~2.16) define _LINUX_TYPES_H in + * sys/capability.h that makes ltp-lib cann't include linux/types.h + * essentially. Here undefine it if include such old header-file. + */ +# ifndef HAVE_NEWER_LIBCAP +# undef _LINUX_TYPES_H +# endif #endif #ifndef CAP_NET_RAW diff --git a/m4/ltp-cap.m4 b/m4/ltp-cap.m4 index 02d3cac8c..4981e843d 100644 --- a/m4/ltp-cap.m4 +++ b/m4/ltp-cap.m4 @@ -1,6 +1,6 @@ dnl SPDX-License-Identifier: GPL-2.0-or-later dnl Copyright (c) Cisco Systems Inc., 2009 -dnl Copyright (c) Linux Test Project, 2010 +dnl Copyright (c) Linux Test Project, 2019 dnl Author: Ngie Cooper AC_DEFUN([LTP_CHECK_CAPABILITY_SUPPORT],[ @@ -14,4 +14,19 @@ if test "x$cap_libs" != x; then AC_DEFINE(HAVE_LIBCAP) fi AC_SUBST(CAP_LIBS,$cap_libs) + +AH_TEMPLATE(HAVE_NEWER_LIBCAP, +[Define to 1 if you have newer libcap-2 installed.]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +#include +#include +int main(void) { + __u16 a; + __u32 b; + return 0; +}])],[has_newer_libcap="yes"]) + +if test "x$has_newer_libcap" = xyes; then + AC_DEFINE(HAVE_NEWER_LIBCAP) +fi ])