Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2276229pxp; Mon, 21 Mar 2022 15:38:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHuqRgM9H5FPMsQIt1mDMsxVF63niyAyyZQdPrV51NthnC2hVfk1PX4CScdTRxhv+jtBYU X-Received: by 2002:a63:1a5f:0:b0:381:f043:320d with SMTP id a31-20020a631a5f000000b00381f043320dmr19734674pgm.63.1647902320364; Mon, 21 Mar 2022 15:38:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647902320; cv=none; d=google.com; s=arc-20160816; b=spM23DThabF8uV/w1N+hralr3whZYa7YDmg+jJ7BDRONhX1jrnxslCpUkVJfeHVr/X jZah3tZtGiAgOvd4GSPg9w3z+rYzEvQeqfCbE6mas+Ip+FiuilGrDVIQI3ShB2qMHVVg 5x1Q+ogozoCZA1+nIWRD8OEiVty+2fEn0X6WR4arx0emE0wCPOr/DWMwXbnVfilAFwF+ Yrn/gPhWFGvdvHS8Ffq885V77UawK5glIDO7LCKFP14qSHOolpF9rYcjiUN23Uc4IAYs MBRJ3laHfxxS1p1spR4JVp9tDFOdMXqE7Utq0idHqut6LmgFz7xoEWlXUlHb4tpvHO/H K5sQ== 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=ERP/ri7fUthNe53EHX7luWZC9TGqfyrEEYYImd67W/Y=; b=qVGMaPcuSfFxHAsCDe2VzylTtluffiLeZjJWnmOh6kjXg28XjheTIdQt2Y8InCxy83 oZck/YXCFbcXT5ixZCYKag57oachXpATKh3+c4ZTc/dOGEm5q7cUcGRHXZnV8GqbXoyb /JbzC+Do0Vu73x5lPI70Pq+zkzMTp50Zzy/vX1+4DslMscDHBomHSs/RQSr5pKb0j2QE O6BF12tyEkx+zphpJFGK7Zh9Le73NLV8ly9RxoNgfpsT+1GDUcpNDhDZzAGp1waMrNoX ZevDWqHE2GR8Xtnw40RV+ZTIOW6IZEm6N/E0CvEEJWdbDSOK/Cj0sq+Yl3BvwY4bIY9A vdwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BggTcfmt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q16-20020a63e950000000b0038259e543acsi7345503pgj.541.2022.03.21.15.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:38:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BggTcfmt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4BB1A62C9A; Mon, 21 Mar 2022 14:50:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239098AbiCRSrs (ORCPT + 99 others); Fri, 18 Mar 2022 14:47:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233444AbiCRSrp (ORCPT ); Fri, 18 Mar 2022 14:47:45 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3EE118A3FE for ; Fri, 18 Mar 2022 11:46:26 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id u17so10166275pfk.11 for ; Fri, 18 Mar 2022 11:46:26 -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=ERP/ri7fUthNe53EHX7luWZC9TGqfyrEEYYImd67W/Y=; b=BggTcfmtj/2qASx5jrYS2HTIDX8wZ0k8AmkaH4EK71HQS+Hr2S2Os83J0Ff6DUxdAm XdEW3psIax6tYFh663lnLA3erJoYb3Sm8e1aRv2sDp/FrATacY8st5ZwnQilndH+PGAH FWOBxc3v+HnN2XQQkObD9jEyhkY2ccr7UA6fH4ZyCS8HVnRCTL0hGzXqiYjAleeFugQ6 s1tVAPpDjDha5Us2u/hB/Bb6LIKjCudqkEbvw3af3Bw+blHuhhiq4vF5rN6+JsWsor05 9jo6J2Ko9bWMEHThamBW9AEzWLr2ePYij+IKusfmpqQJ9okpFAtdXYQdwYqkPI+/ts/g 7JwA== 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=ERP/ri7fUthNe53EHX7luWZC9TGqfyrEEYYImd67W/Y=; b=tCoZVoAKSZ5A7I3Xb5hyTKUL0OBWYupKOeSZPLCHvdZV6TI4sNjwf2Fyg/S23o1q4v 1vSufborq8KApUUzr0823rP5p/Zmw6gcJ+/r1fd9C0VacR7V9YlLmJ2HJoY1BaI6Ul5K lp2AZU8FMb8wFlnHoU8zvmEvydR56C38hoH+HLbe1IejTr/0/W/3gMzxf7S6Mvg8Pl8K nJPQkPUvp4I5weYTh0aWis0CcpWndnSGDUghpI2xNUpKsUrL45HCruUxIbwsJ3Vi1uLM zvsT6TIDyM9ZHFnr68ef0eiLz2PYqeZoDH6Dgnf6tX9eHODBZkQgpjvgBON6spPXuA75 +e0Q== X-Gm-Message-State: AOAM5318rYMQuC36F1eJG1hwjoMH3Q/hPmL+gIfAJujwFVQVf/dqKnz3 R809APMOoIoAeCsKuZ7HQOwJMuJJ2bariVdJjiKO X-Received: by 2002:a63:1613:0:b0:382:2a7f:5ca1 with SMTP id w19-20020a631613000000b003822a7f5ca1mr3871359pgl.151.1647629186010; Fri, 18 Mar 2022 11:46:26 -0700 (PDT) MIME-Version: 1.0 References: <20220316213055.2351342-1-morbo@google.com> In-Reply-To: From: Bill Wendling Date: Fri, 18 Mar 2022 11:46:14 -0700 Message-ID: Subject: Re: [PATCH] gpiolib: acpi: use correct format characters To: Linus Torvalds Cc: Nick Desaulniers , Andy Shevchenko , Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Nathan Chancellor , "open list:GPIO SUBSYSTEM" , ACPI Devel Maling List , LKML , llvm@lists.linux.dev, Joe Perches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 Fri, Mar 18, 2022 at 11:41 AM Linus Torvalds wrote: > > On Fri, Mar 18, 2022 at 11:29 AM Nick Desaulniers > wrote: > > > > Should we add a note diagnostic to clang suggesting the explicit cast > > as one method of silencing the warning? > > On the compiler side, I would love to see warnings about the ambiguity > of the sign of 'char' in the general case. > > That said, I tried to add that to 'sparse' long long ago, and couldn't > make it work sanely. All the approaches I tried all get _way_ too many > false positives. > > I tried to come up with some way of figuring out "this code acts > differently depending on whether 'char' is signed or not" and warning > about it, and never could. > > And I suspect the same is true even for the much moire limited case of > only format warnings. > > Because it's a *bad* idea to use '%d' (or almost any other format > specifier) together with a 'char' argument, but only if you don't know > the range of the char argument. > > But the other side of the argument is that quite often, people *do* > know the range of the 'char' argument. If your 'char' type thing comes > from some array or string that you control, and you used 'char' simply > because you know you have small values (typical example: use it for an > array of booleans etc), then it would be very annoying if the compiler > warned you about using '%d'. > > There is no reason to use '%hhd' when you know your data range is [0,1]. > > So honestly, I don't think you can come up with a sane warning that > doesn't cause *way* too many false positives and just annoys people. > > I'd love to be proven wrong. In fact, I'd _really_ love to be proven > wrong for that generic case. The "sometimes 'char' is signed, > sometimes it is unsigned, and it depends on the architecture and the > compiler flags" can be a real problem. > My first thought is that this might be better suited for a static analyzer, like clang-tidy, that can do deeper analysis on code. It might still be difficult to weed out all of the false positives, but could be useful for specific offenders. -bw