Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp769053pxj; Fri, 14 May 2021 15:46:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdyzi7Z27voo3zfw1hkhh6tYPFh2SMQA4FplTdJNzx3EzBNx7ea1lALukYSlcSux5iOdKF X-Received: by 2002:a17:906:710a:: with SMTP id x10mr13313113ejj.516.1621032375003; Fri, 14 May 2021 15:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621032374; cv=none; d=google.com; s=arc-20160816; b=lO1Y/gKU3RFgwaeqKB8Ukt++qIFyitfYK+GXtX/fVO4qVzh0So4EyuuUKB/jkTmv4H ub6LlU6PXn1DYJePRwrDN6WfE9Pfm5M3bpFlEJ8lZWJyPWU5Os3mB8rEbFexn5O8bHPV 2YAv33wo6J+hKFYL7JvZaIAaHRp0NaPOz8vH2ffqQ5CmRhD8oDPcOZbzFJwikxMQPPBY QiLymOJteVHiZSseFn0q59XGYaEhMD2kEOyjqYTPG2t6sqGhrdcXn63pBNooO4fyM6Pu tJkCx/I2P4Riu3Di/Ol3Btd7HLidIu1WDBd/ALv9YQLkwRNvWkE03rNV4mz0bgIZZxSW 4HjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=W6EGw5FDEXhr6iHG779poa/gfRiLcSiy2g55pqc2Xpo=; b=auooP/JYDszul8LcjR4pzrE87/TyZQj1/SPc7UcCfzmP9b2yHReOrkV7PZ0scHf4Dc snN3yj1njRQ3/FED/BzyM9i+n29hU+IhU8b9pQpRU5rUQEkozjbUKox70vDqsYkig9A7 eEMc7Sq9qoHoQ2BZFhg2jVr+o0/nWYz4lMokNWfSlMktL052aUDnhcQ2RQuD8m9kg7RZ +jOPFvdZCuOIjlv0bYSQpqpGHUYMKqyxd8xSy41p7pTS2Fu1t18ZeB029AYDzuVIyxvC ioXhEk2yPYGY48JoKa99LC5U1lyZRHgv/Ffz7MUsHCiC/eQDircnAr7Mzq6eGLRSHMD1 p3GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bCub7K+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si8479064ejj.214.2021.05.14.15.45.51; Fri, 14 May 2021 15:46:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bCub7K+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234337AbhENOW7 (ORCPT + 99 others); Fri, 14 May 2021 10:22:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233465AbhENOW6 (ORCPT ); Fri, 14 May 2021 10:22:58 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 315AEC061574 for ; Fri, 14 May 2021 07:21:46 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id f75-20020a1c1f4e0000b0290171001e7329so1553440wmf.1 for ; Fri, 14 May 2021 07:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=W6EGw5FDEXhr6iHG779poa/gfRiLcSiy2g55pqc2Xpo=; b=bCub7K+FdNA9MjxtaR/gNqonadOvGhwZNxdrc4cDQ+NZ8EZRge3q4dqVQXTFP2Dd1z fSHVB6J48f8y+YARIuygZNkPCbC2zJy8hiwR9agb1VKo3kHzAXluIjoKT7XZ33NFq6rV PwBxJCV7cOpbiSa3N+1eb+Aa2zYc7LBnSbPM5qxH7bw+/006ZR/1jYdulfJh6/HMuEuI AnJFghTnlqG8oXm025XReNYUGRceCWAPQW9+rpdcFlo4ijX9DNYeXGL+/COftWmTtjWE W4Ubmy7gyzlOZT9DkhpCUVi13RRqqG9m1vYFY87A6Nsz02DZKqvm58SyRC5nDj+egtTW fwkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=W6EGw5FDEXhr6iHG779poa/gfRiLcSiy2g55pqc2Xpo=; b=Y+nXN2iNfaCB2rs4IXVtG+rrkFnUwIN8OpxHpbpV0Vk4M8J8XDHwtk8sLKa4SKZKQd bVfY9lfzL2mgrknDRhgGL6UQhC4XBJxSE8TcfJEIs4hvtGe3MJNeEj2fqYxjojdwUFej ei0wZELDpwO0IzA5UhTDe4+o/54Yl3DMukZVdWEsRWgsscqYVdzDA/oyKGyvKaLsC7Eq Ss45VuR4z7w2/UgndKzceePNRaUD352iK7Wk1ZNGNHnWq+fyB6tesXpgYr0pUWDAF9T9 OA+PkuehyMyV0Ag7xx9Oc7L1JlBEWGnkehqAQ8XrB7x6ARUzez34POso2esUjc33ECvY xSCQ== X-Gm-Message-State: AOAM531oJelCRvQtQL319LifVQzk1MgY18YZojmhm/1P2Mb22bUJ3QnM cEDLNKI+bnDKeoyRsgLbJRBHLT8636Y= X-Received: by 2002:a05:600c:198a:: with SMTP id t10mr8954234wmq.97.1621002104925; Fri, 14 May 2021 07:21:44 -0700 (PDT) Received: from [192.168.2.202] (pd9e5a369.dip0.t-ipconnect.de. [217.229.163.105]) by smtp.gmail.com with ESMTPSA id v18sm7747958wro.18.2021.05.14.07.21.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 May 2021 07:21:44 -0700 (PDT) Subject: Re: [PATCH] platform/surface: aggregator: shut up clang -Wconstantn-conversion warning To: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Hans de Goede Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com References: <20210514140556.3492544-1-arnd@kernel.org> From: Maximilian Luz Message-ID: <219848ed-e0ce-634a-29c2-caca813b054c@gmail.com> Date: Fri, 14 May 2021 16:21:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210514140556.3492544-1-arnd@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/14/21 4:05 PM, Arnd Bergmann wrote: > From: Arnd Bergmann > > Clang complains about the assignment of SSAM_ANY_IID to > ssam_device_uid->instance: > > drivers/platform/surface/surface_aggregator_registry.c:478:25: error: implicit conversion from 'int' to '__u8' (aka 'unsigned char') changes value from 65535 to 255 [-Werror,-Wconstant-conversion] > { SSAM_VDEV(HUB, 0x02, SSAM_ANY_IID, 0x00) }, > ~ ^~~~~~~~~~~~ > include/linux/surface_aggregator/device.h:71:23: note: expanded from macro 'SSAM_ANY_IID' > #define SSAM_ANY_IID 0xffff > ^~~~~~ > include/linux/surface_aggregator/device.h:126:63: note: expanded from macro 'SSAM_VDEV' > SSAM_DEVICE(SSAM_DOMAIN_VIRTUAL, SSAM_VIRTUAL_TC_##cat, tid, iid, fun) > ^~~ > include/linux/surface_aggregator/device.h:102:41: note: expanded from macro 'SSAM_DEVICE' > .instance = ((iid) != SSAM_ANY_IID) ? (iid) : 0, \ > ^~~ > > The assignment doesn't actually happen, but clang checks the type limits > before checking whether this assignment is reached. Shut up the warning > using an explicit type cast. I'm not too happy about this fix as (I believe) it will also shut up any valid GCC error message in case those macros are used with non-u8 (and non-SSAM_ANY_xxx) values. I'll let others judge and decide what's preferred, however. In case you're deciding to apply this, feel free to add: Reviewed-by: Maximilian Luz Thanks, Max > Fixes: eb0e90a82098 ("platform/surface: aggregator: Add dedicated bus and device type") > Signed-off-by: Arnd Bergmann > --- > include/linux/surface_aggregator/device.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h > index 4441ad667c3f..90df092ed565 100644 > --- a/include/linux/surface_aggregator/device.h > +++ b/include/linux/surface_aggregator/device.h > @@ -98,9 +98,9 @@ struct ssam_device_uid { > | (((fun) != SSAM_ANY_FUN) ? SSAM_MATCH_FUNCTION : 0), \ > .domain = d, \ > .category = cat, \ > - .target = ((tid) != SSAM_ANY_TID) ? (tid) : 0, \ > - .instance = ((iid) != SSAM_ANY_IID) ? (iid) : 0, \ > - .function = ((fun) != SSAM_ANY_FUN) ? (fun) : 0 \ > + .target = ((tid) != SSAM_ANY_TID) ? (u8)(tid) : 0, \ > + .instance = ((iid) != SSAM_ANY_IID) ? (u8)(iid) : 0, \ > + .function = ((fun) != SSAM_ANY_FUN) ? (u8)(fun) : 0 \ > > /** > * SSAM_VDEV() - Initialize a &struct ssam_device_id as virtual device with >