Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp862485ima; Wed, 24 Oct 2018 10:19:16 -0700 (PDT) X-Google-Smtp-Source: AJdET5emRBwHWynelJofCuLp4uZ+agCeDwTxokLjqb55lDx6ideXJFEQCq1CniWLqio2s52vX62f X-Received: by 2002:a17:902:8ec2:: with SMTP id x2-v6mr3297757plo.157.1540401556048; Wed, 24 Oct 2018 10:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540401556; cv=none; d=google.com; s=arc-20160816; b=MRhUpRSu5RXheD/D92YhGMex8zOfE93N659/XbPsTJMJuMt9+tYBjIUHe8Lt5lekA1 YmKMEZsuImqtLgLXOT0ljFvS25gypisORXRuXV6/12kYE74xxdZfWkv4Fd03EkcpMgcG wRgKVYy4fmjr/afd/5M8oO/cxslBssyhuyIOFqhoGNXbiftHz4a7Mvs+yPQmjQF93BuV azuPhmir4YmJikmHzAjQBpPTN6xqzZvfj1P5PVU4TFAcG7diHhNHPRfiz/uDoZg5mgNV 1/rQOQuCJ9hsneF84yunrpDZQ4dDi+Yf0RsuIB9CLQ2T3OzgMRNJQSVhpejfcUjGO9zm zXdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=e0MVq8PPJGluRwGSbt0re/maIL2JYWDy2A8UHmES2+Y=; b=Epgtlo6JAxd/xU4DkcjD42UJalNx2t0EssZEGKQuC4NjHg2sXOb57Xr4xYqwFulMSI xloXZkPDA4kBxKbidulcqaPfCG4HEQmsKhixwtB6ctqBFnUyfuMXbN+j4CDhDnWLnqom 2tRKxk7ICvZr4rzKJfPtUE49woRcZ5ZbiTDpcjQI4JQMUYEeGxKWBtWoUBv0APDWdHcD R3MxiupUsFv+FwOyN66pqE5uVG9gitzmUNc6+HkZ7Ca4LdpSRGl3So4BYaFmMG9gYjEd ChK6PFSpUJaXJigcbMkmrAoDMxFkzTBjjeR4MiVIGXRoyZVdTWiMIPoZdUSD5Xjee436 U43Q== 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 i4-v6si5173632pgk.564.2018.10.24.10.18.59; Wed, 24 Oct 2018 10:19:16 -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 S1727041AbeJYBr2 (ORCPT + 99 others); Wed, 24 Oct 2018 21:47:28 -0400 Received: from smtprelay0054.hostedemail.com ([216.40.44.54]:42593 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726497AbeJYBr2 (ORCPT ); Wed, 24 Oct 2018 21:47:28 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 8A945181D341A; Wed, 24 Oct 2018 17:18:34 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:4605:5007:7903:9707:10004:10400:10848:11232:11658:11914:12740:12760:12895:13069:13311:13357:13439:14096:14097:14181:14659:14721:21080:21433:21627:30012:30034:30054:30056:30070:30090:30091,0,RBL:47.151.153.53:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:29,LUA_SUMMARY:none X-HE-Tag: frog90_4aa1ccc66364d X-Filterd-Recvd-Size: 2341 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA; Wed, 24 Oct 2018 17:18:32 +0000 (UTC) Message-ID: <375561cf08343abbcd4118da2272507c30311788.camel@perches.com> Subject: Re: [PATCH] Change judgment len position From: Joe Perches To: Eric Dumazet Cc: Willy Tarreau , wanghaifine@gmail.com, David Miller , Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev , LKML Date: Wed, 24 Oct 2018 10:18:31 -0700 In-Reply-To: References: <20181024154729.5312-1-wanghaifine@gmail.com> <20181024155739.GA25314@1wt.eu> <60f08664db5751949ddfb34666bfda77f99682f1.camel@perches.com> <20181024163230.GA25382@1wt.eu> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-10-24 at 10:03 -0700, Eric Dumazet wrote: > On Wed, Oct 24, 2018 at 9:54 AM Joe Perches wrote: > > > I think if the point is to test for negative numbers, > > it's clearer to do that before using min_t.and it's > > probably clearer not to use min_t at all. > > > > ... > > > if (len > sizeof(int)) > > len = sizeof(int); > > It is a matter of taste really, Agree and hence my use of 'I think' above. > I know some people (like me) sometimes > mixes min() and max() Not quite sure what you mean here by mixes. mix up? If so, the < > inversions probably have about the same error rate. And I suppose there are cases where the always set of len in uses like len = min(len, 4); are more costly (len being in a slow write speed area of memory or some such) than the other style of if (len < 4) len = 4; I think that min() is easier to read in most cases. > I would suggest that if someones wants to change the current code, a > corresponding test would be added in tools/testing/selftests/net?