Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp976928iob; Fri, 13 May 2022 18:19:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAgJbwiwDXxuPPrOzi63iOxYEbRVujXtLT0XPlFJyfOeIs1r+sqVCUxMQkxLjHOMxKltZ2 X-Received: by 2002:a1c:1947:0:b0:392:b883:aac9 with SMTP id 68-20020a1c1947000000b00392b883aac9mr6599656wmz.155.1652491164753; Fri, 13 May 2022 18:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652491164; cv=none; d=google.com; s=arc-20160816; b=YuAE5RJexV2Sbbz+NxxmjSBemgbwsvJXZYiOWO5iVQvvsnXxJHacuZFpL1tn4F0BsU 3TNkO5iGUXDwPD0Oly1pqiFHgPTXHPMDbWrlA7WWaNEQOqazrsmRKml1J5dFhUcA6hYz jUVdRkqg8mbPnVH/4OwpqQ6OKXQgaZYc3DjWgryY+8bvJeyi1LEplRMKHQY3ljKwbrIm BoZzXZz6PdM1IK0KSecF5yQ1G3jmn7VJCMcZbJbBpz626u05jPeAkkV4wUNrX9xuf+B5 JE/ARhYBoGioJHg2VLxCK4vT73VU9aBtcfnCQux44UrTAraFU0wq4V79/tsXpdMDwDnT d40g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=CZSoPA8puL7Md+xQt5hBu3K70prwXWyzH/0IoViDsn0=; b=iIoPJO19KovEgwWPJOHw2GQAq3VwWXt9YkIb5XCnGfdVjMBxYGTBfE/9KAy5zT9UoY 3BCbSKFelhGSJPIQH+MNVLVzfnhI7Onp4CQV9olIoNDN2e/ZYQ+mB3qWiZ8gkXLmAH3n iIleXiwAldb618KseeJDRlcIeBEwl9FKljyjVhUeq6LQj/HfI8CpymaVYULe5Xpk1Y9r vBTAGzfNPqN8bxfiUvxDqgmo+l3pQLmUB0FRPU0gjxQyyOvhZ3vsw32E4qDX1ZyNLutn hsuWGAv1nkos6c6pFr5helRlZy9YX3kCDtFtwDTrI9xz9+1oFeGodr2Ts6JsV5u8cXRM +JSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=cNubmoTk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f3-20020a1cc903000000b0039406c0c2d8si3552755wmb.28.2022.05.13.18.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 18:19:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=cNubmoTk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D7F03C0790; Fri, 13 May 2022 16:49:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359861AbiEMBFq (ORCPT + 99 others); Thu, 12 May 2022 21:05:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbiEMBFo (ORCPT ); Thu, 12 May 2022 21:05:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EDF7B45 for ; Thu, 12 May 2022 18:05:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DDEE3B82C27 for ; Fri, 13 May 2022 01:05:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41568C385B8; Fri, 13 May 2022 01:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1652403938; bh=o0tVkqCw52XZn3wbMhXVh+A4KnIKErQWAa2HDHJy+6Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cNubmoTk7cUdXBCDVnxyxhmzbCjeLlbPJuWm4t0rbcnmJkYe5x+EblRrO1hpM1Ufm ogL/bSUcde84QbgsfvHNjOV1A+0gsacBuVPRWn5ZC8IaUDlarmIIGqG1j3ii5r4AAd irggWkLWD8OKlHbfZzyp5aMS7peS0YAkhhZMj9Hg= Date: Thu, 12 May 2022 18:05:37 -0700 From: Andrew Morton To: Andy Shevchenko Cc: Jagdish Gediya , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jonathan.Cameron@huawei.com, adobriyan@gmail.com, rf@opensource.cirrus.com, pmladek@suse.com, ying.huang@intel.com, dave.hansen@intel.com Subject: Re: [PATCH v2 2/2] mm: Covert sysfs input to bool using kstrtobool() Message-Id: <20220512180537.5296f39b27c3488080ff67cf@linux-foundation.org> In-Reply-To: References: <20220426170040.65487-1-jvgediya@linux.ibm.com> <20220426170040.65487-2-jvgediya@linux.ibm.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Wed, 27 Apr 2022 18:17:29 +0300 Andy Shevchenko wrote: > On Tue, Apr 26, 2022 at 10:30:40PM +0530, Jagdish Gediya wrote: > > Sysfs input conversion to corrosponding bool value e.g. "false" or "0" > > to false, "true" or "1" to true are currently handled through strncmp > > at multiple places. Use kstrtobool() to convert sysfs input to bool > > value. > > ... > > > + if (kstrtobool(buf, &numa_demotion_enabled)) > > return -EINVAL; > > Hmm... The commit message doesn't explain what's wrong with the error codes > returned by kstrtobool(). Can't it be > > ret = kstrtobool(); > if (ret) > return ret; > > ? Jagdish fell asleep. Yes, I agree. It has no practical difference at present because kstrtobool() can only return 0 or -EINVAL. I did this: --- a/mm/migrate.c~mm-convert-sysfs-input-to-bool-using-kstrtobool-fix +++ a/mm/migrate.c @@ -2523,8 +2523,10 @@ static ssize_t numa_demotion_enabled_sto struct kobj_attribute *attr, const char *buf, size_t count) { - if (kstrtobool(buf, &numa_demotion_enabled)) - return -EINVAL; + ssize_t ret; + + ret = kstrtobool(buf, &numa_demotion_enabled); + return ret; return count; } --- a/mm/swap_state.c~mm-convert-sysfs-input-to-bool-using-kstrtobool-fix +++ a/mm/swap_state.c @@ -874,8 +874,11 @@ static ssize_t vma_ra_enabled_store(stru struct kobj_attribute *attr, const char *buf, size_t count) { - if (kstrtobool(buf, &enable_vma_readahead)) - return -EINVAL; + ssize_t ret; + + ret = kstrtobool(buf, &enable_vma_readahead); + if (ret) + return ret; return count; } _