Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp551267pxb; Mon, 8 Nov 2021 18:27:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJy48M/Ar62HPrq1iFXFNaD+QAIvbljBlacgGkw/hrGoGubbRe6ILn4CBhoB3PXHJK8VIdam X-Received: by 2002:a05:6638:3795:: with SMTP id w21mr1295227jal.73.1636424859403; Mon, 08 Nov 2021 18:27:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636424859; cv=none; d=google.com; s=arc-20160816; b=iDU8lMzs40WYisiWb1PSkS+2EuZrqw3HnoH3KQB+329V5k3IHMMAbKlWdMzfVEe9hb i/WzfeXa8jfw9goTUUDeh89FB80iK17fwnKD0XdyxHM8FC9mir/n9ckWu/RnEofHTiZn GkRQ4D/TJnb/paKopZrtDpEsqJYoZ6ThHzjG4Yen9X9ATpjJSayxA1ULwHOqfSomm3y7 i2Q3nkxyyc3sLXr0YIs/Jup04zNY1KB0av3l4N6/Ppcl4FXka068h3gHK1DNd14RKgvE H4Cy+ZKlygYHnEO1jSE6Hmuohi9SKAxeA3Pc/3lstxiLE1/13IK3Uixsxi4WkuW2jbHo rGtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=XCt44ciTjHPqBO2xWONoM27y235Uqj1XS1pgFKfh1lY=; b=VijgHe/CLVLGSm3Iatq3PvJrNOe01GGy4WsMbe6LZQeB9VSiGuVjaZi648mxxbQmz2 RwkGGTuYXdOgsrJzumB/tlgvwJ4K8EXxh/6EsMlFeYs5SPZj+8zpw6+ZpJGWOSpulewC n1+9I89YBAnRvKIk5ODT/9PEYa4Jr0IWUZMuyq6w/irjOy2LPv+WodaQQgZ8GYlty6Jg o2s9ynOHwf/ynyO21GrSzZhBpl63dtXYRIQw2yFMmlfiiumTEwduyfqP2QtW9rv6+frO 4iheV/XT9hM8HD3ZgTRGNq4e0rLYP9J4YNvIoge6OsrG41LpWhUIbXrwyVF3baYmMKID 4BTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=oR4Rs8Lr; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=5XKQZm3A; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y15si37950781ilu.148.2021.11.08.18.27.26; Mon, 08 Nov 2021 18:27:39 -0800 (PST) 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=@suse.cz header.s=susede2_rsa header.b=oR4Rs8Lr; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=5XKQZm3A; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235628AbhKHSd4 (ORCPT + 99 others); Mon, 8 Nov 2021 13:33:56 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:43904 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235611AbhKHSdx (ORCPT ); Mon, 8 Nov 2021 13:33:53 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 6F5861FD4E; Mon, 8 Nov 2021 18:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1636396266; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XCt44ciTjHPqBO2xWONoM27y235Uqj1XS1pgFKfh1lY=; b=oR4Rs8LrrE2wh0pjmmsoiEgZk4Uco+owPrA8z7rJMAyfH9HUrmu0/vaxkGJNBvrGAAEpUL qAKkN5X6PkDnnWkRKCRblD+UodYxnQVbJMtjIbyB3cXBxzkOxKx7xpx6A4FOztkrilWaD2 qiyjPZSGEBbFG9romrvi61mp7Vjd2q0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1636396266; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XCt44ciTjHPqBO2xWONoM27y235Uqj1XS1pgFKfh1lY=; b=5XKQZm3A0GQgccfJjWJc/L5fHp7SL2/HrLb6lUCIHOQg3+qixevztH+dmKeA/W8tlGx326 04jfgETojWoLCOCw== Received: from pobox.suse.cz (pobox.suse.cz [10.100.2.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 42AC0A3B85; Mon, 8 Nov 2021 18:31:05 +0000 (UTC) Date: Mon, 8 Nov 2021 19:31:05 +0100 (CET) From: Miroslav Benes To: Jiasheng Jiang cc: jeyu@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, nathan@kernel.org, ndesaulniers@google.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, clang-built-linux@googlegroups.com, mcgrof@kernel.org Subject: Re: [PATCH] module: Fix implicit type conversion In-Reply-To: <1635473169-1848729-1-git-send-email-jiasheng@iscas.ac.cn> Message-ID: References: <1635473169-1848729-1-git-send-email-jiasheng@iscas.ac.cn> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [CCing Luis] Hi, On Fri, 29 Oct 2021, Jiasheng Jiang wrote: > The variable 'cpu' is defined as unsigned int. > However in the for_each_possible_cpu, its values is assigned to -1. > That doesn't make sense and in the cpumask_next() it is implicitly > type conversed to int. > It is universally accepted that the implicit type conversion is > terrible. > Also, having the good programming custom will set an example for > others. > Thus, it might be better to change the definition of 'cpu' from > unsigned int to int. Frankly, I don't see a benefit of changing this. It seems fine to me. Moreover this is not, by far, the only place in the kernel with the same pattern. Miroslav > Fixes: 10fad5e ("percpu, module: implement and use is_kernel/module_percpu_address()") > Signed-off-by: Jiasheng Jiang > --- > kernel/module.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/module.c b/kernel/module.c > index 927d46c..f10d611 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -632,7 +632,7 @@ static void percpu_modcopy(struct module *mod, > bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr) > { > struct module *mod; > - unsigned int cpu; > + int cpu; > > preempt_disable(); > > -- > 2.7.4 >