Received: by 10.213.65.68 with SMTP id h4csp867530imn; Wed, 4 Apr 2018 08:34:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx48jyDeJZb7CMRicTPqRxMm2h8GnqxnNoJxeN0qHyZvieMVMX9ZDO+lcSWIEA4MNs1SD3WHH X-Received: by 10.99.107.65 with SMTP id g62mr2418534pgc.180.1522856053470; Wed, 04 Apr 2018 08:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522856053; cv=none; d=google.com; s=arc-20160816; b=PwAKHEIyRKf7Hz7aklWrsvNoXqxDoMWIPzOUv22325PYLDGimsH/BI8fG70hQDHNQW 7ADMKEWU1VswjLDesBGDV/GYPN+LXb6KkzBgmawKD6KdVSVMOYXBdmoLTtO2tLlm0yqn Ye5aW3U7h6W/13spnj0FKVb6udZ3//VOfB77T/rf904N2ElItqxHF8BB0oPHOoCesTx6 HGgixJ3s5S8X34bgvIJ84XjfVZrwEef45a/8FRbqCR5ey/SHi4tKaupJLo2yPDKFB5On NRpiRwoYkd5gftvdNQmXpB1/QcKlb9emlslXNj37kPF5sMrP6+3H6au/K5WDc8XGdrX3 Ywuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=1BT2j2Zh/jvfrIV0KPY/Px39Ajtqlru1m5Bk5zOiqjg=; b=w0269wix7olPDjrF2MDPtRDvRluugQcpIrP/pqymhuu25itoyDq20T86geFPk8Ew7D iT1oI2gJQqZhFinq3aDVdGLPYbA313PoXWxLSc8w0Y9LBqbHZw9Ge7jLKLEZzM9HzQGD Gid3JdxgkTNk1VN4jvhYGihmIZMfTQ+yhnUUVvFmf6jJf8lWUG8qR2FaeQCxeBelNun9 eqPCBrtqM/GLf/YsrOFySFFZHIWdMlEOSgW7fnLt8/TypRR/seBiZefOu9EXb+2Tefav dqubpJfV9zlyey6ExBcS6QMTdfBzxIgVkIckv2B5BW4xqs1ZVFeupkop1EvneCbCeRaA 41cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=i79wrFPs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1-v6si3339626pld.546.2018.04.04.08.33.58; Wed, 04 Apr 2018 08:34:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=i79wrFPs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751952AbeDDPcs (ORCPT + 99 others); Wed, 4 Apr 2018 11:32:48 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:46556 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751772AbeDDPco (ORCPT ); Wed, 4 Apr 2018 11:32:44 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w34FGd2E016339; Wed, 4 Apr 2018 15:32:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=1BT2j2Zh/jvfrIV0KPY/Px39Ajtqlru1m5Bk5zOiqjg=; b=i79wrFPs/Cx8HJVP0s+DPgrETrhBM0DnOTbHXNjbIJtP2cJAfK9pjN46JtyT14ZwRURW NhZ45jSYf0OhFzci3lQq39y65ImzgZNMwwyYnuds+IvdXR/oH3G0WalSwZO4ItCt4Ys7 YXfRWeamkgDM4L8H6vYn4w1c2laKFC9fmd9uo2zHjjtuLjzgIdCrti/q7iiQcIa3onsv fmDiNNnL7L9ffTLym4rS7ew/LcITuePZYwg1o/COgs6YAH30/7EtaGaPMmJbjrj5Lqy/ XNn+rDhHuf719xYZKp3d1RPDPjDtn5E9ptOJw8iDMo7wKQZdyK7V39z6na3lv59bLxyY HQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2h5175g4mh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Apr 2018 15:32:40 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w34FWepC003589 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Apr 2018 15:32:40 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w34FWcu4020812; Wed, 4 Apr 2018 15:32:38 GMT Received: from [192.168.1.164] (/98.246.252.205) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Apr 2018 08:32:38 -0700 Subject: Re: [PATCH 1/2] selftests/memfd/memfd_test.c: fix implicit declaration To: Anders Roxell Cc: shuah@kernel.org, linux-kselftest@vger.kernel.org, Linux Kernel Mailing List , David Herrmann References: <20180313114205.27714-1-anders.roxell@linaro.org> From: Mike Kravetz Message-ID: <204aed15-390c-f8eb-a248-d0f8305ab694@oracle.com> Date: Wed, 4 Apr 2018 08:32:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8852 signatures=668697 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804040153 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/04/2018 04:36 AM, Anders Roxell wrote: > On 14 March 2018 at 02:09, Mike Kravetz wrote: >> On 03/13/2018 04:42 AM, Anders Roxell wrote: >>> gcc warns about implicit declaration. >>> >>> gcc -D_FILE_OFFSET_BITS=64 -I../../../../include/uapi/ >>> -I../../../../include/ -I../../../../usr/include/ >>> memfd_test.c common.o -o memfd_test >>> memfd_test.c: In function ‘mfd_assert_get_seals’: >>> memfd_test.c:74:6: warning: implicit declaration of function ‘fcntl’ >>> [-Wimplicit-function-declaration] >>> r = fcntl(fd, F_GET_SEALS); >>> ^~~~~ >>> memfd_test.c: In function ‘mfd_assert_open’: >>> memfd_test.c:197:6: warning: implicit declaration of function ‘open’ >>> [-Wimplicit-function-declaration] >>> r = open(buf, flags, mode); >>> ^~~~ >>> memfd_test.c: In function ‘mfd_assert_write’: >>> memfd_test.c:328:6: warning: implicit declaration of function ‘fallocate’ >>> [-Wimplicit-function-declaration] >>> r = fallocate(fd, >>> ^~~~~~~~~ >>> >>> In the current code, we include the headers that the functions want >>> according to the man pages, and we add some defines that will be used if >>> they isn't found in glibc. The defines was added into the kernel source >>> in kernel >= 3.16 and glibc requires kernel header files >= 3.2. >>> >>> Fixes: 4f5ce5e8d7e2 ("selftests: add memfd_create() + sealing tests") >>> Signed-off-by: Anders Roxell >>> --- >>> tools/testing/selftests/memfd/memfd_test.c | 25 ++++++++++++++++++++++++- >>> 1 file changed, 24 insertions(+), 1 deletion(-) >>> >>> diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c >>> index 10baa1652fc2..0dbeb29c094c 100644 >>> --- a/tools/testing/selftests/memfd/memfd_test.c >>> +++ b/tools/testing/selftests/memfd/memfd_test.c >>> @@ -6,7 +6,6 @@ >>> #include >>> #include >>> #include >>> -#include >>> #include >>> #include >>> #include >>> @@ -14,13 +13,37 @@ >>> #include >>> #include >>> #include >>> +#include >>> #include >>> #include >>> #include >>> +#include >>> #include >> >> I suspect there is some guiding philosophy for selftests that I am >> unfamiliar with. However, it seems that tests should use as much >> of the header files in the current kernel source tree as possible. >> This change removes the include of a header in the current source >> tree . It replaces that with the header >> from the host system (and some other changes). >> >> To me, this seems like step in the wrong direction. But, I could >> be totally wrong and perhaps self tests should primarily target the >> host system header files. > > So in a way I agree with you. However, what was the design decisions > internal kernel headers vs. headers from Host System ? > For me it isn't clear how/when we use them, its a mix today is it not? I am unsure as well. Was hoping someone who was more involved in the development/design philosophy of self tests would chime in and comment. My thought that the tests should use more of the associated kernel header files is based on the fact that those header files 'should' be more aligned with the tests. The host system header files could be very different than those of the running kernel we are testing. > To ignore warnings with -Wno-implicit-function-declaration wont be an > alternative I think. I am not opposed to your changes. Again, was just hoping to discover what should be the direction/philosophy for header file use. -- Mike Kravetz