Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3996203rwd; Tue, 23 May 2023 01:17:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7CMOj4gzJ1rWK8DJBa59X+6URYB6PQ1XLwJ4/h6agn9OqqUF9Gt17K/TlEHChjRIAD4K4Y X-Received: by 2002:a05:6a20:3d05:b0:10a:9f55:292a with SMTP id y5-20020a056a203d0500b0010a9f55292amr13044195pzi.43.1684829873120; Tue, 23 May 2023 01:17:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684829873; cv=none; d=google.com; s=arc-20160816; b=SGC5CA1PONvh4fMJoDDV1yWx54wyZUbV8vCcd8bccX27dKH7DrwDR1OXF78KasNZJJ yLTiuEl16Ej3cJIGqwg5gVkfMoYq5mff4YrdhVpBEcHfXbX4OddliK6BETY87GNTt4u7 3eOx8Oo+MtKsM/pBkiYvDH5i3gxSt7pH3JVtEWyg9G4OLJVszap9Kuj58o8F0q4vByzM BqJ+WSvHgbfq0g/GS3iydh9+qQ+cKhBQMGLBP5owumQ/SI0ycmWEFeZD0WkAhmizasQW MGsx8hhbK1uzQPq5Q9jSyBwxlkvvBIUHrhb0T8A0eCr3VrjQu/psLtRIjstaB0OkgRjn BbaA== 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=/UBmaUNQZ4cD63VkIDKgkEiTelaPQH55K4YkFVxnNek=; b=hmuJJG5jtZ22UAprrkdTJW1ur2s0AWjYULd36it5us/zF1+9dYyaQauhRHlvmuULga 2B+f+xQBLrJWjGWFuJzis5gaKAhBcrEJc29ahBfKBfnfvgTREJNCEsCogbHo/6z54oDg Wl+tJ/FtrardVfSl13R854ZgoVQ1jp1frD64AfAzMTIsMGZx8mXqHVTWmy8LQRgJkA0o XL/pxnngYIQvBwkCwiVrv4GU6ZMp/dMKNTGxqm41TWFsARV2G2WY3ljc68qPMH3S0a/d zWWMVas0bLFz5eI4Y1WZv/d0u2CEYOd5MhEL1A/yNSGrtDndSPmHLpudj0/YttxgCe8d 4FeA== 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 j29-20020a637a5d000000b00534869d75d0si1138267pgn.767.2023.05.23.01.17.40; Tue, 23 May 2023 01:17:53 -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 S236095AbjEWIOb (ORCPT + 99 others); Tue, 23 May 2023 04:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236124AbjEWINi (ORCPT ); Tue, 23 May 2023 04:13:38 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3968E1709 for ; Tue, 23 May 2023 01:12:17 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.41:50830.1110848198 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.41]) by 189.cn (HERMES) with SMTP id 2E6421002CE; Tue, 23 May 2023 16:12:14 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-xwndj with ESMTP id 44015d2c06d047de9aca08dcafbd25d6 for 15330273260@189.cn; Tue, 23 May 2023 16:12:16 CST X-Transaction-ID: 44015d2c06d047de9aca08dcafbd25d6 X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn Message-ID: <5d7f9d1a-10c5-5b55-c7d8-24183f5a09ee@189.cn> Date: Tue, 23 May 2023 16:12:14 +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: Sui Jingfeng <15330273260@189.cn>, Jani Nikula , David Laight , 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> <4c9c0897-5e3a-1469-3d87-ff7723ac160c@189.cn> From: Sui Jingfeng <15330273260@189.cn> In-Reply-To: <4c9c0897-5e3a-1469-3d87-ff7723ac160c@189.cn> 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/23 12:26, Sui Jingfeng wrote: > 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, > Here, I'm NOT 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.