Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp810200imm; Fri, 1 Jun 2018 09:55:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLtcTPKbb6rYQkf5wRWzHUcANxcxnmqA/CGYFAPgtR4X6Yt2hIc1HxZcN2ErjiW8xExwLLv X-Received: by 2002:a62:190f:: with SMTP id 15-v6mr11669480pfz.42.1527872146933; Fri, 01 Jun 2018 09:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527872146; cv=none; d=google.com; s=arc-20160816; b=DHRP3iGp8hgAiJ6FondB4so1NHfN2a6BmOTW01Z1RfLqWhQ0z0VpP2GQMgVXi964MF AaxWayfyRiYUlAetaXJwPyBB2LbbIyjZQv/osSEQcLeTYDnXqWAiSmvJ7lXb2qH7bezS GRj3+hA0O5BX0WPZMkjR3J0Mcux+aWAoqMaTNXz60jLyhMNYHtJ1OdwCOYjL1rh8DxtU 5AG1D4VgUcMuv07sIb1Wx6Kq7ruJKNUtIKmZktz/Rw7lQsCXxzVk/b9YKx5pYTGxy0cf s3pmhRw7PZQxkDQxZyQEZBTH5R9jFsJGwPUF/2FtpfRfrkl2nrGofyekrtpxzCt4xD8e +cmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=miUrbslyoy1YQGjowOn3VBYoVhh7TA3Na0URUHAvSQA=; b=R3u5xtoND9bAtkKZTBoY2yzayA15FdexG/ebcCivj2y/I7pL8Vhh1Bvdu7gyG0Wudx 8ARc1FRPQV0z/y2+XGBe1C8R51B/7XZbaNokgKVLL+GJN+ZWnUw+RBO0ELgvOYC//iXd pPg5ASkoTWQZtw+io/TtZ3wzcyFFhmkzTIg+qMPuPQYgiW2x9nCk3VoZCcarc6goYrsY GFbaz/6muDV/+WN5ZrowRsa1Uq7uI17nvPKlYMuMcuxE24KxuluNRDq2okrOVqKLzBTk KOK1NbX495x6pJaz3ox5UcyAx1nKnVWy8AHbautrngie5zw72p6E7i8IAnivY5tDKjfS zMHQ== 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 u14-v6si6954793pfa.28.2018.06.01.09.55.31; Fri, 01 Jun 2018 09:55:46 -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 S1753297AbeFAQyD (ORCPT + 99 others); Fri, 1 Jun 2018 12:54:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:44096 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753206AbeFAQx5 (ORCPT ); Fri, 1 Jun 2018 12:53:57 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9E148ABE8; Fri, 1 Jun 2018 16:53:55 +0000 (UTC) Date: Fri, 1 Jun 2018 09:53:47 -0700 From: Davidlohr Bueso To: Herbert Xu Cc: akpm@linux-foundation.org, torvalds@linux-foundation.org, tgraf@suug.ch, manfred@colorfullife.com, mhocko@kernel.org, guillaume.knispel@supersonicimagine.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 1/5] lib/rhashtable: convert param sanitations to WARN_ON Message-ID: <20180601165347.kvruerdm3gu57ifv@linux-r8p5> References: <20180601160125.30031-1-dave@stgolabs.net> <20180601160125.30031-2-dave@stgolabs.net> <20180601160944.ji2gsp3pyunlj476@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180601160944.ji2gsp3pyunlj476@gondor.apana.org.au> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 02 Jun 2018, Herbert Xu wrote: >On Fri, Jun 01, 2018 at 09:01:21AM -0700, Davidlohr Bueso wrote: >> For the purpose of making rhashtable_init() unable to fail, >> we can replace the returning -EINVAL with WARN_ONs whenever >> the caller passes bogus parameters during initialization. >> >> Signed-off-by: Davidlohr Bueso >> --- >> lib/rhashtable.c | 9 ++++----- >> 1 file changed, 4 insertions(+), 5 deletions(-) >> >> diff --git a/lib/rhashtable.c b/lib/rhashtable.c >> index 9427b5766134..05a4b1b8b8ce 100644 >> --- a/lib/rhashtable.c >> +++ b/lib/rhashtable.c >> @@ -1024,12 +1024,11 @@ int rhashtable_init(struct rhashtable *ht, >> >> size = HASH_DEFAULT_SIZE; >> >> - if ((!params->key_len && !params->obj_hashfn) || >> - (params->obj_hashfn && !params->obj_cmpfn)) >> - return -EINVAL; >> + WARN_ON((!params->key_len && !params->obj_hashfn) || >> + (params->obj_hashfn && !params->obj_cmpfn)); >> >> - if (params->nulls_base && params->nulls_base < (1U << RHT_BASE_SHIFT)) >> - return -EINVAL; >> + WARN_ON(params->nulls_base && >> + params->nulls_base < (1U << RHT_BASE_SHIFT)); > >I still don't like this. > >Yes for your use-case you will never crash and a WARN_ON is fine. >However, rhashtable is used in all sorts of contexts and returning >an error makes sense for quite a number of them. Curious, are these users setting up the param structure dynamically or something that they can pass along bogus values? If that's the case then yes, I definitely agree.