Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp324423img; Wed, 20 Mar 2019 21:46:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxG+4JoWgTCXUSZN1VNZXoOiVqWRFBp7tmX6rJkrapbcE0w4d5JBzra2U3hgNjQs/SMk6Vq X-Received: by 2002:a63:e002:: with SMTP id e2mr1581552pgh.300.1553143600549; Wed, 20 Mar 2019 21:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553143600; cv=none; d=google.com; s=arc-20160816; b=VcPC3E1aS0Qp4PeYh1ShEdASgJi1FsvEoB8iFkHyY0vPSFDsHgutMievJjM05Tg9+w +IGu6bIp1BEYi/xoxj+FCdooLjDav9Lz4G6cgLt4iCWyuMpku3/9GGTl+1uy8Xzv0+jh 8KXApYOFLEsxdTVmij2B81LJgmtmid4NevmlYUOTEnh69SfeA86V/7qRO4OcHNBUNH9u Fwygk3azyccAIlCvctf2rG8Gm6WYccH6VVXtA2EunRFiha5AS9UTMebZIrCkNRgPBgkC 3VvEc455d3T9OcpaCxKuUIVtC9MMnrGNOvC61OwrOou6LODMAXij/qRSKo64UVLqulx3 +Y4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=iEtkszVLLNU+sqaVLD9f4N/eDcLXgaVMKWhv+59yX1A=; b=sUEkpz/YOKxXFlY4WGo2LbQSiXZJbe9i08gu+NXgmmdZ9JY8MU24Uzp9j2zOPvzTbZ DWCKkwzQ4FJI9R+LmDMBkaWC8LrpTIAc7Dcd5DwEWuRzkBLmNQK6yf6lq/Yc10dzMTSr RA5WHnTcmDYlcvL9Sj8mcdiG/XvNWtfJe+C2XKWdCZVJ4eGmZl/astcVa+vpCmAK+nL4 XFspirBxNs32F+3ixm8OvmdCUYy2budupiM1ZUfbWMmFVt0kIdKfSRUpXx5oVBcQZWVQ vhzHEHlz1Gq4mjTbYHc1yT7pcz7ILoa9FXggepBCnWEU68T1wj6Zhu8z1mlTfZF5cLI5 U5kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Dgmp6BvV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id g11si3458907plo.125.2019.03.20.21.45.54; Wed, 20 Mar 2019 21:46:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Dgmp6BvV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726189AbfCUEoX (ORCPT + 99 others); Thu, 21 Mar 2019 00:44:23 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46400 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbfCUEoW (ORCPT ); Thu, 21 Mar 2019 00:44:22 -0400 Received: by mail-wr1-f65.google.com with SMTP id o1so5073631wrs.13 for ; Wed, 20 Mar 2019 21:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iEtkszVLLNU+sqaVLD9f4N/eDcLXgaVMKWhv+59yX1A=; b=Dgmp6BvVdsUF/rhGWEPPHi9ZCS9XL149R3uMnLGVXkGoF5H1iN42EJRZe/aZCOTPL+ G4zWc/OKQ6dcnOGnOZsSEa0mZCreYuy6A6yP9MgEk7culj5BUKcTtid1OPs2yELE5/Qz uu/4iWiXUANbngZ0xYikD3Th1Zsruw3+am6Off/K68LJrNB8VD/lEHuspl0ET/zuK47Y QIyP+6M7HaNrzVpZxjGAZGdu9efXSbj51cwjbe8AR9+O29I5iI9yUB3BHPBM/z+2Jmlx 74htqMGGdv4MpIBnngIN55KgApr72iGObErQffgk8PkmSQijlAv/zwr5Q/fIwO3b621n mXdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iEtkszVLLNU+sqaVLD9f4N/eDcLXgaVMKWhv+59yX1A=; b=Q5S/0oR8BccZpkfrNPFU3zPtEh8nrschekexFzlgeCtVI345aJZlpNO82fKvMHe6tB KuB5zSeLkip+sXKvfqdFieNYBgMVhYlBw7aJRxNxcqrVNOEcaF/MjZZcllhb0Gg1aolh +uL+sBw6qA40hkuDoEeZFaZNl9NdYk37YT83T/OW0T0F9/HJpvVO1pE+CVf+W6XUGjuz mtYBepcyJ35UymeEG+vq4TNV6AmV4CENLsW8trb5/F2sYP/+moir2OG8B3jAon33GVnX xfJZGS+aI7RV9N2Ou5s1cEh1KclJpW+O/Ccdz4AmtrLNOzqxhcLvQQam+U4c1rGdi6jk GceQ== X-Gm-Message-State: APjAAAXwwj9aMEb5k/JbolBsvN7dbfvTzYpZUyJIfyPvOIgUdIwLFZVt CDsWkhIQGnD3HPhk2dwa7G25DB99rUlSzuOkBT8= X-Received: by 2002:adf:dbc2:: with SMTP id e2mr940523wrj.317.1553143461233; Wed, 20 Mar 2019 21:44:21 -0700 (PDT) MIME-Version: 1.0 References: <20190320005406.GA16412@archlinux-ryzen> <20190320043440.GA23335@archlinux-ryzen> <63518f1f-b808-77b0-aac6-ee1ece669c4b@amd.com> In-Reply-To: From: Alex Deucher Date: Thu, 21 Mar 2019 00:44:08 -0400 Message-ID: Subject: Re: Clang warning in drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c To: Nick Desaulniers Cc: "Koenig, Christian" , "Zhou, David(ChunMing)" , "Pan, Xinhui" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "clang-built-linux@googlegroups.com" , "amd-gfx@lists.freedesktop.org" , "Deucher, Alexander" , Nathan Chancellor Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 20, 2019 at 4:49 PM Nick Desaulniers wrote: > > On Wed, Mar 20, 2019 at 2:37 AM Koenig, Christian > wrote: > > > > Am 20.03.19 um 05:34 schrieb Nathan Chancellor: > > > On Wed, Mar 20, 2019 at 01:31:27AM +0000, Pan, Xinhui wrote: > > >> these two enumerated types are same for now. both of them might change in the future. > > Please consider if the YAGNI principle applies here. > https://martinfowler.com/bliki/Yagni.html > > > >> > > >> I have not used clang, but would .block_id = (int)head->block fix your warning? If such change is acceptable, I can make one then. > > My preference on solutions, in order: > 1. One enum (this is the simplest most type safe solution). Add > another enum when you actually need it. Otherwise, YAGNI. It make sense to have two enums. One is a firmware interface that is only used by some asics and the other is for the general driver interface (non-asic specific for the ras features. > 2. Safe casting function (like the one Nathan supplied, maybe with > WARN_ONCE rather than WARN). This ensures that at least if the types > diverge you get a runtime warning. A compile-time warning would be > preferred, but I haven't taken the time to think through how that > might be implemented. I'd prefer this one. Alex > 3. Cast to int (this has been used in other places throughout the > kernel, but provides the weakest type safety and doesn't catch future > divergence). > 4. Disabling the warning. (I almost never advocate for this). > > > Another question is if it is such a good idea to just silence the warning? > > For the kernel, it seems that each maintainer can choose what to apply > to their subsystem. I would recommend against disabling additional > warnings that aren't disable kernel-wide for most cases. > -Wenum-conversion has spotted many bugs. While the enums in question > today are not different, they MIGHT eventually diverge and lead to > bugs, like the others we've found and fixed throughout the kernel. So > I would recommend fixing now, and be insulated in the future. > > -- > Thanks, > ~Nick Desaulniers > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx