Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5504286rwb; Tue, 1 Aug 2023 03:51:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFnvv8tv+Nn+GJy2l7u28aE9VJ2/f4ieX3PBl9Dz5ds/l7oorIK9hAZYCNSGEoaCuh/4zLA X-Received: by 2002:a05:6300:8086:b0:137:e595:830f with SMTP id ap6-20020a056300808600b00137e595830fmr11209777pzc.57.1690887114041; Tue, 01 Aug 2023 03:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690887114; cv=none; d=google.com; s=arc-20160816; b=cCZ1A1kvCJ7zV9jO4UXV7CbZZe0pqBBNwhGx5zxvf8H2nlPjeaKWBoqugGkMxZxIRo Va3lYtidMMv1Ts2+33CFZ4TviMVGpKXpR40ldkuA4e150ERs3F2o0oMPPUd9ggwjJQdM JiuO1GRAhAIRMp/mQjtMSbO7M6nVnTGtlow9SlSec1HtscJzG3dxXydOqpW2R/41CSMQ TFpphAxxmk3QN1o2jfNESWTe/pBWd6SoSRnR9rMs9Xj0vv7XNRyCLKuqzOeWQQROAPy8 WKFaBlTYLXn6lSKPzFwdMwR71ll0gGek94wufDrVRCerYfZfEtF3xbJz2esrC5mSESdU hzNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=mKkcfY5zqpLKFBoScbc+V2BRmzXnuf03ZpIGPeD6uB8=; fh=0JPIYVoFxjdDuAg4P1fySgROU7ngb82b/N4MymT/i7s=; b=lzfpY+3FcLKVgauVGzXunTdJRlrlc6g6x98byV11TDbaQEWDRfBGIFmmIt9bhKBv0t UsAhAKbUAnJwIBN9Q/XQtUIaQHEuPmtjpiinQvbI7h/ZDNHSuJ68VKT6w39uZ19Sl+Ak GJfYxxRFPrLuYGZm8LI8ArpoQm2/AgfcDF2z+ifRAIUj/x0sp5nPu+6EZD8yn8N+hhni dJCi3EFh7wHqresRjic+2UZwiKOfEkP0xRDjS9QBGoLFIOaNnu7d8Qq+i405Fp6YU9FL 8X+Io6/ZFV8OGiknkBqcGgT3aN26GVyZQHRlyh76sFu8hXp/xhCthIQ8DaOvtRwEmtjI DuAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=gkpHN0vg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020a170903124e00b001b55070e154si5426775plh.96.2023.08.01.03.51.31; Tue, 01 Aug 2023 03:51:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=gkpHN0vg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234128AbjHAKVp (ORCPT + 99 others); Tue, 1 Aug 2023 06:21:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232788AbjHAKVW (ORCPT ); Tue, 1 Aug 2023 06:21:22 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77ED05276; Tue, 1 Aug 2023 03:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1690885059; bh=mKkcfY5zqpLKFBoScbc+V2BRmzXnuf03ZpIGPeD6uB8=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=gkpHN0vgZPP+Bm7wa32u0lXIRovoBU79/16NvzMf77oQ/cOvUDBVEdYDHlfj/2bkX Juql0hjSf1j3hqbpTnhu1sfJHloPN2BDmmnGRErWgzXMwfjaX8WY+peLolVN6poUGm VnEvuEwbkEXIujjDmLYcCMMXzF9tun1kN8rucCDU= Date: Tue, 1 Aug 2023 12:17:33 +0200 (GMT+02:00) From: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh_?= To: Zhangjin Wu Cc: linux@weissschuh.net, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, tanyuan@tinylab.org, w@1wt.eu Message-ID: <9c47fc05-ba20-4d90-9d11-840f77c35aaa@t-8ch.de> In-Reply-To: <20230801101508.75571-1-falcon@tinylab.org> References: <6d67a8ed-8cb6-4ab7-8db0-68269981f8df@t-8ch.de> <20230801101508.75571-1-falcon@tinylab.org> Subject: Re: [PATCH v2 07/10] selftests/nolibc: avoid unused arguments warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Correlation-ID: <9c47fc05-ba20-4d90-9d11-840f77c35aaa@t-8ch.de> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Aug 1, 2023 12:15:27 Zhangjin Wu : > Hi, Thomas > >> On 2023-08-01 10:07:28+0200, Willy Tarreau wrote: >>> On Tue, Aug 01, 2023 at 07:30:14AM +0200, Thomas Wei=C3=9Fschuh wrote: >>>> This warnings will be enabled later so avoid triggering it. >>>> >>>> Signed-off-by: Thomas Wei=C3=9Fschuh >>>> --- >>>> tools/testing/selftests/nolibc/nolibc-test.c | 3 ++- >>>> 1 file changed, 2 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/test= ing/selftests/nolibc/nolibc-test.c >>>> index 53a3773c7790..cb17cccd0bc7 100644 >>>> --- a/tools/testing/selftests/nolibc/nolibc-test.c >>>> +++ b/tools/testing/selftests/nolibc/nolibc-test.c >>>> @@ -1089,7 +1089,8 @@ static int smash_stack(void) >>>> =C2=A0=C2=A0=C2=A0 return 1; >>>> } >>>> >>>> -static int run_protection(int min, int max) >>>> +static int run_protection(int __attribute__((unused)) min, >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 int __attribute__((unused)) max) >>> >>> This one is used to silence -Wunused-parameter I guess. >> >> Yep. >> >>> It's one of >>> the rare warnings that I find totally useless in field, because it's >>> simply against the principle of using function pointers with different >>> functions having the same interface but different implementations. As >>> your code evolves you end up with unused on absolutely *all* of the >>> arguments of *all* such functions, which makes them a real pain to add >>> and tends to encourage poor practices such as excessive code reuse just >>> by laziness or boredom. BTW it's one of those that are already disabled >>> in the kernel and we could very well do the same here. >> >> It's indeed unfortunate. >> >> As long as we don't have too many of them I would prefer to keep the >> explicit annotations. While they are ugly we then can still reap the >> positive aspects of the warning. >> >> This is where -std=3Dc89 bites us. With extensions (or C2X) we could als= o >> just leave off the argument name to mark it as unused: >> =C2=A0=C2=A0=C2=A0 run_protection(int, int) > > what about further simply ignore the arguments like we did for main(void)= ? That doesn't work because it is stored as a function pointer in the testcas= es array. And these members all take the two parameters.