Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3710520imm; Mon, 17 Sep 2018 01:43:47 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda5TkYSv7pdZJNltrH1uNoVhbZnsOtiSEMNR56GYZuuMaSlNurtKr4AoJXdwf1odhmnMvDV X-Received: by 2002:a63:e4b:: with SMTP id 11-v6mr22724087pgo.320.1537173827303; Mon, 17 Sep 2018 01:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537173827; cv=none; d=google.com; s=arc-20160816; b=aMDtpHV0coRdEIaPf8h1gCdOgQa5SG3hKCB1KlT6eqINcTCpkTjvmthhUD+lhRf3YN 91hI+x5aBdBWQRfNHAaHWYhxmoQoKI0JwPlzfuPRUliP3OEbxiBsdR19BkaynNb5BYw+ drf0urlS2kW04NPcvftZcfbi0bylTUIrrF7oqJ4NOPAvXDqvTf9vQddx1S14OlSTEiHX OzdIHaII5fsu0mRxYNMsp0phBo9aqh1dmkIdYBCouMepgOjNRkkvgaZk/fecsFYfO7jU CVqd0XN4WaRp0VhHDhygfFHEfWqS56ruJc17/o8O8/mICBmYttmrNdCfwUPueOCZjTto C2UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=jmDwioOhFVG6kda24QI0ePGFZPWJeHNYC5wHqwTVbH4=; b=goRtoApa+/QSKXAcVp/7AUo06FpdoBZyTVBo+tNyEvVW4VEC/3MJQxZU6cbd8GvLKv jSFBiHtMsvSBc0tCYCfWGGIyR3uanYNI/kO1uNOPu2DWNkZkLgKLG7XxC/XVmeqR5gwO 8fBvLCg440xJOUcIFDa04IMbHOThPlg1NGbbFfkyCfd+yCMncOQAMixKt91xNn21B0yl 9lOzweHjZH84N8uyeH5m3gi04+dGuamgIA+i8WFpLHV/6FwuyTvA0iCxKplzQajlM9o/ TD0s4Lv113/c448jysG7tYhxFGfhxdZEKoLgqtYCQeLnde9CkUljUqer8jl9AEgchV1c Znfg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10-v6si14624767pgb.638.2018.09.17.01.43.31; Mon, 17 Sep 2018 01:43:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728289AbeIQOIb (ORCPT + 99 others); Mon, 17 Sep 2018 10:08:31 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:38469 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727329AbeIQOIb (ORCPT ); Mon, 17 Sep 2018 10:08:31 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 42DKP80gB5z1qxQN; Mon, 17 Sep 2018 10:42:03 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 42DKP74HMKz1r45B; Mon, 17 Sep 2018 10:42:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id hhH72BPfeCtV; Mon, 17 Sep 2018 10:42:02 +0200 (CEST) X-Auth-Info: apX/yAMFFAJ7BP0mXwzgOFDe2foS9aoDFfWp/T2uAVG4Fs1bGVrHx4K5YXqI3k5o Received: from hawking (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 17 Sep 2018 10:42:02 +0200 (CEST) From: Andreas Schwab To: YueHaibing Cc: , , , , Subject: Re: [PATCH net-next] net/smc: cast sizeof to int for comparison References: <20180915100036.20100-1-yuehaibing@huawei.com> <87zhwj6liz.fsf@igel.home> X-Yow: I've gotta GO, now!! I wanta tell you you're a GREAT bunch of guys but you ought to CHANGE your UNDERWEAR more often!! Date: Mon, 17 Sep 2018 10:42:02 +0200 In-Reply-To: (YueHaibing's message of "Mon, 17 Sep 2018 11:57:40 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sep 17 2018, YueHaibing wrote: > On 2018/9/15 19:35, Andreas Schwab wrote: >> On Sep 15 2018, YueHaibing wrote: >> >>> Comparing an int to a size, which is unsigned, causes the int to become >>> unsigned, giving the wrong result. kernel_sendmsg can return a negative >>> error code. >>> >>> Signed-off-by: YueHaibing >>> --- >>> net/smc/smc_clc.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c >>> index 83aba9a..fd0f5ce 100644 >>> --- a/net/smc/smc_clc.c >>> +++ b/net/smc/smc_clc.c >>> @@ -446,7 +446,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, int smc_type, >>> vec[i++].iov_len = sizeof(trl); >>> /* due to the few bytes needed for clc-handshake this cannot block */ >>> len = kernel_sendmsg(smc->clcsock, &msg, vec, i, plen); >>> - if (len < sizeof(pclc)) { >>> + if (len < (int)sizeof(pclc)) { >>> if (len >= 0) { >>> reason_code = -ENETUNREACH; >>> smc->sk.sk_err = -reason_code; >> >> It would perhaps be better to handle len < 0 first. > > That need refactor the err hangding, is worth doing it? Just a few lines moving around, IFAICS. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."