Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5492368rwd; Mon, 5 Jun 2023 04:39:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7taGhzvDkZTCm7Rjpo204QYuSLPM6/dxWe5vpLXNA65bXkF9tB1Idq+0k7oj532qDhqvSs X-Received: by 2002:a17:90a:6a8c:b0:256:8825:d48f with SMTP id u12-20020a17090a6a8c00b002568825d48fmr2395518pjj.29.1685965152645; Mon, 05 Jun 2023 04:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685965152; cv=none; d=google.com; s=arc-20160816; b=F+AsYEKeATgJUwDIrnNy+sAexwbxH4AoaH858xt6CyhPVwYVH9txMEmN8bhSHtFBS7 NwtuRDsVwV0jNIHK4lxaDo23ZAxW0j7f6kuTXIHrF2fmadq4v3K70trfR0qbaTel/5yN KLsOBaMe4x+AFxQxDvAX/Gt7zAyTz+o6oEjehEXgD16Q6Z9j0guNCGdZL/HezePXuyhx kZViDZs395C9P/TU2/6Nx5/f6+UjnrG4VDT9OH9uLAnfg+Tem6gRB+TBRzzrFK8BSjMm t3jrhj3CLXyt2Dcao1i6mPh9pcRsWNEzGSM7lbZjaW7ONFtgleePqKsxW3AXzJigQMNs pIVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=fAIQEofIMC7v8RzKIvVCVe2spFdmLoNCeLo4DX8oh/0=; b=yd5Wx9mtOEvLyYvf8AeFc0gV2HNiNy9RtAkt8LEJmSnbuTPzqOVdhV0cObKytyoI6Z hY1+Qsx/KE7bFDa/DINAG4iQXf+BM87QcIEoDf24/gAt/mE8B1m8dUFB+KzCGw5Za5Ny KY3b7vjEyzjg5+PkfSh7R1r3+Z7YZW/Jpd5PkceWRuPNJ8OUpfkg4Tf6PNOo7Cuuc1xO kaFJPNzIzobc4UhXWVazjLH7e1/xYbvlfgUvWMiz0jNADjuf2Anh1elbPm67mNKgyL2C FxWX6Fnef+F9WqZpU5qrh0VuVJXWJmfIzHgY2muFiF2GJ0mAL+9bhG0tbPtJ8OUgJovD 5oxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WVZtc8+w; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a633e05000000b00502d825633asi5554446pga.639.2023.06.05.04.38.59; Mon, 05 Jun 2023 04:39:12 -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=@redhat.com header.s=mimecast20190719 header.b=WVZtc8+w; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232638AbjFELiH (ORCPT + 99 others); Mon, 5 Jun 2023 07:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232630AbjFELiC (ORCPT ); Mon, 5 Jun 2023 07:38:02 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25382F7 for ; Mon, 5 Jun 2023 04:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685965028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fAIQEofIMC7v8RzKIvVCVe2spFdmLoNCeLo4DX8oh/0=; b=WVZtc8+wZQgfAEElvxZ5NMYHBHnUMwUIiOl3hrgiaOJvO9mvxVVvsDrVx32Qd1AnfJH3YW 5pYIcY53c42JR5wbMcStZkXjJtciabapKX/XF6cH1kDvqz9FEWba7fPBwnNq43CVAzmW9S sb7rnC2GVJRTOO78Gm+iigC+BZIsJFw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-287-_vGzmP2NNl-hpfweRr2Ppw-1; Mon, 05 Jun 2023 07:37:07 -0400 X-MC-Unique: _vGzmP2NNl-hpfweRr2Ppw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f41a04a297so22780685e9.3 for ; Mon, 05 Jun 2023 04:37:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685965026; x=1688557026; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fAIQEofIMC7v8RzKIvVCVe2spFdmLoNCeLo4DX8oh/0=; b=YBbM9pW27yMxWXesTxAAOvI4GGa+LEOPKNbFCiEfx5JGIqxo89d0UOYAqKc4jnbhLV SLUwMYwCUZIvHTnbEF4WXO3sbEb9h8YSAgiqdHIMXkQwpdopOlFGSCQvy/6QGE1ZizAr WcSks2B8u3+2p9dPRJa9eUTfV0wlxMhszN/dV4b34IfTBwPn1JkJCXcnMLNV8f3qc7Xo x39zEEVJtdAWz8KomhuyZ4OJbU7tp1WSI1LDYzVeOtVbuAt4REpJS2dg0IMh6eOpDNf/ ne3j8FMHKmOcbt72wlt5kxUqbMg3l6vt1KuyNFvd5+31PAuiWovD0Ko5Xo7AUiN1jUIg fgKw== X-Gm-Message-State: AC+VfDxLcby79cSE+z5Zwc9ptjWJziPPulqSQvEXVNm6pR9PjpB3Ef/i LM1TvaRfdMIgY/2lINVHlZNnc1sGeZlxDiUZtBDwaAVyuNVQB3D8n2nbRZPnChf3Y7xRuM5Pv3t o+uBN1kV9uawxSuk81s4ZW/0Y X-Received: by 2002:a7b:ce89:0:b0:3f6:552:8722 with SMTP id q9-20020a7bce89000000b003f605528722mr6649061wmj.18.1685965026172; Mon, 05 Jun 2023 04:37:06 -0700 (PDT) X-Received: by 2002:a7b:ce89:0:b0:3f6:552:8722 with SMTP id q9-20020a7bce89000000b003f605528722mr6649046wmj.18.1685965025766; Mon, 05 Jun 2023 04:37:05 -0700 (PDT) Received: from ?IPV6:2003:cb:c737:8f00:ed9:16b8:4e22:5820? (p200300cbc7378f000ed916b84e225820.dip0.t-ipconnect.de. [2003:cb:c737:8f00:ed9:16b8:4e22:5820]) by smtp.gmail.com with ESMTPSA id u4-20020a7bc044000000b003f70a7b4537sm14074087wmc.36.2023.06.05.04.37.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jun 2023 04:37:05 -0700 (PDT) Message-ID: Date: Mon, 5 Jun 2023 13:37:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2 06/11] selftests/mm: fix two -Wformat-security warnings in uffd builds Content-Language: en-US To: John Hubbard , Andrew Morton Cc: Peter Xu , Shuah Khan , Nathan Chancellor , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, LKML References: <20230603021558.95299-1-jhubbard@nvidia.com> <20230603021558.95299-7-jhubbard@nvidia.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230603021558.95299-7-jhubbard@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On 03.06.23 04:15, John Hubbard wrote: > The uffd tests generate two compile time warnings from clang's > -Wformat-security setting. These trigger at the call sites for > uffd_test_start() and uffd_test_skip(). > > 1) Fix the uffd_test_start() issue by removing the intermediate > test_name variable (thanks to David Hildenbrand for showing how to do > this). > > 2) Fix the uffd_test_skip() issue by observing that there is no need for > a macro and a variable args approach, because all callers of > uffd_test_skip() pass in a simple char* string, without any format > specifiers. So just change uffd_test_skip() into a regular C function. > > Cc: David Hildenbrand > Cc: Peter Xu > Signed-off-by: John Hubbard > --- > tools/testing/selftests/mm/uffd-unit-tests.c | 16 ++++++---------- > 1 file changed, 6 insertions(+), 10 deletions(-) > > diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c > index 269c86768a02..04d91f144d1c 100644 > --- a/tools/testing/selftests/mm/uffd-unit-tests.c > +++ b/tools/testing/selftests/mm/uffd-unit-tests.c > @@ -109,12 +109,11 @@ static void uffd_test_pass(void) > ksft_inc_fail_cnt(); \ > } while (0) > > -#define uffd_test_skip(...) do { \ > - printf("skipped [reason: "); \ > - printf(__VA_ARGS__); \ > - printf("]\n"); \ > - ksft_inc_xskip_cnt(); \ > - } while (0) > +static void uffd_test_skip(const char *message) > +{ > + printf("skipped [reason: %s]\n", message); > + ksft_inc_xskip_cnt(); > +} > > /* > * Returns 1 if specific userfaultfd supported, 0 otherwise. Note, we'll > @@ -1149,7 +1148,6 @@ int main(int argc, char *argv[]) > uffd_test_case_t *test; > mem_type_t *mem_type; > uffd_test_args_t args; > - char test_name[128]; > const char *errmsg; > int has_uffd, opt; > int i, j; > @@ -1192,10 +1190,8 @@ int main(int argc, char *argv[]) > mem_type = &mem_types[j]; > if (!(test->mem_targets & mem_type->mem_flag)) > continue; > - snprintf(test_name, sizeof(test_name), > - "%s on %s", test->name, mem_type->name); > > - uffd_test_start(test_name); > + uffd_test_start("%s on %s", test->name, mem_type->name); > if (!uffd_feature_supported(test)) { > uffd_test_skip("feature missing"); > continue; Reviewed-by: David Hildenbrand -- Cheers, David / dhildenb