Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp929662iog; Thu, 30 Jun 2022 13:06:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sibZihDZOAvMTHrp8z9rSiqKN1H7dIGSZG42R+VoWKr+RV0FutYbWEFc+bsH/QKpwEJq+x X-Received: by 2002:a17:907:7f8c:b0:726:2c53:2f82 with SMTP id qk12-20020a1709077f8c00b007262c532f82mr10520219ejc.140.1656619567736; Thu, 30 Jun 2022 13:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656619567; cv=none; d=google.com; s=arc-20160816; b=csm4X3KfWzAj+EV+Iw44wiitp9xzbutZE+QYVqfeOUxKFyh7SE0UQplPlKh8Ut9KtV X9ct11Txr/Euts7iBGuVq6R2AVI/+QaWd1KIqIb0+YxdoxOhtQuNbPHgonCJEaxKmDdx fmR4kJGw+3pMSFlyMYhkDMAHcD7ZgZNR5cyg2fXx/pvBsb1QdVeMmQ0uYP6fuQyHcNg1 W3eWNw5/bbAXGopsPL/c4VxGpKEKuYjBql/QrzXJZbFN8R2r1DWJJxP8ARd0dDkqRm2w +gcHmd/toS5jGXXc9Miaotc/IQGQttrflhnBPrIh3A+Ho5SyjaBX2S0UhS7k54RjuY8A zFIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :references:mime-version:message-id:in-reply-to:date:dkim-signature; bh=bQE81g2DmbR80VZhT+P0vc15LIodMtph9Q2b9AmTsII=; b=ZTH8sFUfzJdbNqvjBmaLZAQH+pBAFQtRAfqst14HeIoDfgJLcwkGiET1Xwu4ZhcfkN aXVEITmqiKUnN8V7Ug0WhWu4suhOJQmNdzLZ6/r1mpHkDbgzyNLIoaypP3Vdd4nA248w JK7FSfpBD5dT9ft7ZGNM3HczpZjb99sAcJDPzquP5loT2A0A19K16QBV3+22aG5W7PWN CNh9dYzrIpRuJYczv2Xi7MFot8b2xPOngvIMge1aDzBanjhr1Wnjnn1+YUd1F2vE9gx0 Np7Y2hMz6n+tdWIdHc2JR+T4WosaTqD6Gz1tN1nE8mQ4ruzN7h9Dyf8y5DQ1Ovgttrwl 3c2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eR90cr21; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a056402084500b0042dc61e68d0si8650326edz.137.2022.06.30.13.05.42; Thu, 30 Jun 2022 13:06:07 -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=@google.com header.s=20210112 header.b=eR90cr21; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236664AbiF3T7S (ORCPT + 99 others); Thu, 30 Jun 2022 15:59:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231747AbiF3T7Q (ORCPT ); Thu, 30 Jun 2022 15:59:16 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30CC54132B for ; Thu, 30 Jun 2022 12:59:16 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-31c20461d7eso2650717b3.19 for ; Thu, 30 Jun 2022 12:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=bQE81g2DmbR80VZhT+P0vc15LIodMtph9Q2b9AmTsII=; b=eR90cr21CMIzTJFV+sggZ9202FIY3SWnOc51sGGAw3DCFSfXQZHBwHRBWfPMiSA11h LcCL9ysenrMzJ3KFahx7K4L1bPkH2ZO300OMvJvSQGOQmx5oz8Y1OFlOL6lUlVMP/OPa 3son8m5HjnpQntHpajGNczO51xPJaWE1UYl5n2mv0QZ8LKfEfYjqig5HtmIyavx80OIe 8c+M8wXg2MHwbaBpMEOuGiHlGk+0DPdEeabNg9j6tshUS+V+Hu3UXGkY/6uKIP31XS0o owM1PPa/9+tp82p0O12qYjfTfLQcPyqevFfns1deiXWDR/b2Ah3j35PmtbKktzOY9TnI jaZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=bQE81g2DmbR80VZhT+P0vc15LIodMtph9Q2b9AmTsII=; b=aBLy3kv+xv6x1d4bOFjn2AsSH7jzBDrzM6hsR2ivPgxsz49u5MV2M9v0PMo389aBbB 9kk4l8gj+93ad59b+PTsC64gKEDYPJQaJT8p0mSxu9mWBbiXiWtyJlN07MP+Ro/LXpmZ b6oxxoAFuyN4smk+dJPUKEUHAcJ50A3q2ThcykI8wS4c0EbiNHuyOBdTokyKPiCBNqbk m3Y+VosMMECT+0AKI8lSZUAH5eA8YqTjsmepJlxG5FIrbV6UyPzG1PaXBm78lH5lXxOQ JCyFJ/DnGGkZf0hzXWQpCVzTgs8g6GsO/2wYexZQgMRCEI5UKVO8qUNx1VuNomDsomXm wQWA== X-Gm-Message-State: AJIora8tIYRxXO40md060uw7FX9+QKEfn2KV1gzzQL9bEaWPK32gXRIg /tmEToMC95E905f/UKklFwO53TyWqBXbpZFQVA== X-Received: from justinstitt.mtv.corp.google.com ([2620:15c:211:202:c5f5:d5e5:38d2:2025]) (user=justinstitt job=sendgmr) by 2002:a25:d292:0:b0:66c:8adb:ce55 with SMTP id j140-20020a25d292000000b0066c8adbce55mr11608903ybg.131.1656619155389; Thu, 30 Jun 2022 12:59:15 -0700 (PDT) Date: Thu, 30 Jun 2022 12:57:38 -0700 In-Reply-To: <20220629235326.480858-1-justinstitt@google.com> Message-Id: <20220630195738.904505-1-justinstitt@google.com> Mime-Version: 1.0 References: <20220629235326.480858-1-justinstitt@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v2] lib/test_printf.c: fix clang -Wformat warnings From: Justin Stitt To: Petr Mladek , Steven Rostedt , Sergey Senozhatsky Cc: Andy Shevchenko , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Justin Stitt , Andy Shevchenko Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 changes from v1: * moved NOWARN macro definition to a more appropriate location * using __diag_ignore_all (thanks Nathan) * using local scoping for code blocks instead of __VA_ARGS__ (thanks Nick) * indented affected test cases (thanks Andy) Suggested-by: Andy Shevchenko Suggested-by: Nathan Chancellor Suggested-by: Nick Desaulniers Signed-off-by: Justin Stitt --- lib/test_printf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 07309c45f327..1b1755ce9fa7 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -30,6 +30,9 @@ #define PAD_SIZE 16 #define FILL_CHAR '$' =20 +#define NOWARN(option, comment, block) \ + __diag_push() __diag_ignore_all(#option, comment) block __diag_pop() + KSTM_MODULE_GLOBALS(); =20 static char *test_buffer __initdata; @@ -154,9 +157,11 @@ test_number(void) test("0x1234abcd ", "%#-12x", 0x1234abcd); test(" 0x1234abcd", "%#12x", 0x1234abcd); test("0|001| 12|+123| 1234|-123|-1234", "%d|%03d|%3d|%+d|% d|%+d|% d", 0,= 1, 12, 123, 1234, -123, -1234); - test("0|1|1|128|255", "%hhu|%hhu|%hhu|%hhu|%hhu", 0, 1, 257, 128, -1); - test("0|1|1|-128|-1", "%hhd|%hhd|%hhd|%hhd|%hhd", 0, 1, 257, 128, -1); - test("2015122420151225", "%ho%ho%#ho", 1037, 5282, -11627); + NOWARN(-Wformat, "Disables clang -Wformat warning", { + test("0|1|1|128|255", "%hhu|%hhu|%hhu|%hhu|%hhu", 0, 1, 257, 128, -1); + test("0|1|1|-128|-1", "%hhd|%hhd|%hhd|%hhd|%hhd", 0, 1, 257, 128, -1); + test("2015122420151225", "%ho%ho%#ho", 1037, 5282, -11627); + }) /* * POSIX/C99: =C2=BBThe result of converting zero with an explicit * precision of zero shall be no characters.=C2=AB Hence the output --=20 2.37.0.rc0.161.g10f37bed90-goog