Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp89047rwe; Wed, 24 Aug 2022 17:45:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6URgwmoFIwa+tWVWQZKxUeX5p0t2PgAv6axJvjLYIh6F3JAMC4NqRhMis4nW7g8XYoUpNI X-Received: by 2002:a17:906:58d0:b0:73d:8e80:b07e with SMTP id e16-20020a17090658d000b0073d8e80b07emr915875ejs.488.1661388356550; Wed, 24 Aug 2022 17:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661388356; cv=none; d=google.com; s=arc-20160816; b=Bp+LWO8tfr0Ias5qCTC8oLc1QLwABJhrTk/UydSAjnBMHuYXj9Wo6k88eoSiao9OLl kUv6E8GB+ZIw9kyN5kWwiGSPUjtEOGtt2G51oTb/zgYbvKMTUoGyI9DWYoTfHaxOENNE 2Woot5Yqc2uTPjHUgTYOA6ZVpLcFYhRaePYMZ6M4MOABVsdwozV6+3ducptRejNHjvLX z9a/0bKYHCbaQ0Z5fJrLH3JoZTX6sL7/1YBm9UG2GfhzyBgdchBzPgGjblePu+RfFAIn iU8HwYVkiClq/neoHt6GEYa1HufyN8ndOrtybFJ1LHHn5fhYZEywVQSogwtowQP80Kad dQcA== 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=nIrwbzjVPwR86UIbrzDHfa+rwrBPUHe0L91ULQSuDXc=; b=nMV14FjW25Q1RU92oQgYNFMQmwMvNiFjJ52xihaKS/wp4i+jQfsVxltv1PJZuleUxD zwpjLIpuVjQrD+2YGU0+rVGljsG5i1wyQdvyPPCKVUWabaxif9VnFvu7/L643C7Dft3H sJOwYZPGEPSptzE4fFtQpHLX00geUm6V2zbJ2/KeS6vwcvCoA6fjX0/LS+L47ntmEtvJ niNPGhxV5Q6tg22kqO2CZM3OO+JCWe/rfpluq3P7Gdg4zeInKFohMsS0+s0pf9ihSpb0 V8yC/gAZA5pgz8eKRX/11qivJ3lp7782qmwORk/n6O8D5vuiBlGOqRnd3T4loU8o1Hy5 2z0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=BGlAVXTS; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn1-20020a17090794c100b007309e3750acsi3044484ejc.652.2022.08.24.17.45.26; Wed, 24 Aug 2022 17:45:56 -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=@linux-foundation.org header.s=google header.b=BGlAVXTS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbiHYAkh (ORCPT + 99 others); Wed, 24 Aug 2022 20:40:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbiHYAkf (ORCPT ); Wed, 24 Aug 2022 20:40:35 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2268D7B283 for ; Wed, 24 Aug 2022 17:40:34 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id gb36so36558294ejc.10 for ; Wed, 24 Aug 2022 17:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=nIrwbzjVPwR86UIbrzDHfa+rwrBPUHe0L91ULQSuDXc=; b=BGlAVXTSXs+iHzo5okyca9opwOfI2k+bCnq9C13rvW9w9O7zi4EF+ei6QHyYkFpOzA ztW4WXKGmB2tWclYzgQiuFlQxfszReeLGXZNujm3HiRsSIEls5zy9fc/EM7xcqDtX9M2 O6eXyOnW5S0vVn6UW9twmpipce7h/FqqIP0m8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=nIrwbzjVPwR86UIbrzDHfa+rwrBPUHe0L91ULQSuDXc=; b=iyT5gCoEP66poMNM9UerkMyeOrq8FgYIFo8jO7fewPiIE72uu08iuhK1QmefbmNKN8 cNd6pHsjrD9AkzWxj5Wvrcz/Z2yn17JeTXPUpNq+OA96lC4UzEo50qSfKjKoHPR5hAMk EmzzF/vAkwHjabKYV7kJtbf9VIPIQ/olXpV6BB/9YjXXtH/ZOTiQmuU6wDgJt7TTQ20k KfR0AtBVcf2sCBg1DWp8vLjlre5C2lIuo3JR1JrLkxyKkQn+cQWtKYhcuVfzLIq//3FY +RtI91CzWUVBwZN3giqmKP0ReaMi5b5QhHOTWByPCnRx0Xl94UDWul5vGQgMqK3ODOBX mFLQ== X-Gm-Message-State: ACgBeo3RMnUsLZ4glm+/yYPBHJic5a3HsiXIWZ25GMXiEytzqaSp1IKw wHQ4ipAjliiQgH2pGHpJawzHN4DlKhkj775N X-Received: by 2002:a17:907:c10:b0:73d:90ae:f7fd with SMTP id ga16-20020a1709070c1000b0073d90aef7fdmr877772ejc.52.1661388032448; Wed, 24 Aug 2022 17:40:32 -0700 (PDT) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com. [209.85.221.49]) by smtp.gmail.com with ESMTPSA id y21-20020a170906559500b0073d685a2985sm1745403ejp.108.2022.08.24.17.40.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Aug 2022 17:40:28 -0700 (PDT) Received: by mail-wr1-f49.google.com with SMTP id k9so22687139wri.0 for ; Wed, 24 Aug 2022 17:40:28 -0700 (PDT) X-Received: by 2002:adf:b343:0:b0:225:1a75:2a9a with SMTP id k3-20020adfb343000000b002251a752a9amr719380wrd.281.1661388027693; Wed, 24 Aug 2022 17:40:27 -0700 (PDT) MIME-Version: 1.0 References: <20220821000737.328590235@goodmis.org> <20220821000844.510643400@goodmis.org> <5700ac75-f6a9-877e-4011-9b314f12b5ab@acm.org> <02daa3d6-2847-d7e0-e23e-411076c6d4db@rasmusvillemoes.dk> <0163b361-14bf-7b4c-751a-14f1a004b1a9@acm.org> <353e5bbd-cdd1-f818-6a2f-9a7c800f9879@acm.org> In-Reply-To: From: Linus Torvalds Date: Wed, 24 Aug 2022 17:40:11 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [for-linus][PATCH 01/10] tracing: Suppress sparse warnings triggered by is_signed_type() To: Bart Van Assche Cc: Rasmus Villemoes , Steven Rostedt , linux-kernel@vger.kernel.org, Ingo Molnar , Andrew Morton , Christoph Hellwig , Luc Van Oostenryck , Jens Axboe Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Wed, Aug 24, 2022 at 5:30 PM Linus Torvalds wrote: > > Let me think about this. Actually, thinking about it, that was simple enough. -#define is_signed_type(type) (((type)(-1)) < (type)1) +#define is_signed_type(type) (((type)(-1)) < (__force type)1) should work. It looks a bit odd, because we only force one side. But we only need to force one side, because the '-1' doesn't have any issues with bitwise types, the same way 0 doesn't. So only '1' needs to be force-cast to avoid a warning about casting an integer to a bitwise type. And since that -1 counts as an unrestricted value after a cast, now the ordered comparison doesn't warn either. Now, admittedly I think sparse should also allow a forced cast of an unrestricted value to be unrestricted, so I think I should do this static int restricted_value(struct expression *v, struct symbol *type) { - if (v->type == EXPR_CAST) + if (v->type == EXPR_CAST || v->type = EXPR_FORCE_CAST) v = v->cast_expression; in sparse, but even without that the above "is_signed_type()" macro should make sparse happy (with that current tree of mine). And since we don't now need to cast 0, gcc won't complain about that NULL pointer comparison. Does that solve things for you? Linus