Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp833819iog; Thu, 30 Jun 2022 11:01:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vU5JANGXWISnXzCF4utxnxLDLHSz5WD9XG658n/8uZ4lNDEgp/BOHoJrR2eLLDUzjH6iHH X-Received: by 2002:a17:90b:3a83:b0:1ed:4bfb:7763 with SMTP id om3-20020a17090b3a8300b001ed4bfb7763mr11296269pjb.41.1656612074402; Thu, 30 Jun 2022 11:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656612074; cv=none; d=google.com; s=arc-20160816; b=wAMNorZyiw/9OGJx4QFT6xTTBkSHQXYVjzdlGhTllpr8wQes1DTXMpFi5rrV8Q0RVJ ftqYf+T0qfYtDEgWLemAYqaflTXY7ZyD+ta02zTg7XEkzNLpaPVSnNGlOpdscbuUPD2O 6DQWHE1HHQICMoqnxdD7/TBnRJ4ow83M1azLj4bIEy6nb5WFeiPW8nyDJ8JJj5128aso 0UbcqQYSoYAH3k7KpHSqBq0qWPJziQF0wTrF8k8mrKeWPPoyOslhEH/23geyLyvzvOOM gsC1sO+xsN3NwzD4WYA8zOoQ3zh7b8T/GtsTI+fc+YzVVIQOB/BBnjLCrCJi2S+lU1tP Z3Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bKovRKzTTq8kVAKncWkMW8HntSojKecvaV7C1Tiy6gA=; b=wn1RN/RaoFNKb8UflLCS2JQcN04Dzhd0UmhPCqhQr9OrHh3INWMpSQ0o8c5dylgWYT sFWrCR9Q0pgKwf32vO/f0QBnZzdwsNwSumWotjDIrf5PWmSsDsBIIbtcLqBgBZPSPliJ xspy/GsfD95ZGbCC7Yr6vyeTSysouyO4/sRf2aTWsnaBDxrG1YtVLT3Q53tyOunC7zWj aBH+jQizJb1dXEqU5SJEVEb21oy9reLWx3IyMshIOCNcFZ3rkjpHq08CiU6ldpGQ4qAx piQ14fvK03Doy311T1Dicd4dMtL5lV5z7M13aj6ACFUme9KoLl7tpXVl1ZiXLBXCF6/7 iPDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=KiMJPhP6; 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 f15-20020a63de0f000000b003fe34317ce2si25229122pgg.778.2022.06.30.11.00.50; Thu, 30 Jun 2022 11:01:14 -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=KiMJPhP6; 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 S236257AbiF3Rbu (ORCPT + 99 others); Thu, 30 Jun 2022 13:31:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231747AbiF3Rbs (ORCPT ); Thu, 30 Jun 2022 13:31:48 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0714120BD3 for ; Thu, 30 Jun 2022 10:31:48 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id x3so34995556lfd.2 for ; Thu, 30 Jun 2022 10:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bKovRKzTTq8kVAKncWkMW8HntSojKecvaV7C1Tiy6gA=; b=KiMJPhP6xYYFUTWaCNcg8Z9VnzBD8Sm0oGGvMtn8MvEbc8PTHuawBiezi89pfsM7Qg Weaotn/+nwWWMTsRSzSg3qRF0kqlRQQhIV56sfRjnhfJlsreFVjkQwOx56O2r6XGhDIE 5MwNLhFeUXTLv7GhRSR68Rj4yk3AT6dh4zwiNg6OLPp3JgFANNXzgIlgbjJGJVPQTKnx MCEUiDTeM+atlaHz/soeTiQbt2NENBGmLKydg6UEQBFGBoYX7OfGhPE0X3Fm27YP4uzU UqdaYdcuGBsxGYIcG7YALT7F6u1V1TWM2roEZKCy53hl8+dLM5hWEuupgxTAOg99+qcZ o7Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bKovRKzTTq8kVAKncWkMW8HntSojKecvaV7C1Tiy6gA=; b=CH1ZXipCLXhnv3oLe5PgXhTWwughobSr6eyG0JsmhlGN4DGl/CoA1XZmWpMrQsbM9D njQnFXfr+R8AygdpdP5LqLCS7qv03mMAgS3yaNvdqfHoqVeSLu3oX4A1ZCxkdFo8BQLp fNibRy9lnS/Q2bmz1qRohjN/6ejAPjQ9wF7ae/aGH8keKgk3XVRbFoZMZd47KDo/lPJQ pOO6aVmh6hRD7yGrucOiUNWMoisTFaHMDKPAAP2gK3pA3f2rg8R2VtXr0lG/iFBZszoV +8IZALlnqdRctEmL/9oLTsihXq03PA5gb+KyT4a+WJjbezWq8S0iLb0YPZ4Ovriv2T+n G5/Q== X-Gm-Message-State: AJIora/GmHq1NPtwo8ixtmrEmtW7lt78zyr9nUYYLDv/TpAIquqeekfi Iq6jP9J7NDvgNf2NkVwjkh1LTuNbalzBb09D6Y63VA== X-Received: by 2002:a05:6512:b8d:b0:47f:74f0:729b with SMTP id b13-20020a0565120b8d00b0047f74f0729bmr6261421lfv.403.1656610306179; Thu, 30 Jun 2022 10:31:46 -0700 (PDT) MIME-Version: 1.0 References: <20220629235326.480858-1-justinstitt@google.com> In-Reply-To: From: Nick Desaulniers Date: Thu, 30 Jun 2022 10:31:34 -0700 Message-ID: Subject: Re: [PATCH] lib/test_printf.c: fix clang -Wformat warnings To: Justin Stitt Cc: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Nathan Chancellor , Tom Rix , Linux Kernel Mailing List , llvm@lists.linux.dev, Andy Shevchenko Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 On Thu, Jun 30, 2022 at 1:14 AM Andy Shevchenko wrote: > > On Thu, Jun 30, 2022 at 2:11 AM Justin Stitt wrote: > > > > + /* disable -Wformat for this chunk */ > > + NOWARN(-Wformat, > > 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); > > Perhaps shift right the lines as well? Along these lines, I think it would look nicer to pass a block statement (a group of statements) to the macro rather than use __VA_ARGS__. Here's an example: https://godbolt.org/z/fsYcGGEMb You have to be careful with control flow out of blocks like this sometimes, but for these simple localized cases it looks like that should be fine. As Nathan mentions, you can probably re-use the existing infra in your definition of NOWARN. I do prefer some macro to make it appear that the pragma is scoped to a block statement, rather than multiple lines for the diag push + pop inline. -- Thanks, ~Nick Desaulniers