Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp704502pxj; Fri, 14 May 2021 13:37:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU1Ry6fembo/p2bAA5KtzdfD8aMLLarh1cADVDDNlferbMOViV8pKw9/Zv9iJv2FjxZnCK X-Received: by 2002:a5d:814d:: with SMTP id f13mr13291073ioo.203.1621024661256; Fri, 14 May 2021 13:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621024661; cv=none; d=google.com; s=arc-20160816; b=cCDnyIg5dVCfEuLcwLFgoaOpN1EdyLhn0D8NN6rpLgupMj0bkblTok3SIxWQbp4PRH Yq0T6a9jFmMJRVNuUoEfLuIn4X6JpvjhuOxFAsgozO+D8huh+PiTxhv8M1pgoiJjAKmJ uRcVeBkqTazcxU1Sy+8kqDLgtxmGhg10jnVLJh6X7g0+RTZaDAAyfpffyFVo5kErbWER sa6M+qnDEfF7I75DipUgNgnvewqEO+s5dDS6CWJ9zZyqqniJhnAVWaajqZWLfFNVQTXQ 30MmCmayNbIRw4xUdvycdg7kLHT7npS7xBubnAYaUyNe3PIBBOhGTUwr0+1QySdMlI0k imKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bV95c3iMgL3NAEjWtLQf0+CS54N+jJNScFPUWDdcbrk=; b=WwylIDrgdxekVKt5SJOPLm5TgV5bKgmvaHu1IiSMDf9JcByJc/bs/P8oJkAyESMu3k JuLa9vfOsIr8pEFEScRE704EyC14A9IE7t+fR+TJIDJduTz9bpMfmui8jbHa6WRFNMNx 5kYDJogI0Fca+QqSfyMkAZaJJvkStRgMFSZCRyJ+AJXUVCZj+1+H7csyDJDnvzLdz4ml b0oZ96jpT2/XZWQBmUPes4Oh0F4kYgXcnIq0f2+6Z7QwOedzzsCc5x4RKgB9szt+GYW0 B2su/EwtPARo3MvaYyofYBn9gxweJv3ynFDutTkQaNmpC1mnsDxID7/vzmmX7elwEG/O Rfuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lmmWfaUO; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si7975257ilx.117.2021.05.14.13.37.28; Fri, 14 May 2021 13:37:41 -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=@kernel.org header.s=k20201202 header.b=lmmWfaUO; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231580AbhENUG5 (ORCPT + 99 others); Fri, 14 May 2021 16:06:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:58414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbhENUG4 (ORCPT ); Fri, 14 May 2021 16:06:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7C1C16134F; Fri, 14 May 2021 20:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621022745; bh=6HQ4i41x2W6L18KGACfxOUHJl8ZeDEuYjx2rHL7bWwA=; h=From:To:Cc:Subject:Date:From; b=lmmWfaUO8gcZsen3JNvjqN/INR+pmOieZahdIuOJauyxJbht7az+xaNJSgRaMjSWr gr4Mc3wLhYleXIgmAa/tx6KMM22oJE2JDogSDLB0nVJDcpyiIweYVN9GJsw8HZUnQn sH0FjsczMNaG5VKWGObFZiCt7mxQgt0JG5TcsZKDThC2MvHBSv1q3quo82YQ1mAhYW BMhV/7lg/r6ALhUNoycu7hLXtd9wJUK9BX+/hbIOkMDuF/lcMBYmtwzFLKR5X788o+ qtG4MeA1heZfOlREHaTwRBRAA9YuroLIOSNkmAj6wV9/zWa0E8mG0QfKgshBTOBohN 6h0FrELO/aMLg== From: Arnd Bergmann To: Maximilian Luz , Hans de Goede Cc: Arnd Bergmann , platform-driver-x86@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] [v2] platform/surface: aggregator: avoid clang -Wconstant-conversion warning Date: Fri, 14 May 2021 22:04:36 +0200 Message-Id: <20210514200453.1542978-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Replace the ?: operator with a __builtin_choose_expr() invocation that avoids the warning for the untaken part. Fixes: eb0e90a82098 ("platform/surface: aggregator: Add dedicated bus and device type") Cc: platform-driver-x86@vger.kernel.org Signed-off-by: Arnd Bergmann --- v2: use __builtin_choose_expr() instead of a cast to shut up the warning --- 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..6ff9c58b3e17 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 = __builtin_choose_expr((tid) != SSAM_ANY_TID, (tid), 0), \ + .instance = __builtin_choose_expr((iid) != SSAM_ANY_IID, (iid), 0), \ + .function = __builtin_choose_expr((fun) != SSAM_ANY_FUN, (fun), 0) /** * SSAM_VDEV() - Initialize a &struct ssam_device_id as virtual device with -- 2.29.2