From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93EE2C7EE24 for ; Mon, 5 Jun 2023 11:38:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232646AbjFELiI (ORCPT ); Mon, 5 Jun 2023 07:38:08 -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-Google-Smtp-Source: ACHHUZ5VGDnaIen5lKCJ5CKH0EbB5zYnqK07QWbo8gZv5KqwMjzuCPkiSLwEQ2p/qW8E3PH5x2JDyg== 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 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