Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3832886rwd; Mon, 22 May 2023 22:05:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7l3iGKmzl31MuZM0tLtWqHlGxM8ksc9j/sAlJ7FGdglbpIP/I8Za9amYzFtPRHlY+hY2qj X-Received: by 2002:a17:902:e751:b0:1ab:f74:a111 with SMTP id p17-20020a170902e75100b001ab0f74a111mr15553913plf.63.1684818358968; Mon, 22 May 2023 22:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684818358; cv=none; d=google.com; s=arc-20160816; b=Pf6YVow0swz/RgCT7YCoU3NVqUjzrberhQiAlq+Og0cuzXqUG9/FSUJURk4hyT3yJI s7zMIW+0/cvYvnBy20+Hy8EuTIxAtJyTphTAZ5eMMJGHHugyJ82X7NrZIkb9kxuBvNRC ghJFfgHrT5pioVpZmmW8YRsd5IDz68Tt0JW3A8Pyt27giGrSUwKcfpm97w06KwYDRKLv 2bSqie6Cq5xTX8ASdyQyZx+CGDtUTexy6IS6BAtQTuaD+oTkiHtyc57Thns1moq7qa8D cs103kN6YknTelA65Itau/Nb0CGzEE0BAyBlngkmMqlmdYC7wllI2Fp/6wlfoxW6Sj+j epsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:hmm_source_type:hmm_attache_num :hmm_source_ip; bh=HHM2gRp2WKf6/DxZyRsXzRldi+YdnQwgBHpOBzepcJU=; b=p5l6d6HcDTNBJniJ5h9gqcoZw3nV1Wro37pI2ePUrUKC9KhXHA8MHX3dnc9xNQ65/w ud+24evAiGCX9YLir6vpJkkXU0uUYhVvIrYkgjYm/rqLxY7klaQBTdV++wdSlkgsjjFh DYYt5cteMu6wF9tRAHF16UrTJVLkPn5Qu+GKqPhVoNt1wR1G3TZfVuPEnL7tCkOvRFw4 CLW3rKPnlvom1dD0OF69y4LNmC9PQJ66WTFBj4DuQNicR/MPxIHaYH1vVyBo/kkuIAbH XD63mDb+p4Yd+nXwKRnXWsTVNI44/LYeLlZ4tN5Yq00LSs+MydLzI58dQ6CLXDe3dJjk NQaA== ARC-Authentication-Results: i=1; mx.google.com; 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 jb21-20020a170903259500b001add3e4ee8fsi5803806plb.138.2023.05.22.22.05.43; Mon, 22 May 2023 22:05:58 -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; 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 S231153AbjEWE0k (ORCPT + 99 others); Tue, 23 May 2023 00:26:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbjEWE0h (ORCPT ); Tue, 23 May 2023 00:26:37 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D5CFFFA for ; Mon, 22 May 2023 21:26:35 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.31:35904.1415243224 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.31]) by 189.cn (HERMES) with SMTP id B8F6B1001EF; Tue, 23 May 2023 12:26:32 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-xp9j7 with ESMTP id 8ceb7444fc6a4c1d905d08bc2382ec42 for jani.nikula@linux.intel.com; Tue, 23 May 2023 12:26:33 CST X-Transaction-ID: 8ceb7444fc6a4c1d905d08bc2382ec42 X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn Message-ID: <4c9c0897-5e3a-1469-3d87-ff7723ac160c@189.cn> Date: Tue, 23 May 2023 12:26:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] drm/drm_vblank.c: avoid unsigned int to signed int cast Content-Language: en-US To: Jani Nikula , David Laight , Sui Jingfeng , Li Yi Cc: Thomas Zimmermann , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "loongson-kernel@lists.loongnix.cn" References: <20230516173026.2990705-1-15330273260@189.cn> <871qj8ob7z.fsf@intel.com> From: Sui Jingfeng <15330273260@189.cn> In-Reply-To: <871qj8ob7z.fsf@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FROM_LOCAL_DIGITS, FROM_LOCAL_HEX,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Hi, On 2023/5/22 19:29, Jani Nikula wrote: > In general, do not use unsigned types in arithmethic to avoid negative > values, because most people will be tripped over by integer promotion > rules, and you'll get negative values anyway. Here I'm sure about this, but there are plenty unsigned types arithmetic in the kernel. take kmalloc_array() function as an example in /tools/virto/linux/kernel.h static inline void *kmalloc_array(unsigned n, size_t s, gfp_t gfp) {     return kmalloc(n * s, gfp); } NOTE that *size_t* is an unsigned integral data type.