Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1005537imm; Thu, 5 Jul 2018 12:50:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdG3j0bkfaVaavRE1mSPF1lY/eSUozB6E4nQmf47j2naIM4ynZKi3mnMulFPXHApJwHHV2J X-Received: by 2002:a65:448a:: with SMTP id l10-v6mr6904606pgq.382.1530820239374; Thu, 05 Jul 2018 12:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530820239; cv=none; d=google.com; s=arc-20160816; b=PqVhhnbSgRgp3XsTkzCI0gmMk7EMH+Pp+VcE+aXrX9RyMYB2zip3cUHnobymXNaf2W JjTI2iuOt9zJjUmzTgszDioD99/SFAOWCVFoTCKz71JEMJ/NkTQQLAvNCopEA44bF7Xz qdny5QdTJkAaqA0DKndYamwxDMHvFi3u4JRcGGoemsrqKbNLeuhiCPeDyfY9gaqd25gY QKx++z7PAZBKDpLSWnA2tQhNiC/W+MYqIxBRcRWWVhp3TtML2cu6oPhHy7esg7Sdu2Pp Cx1Ssmu+QrWpXxrEKOM8jJh446SWLGHqKhs03wmZKbESmqgX/zfMhUw4hDMoS0T7E6Ks YWrg== 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:dkim-signature:arc-authentication-results; bh=XHAMxw6CXBYg5NE9j2EHSKSy6vVRwvrWIH3vI/OHPM8=; b=ceEDVSdDabXXEjqR1U03iJ1Ba3jQXv/ms6cqDNoXL03QJWxnem493aPRkB2ROlSI3f 1Y8Izv1PyVjuwSB5aXgPu4AHirUztdcvc2lHoQYtcnDHhR5O2Jum3qiL0mdlWQZkieF0 YWpSFSKXAUdXPgS3NxjEoLY7/gydixhV9BQ6M3xAy0inK/3wzXYOKjCNw1heBBYqbcHD 1jYy9Kb/851W73oR9h3GUOnczn99Ykbh3BM6n6GCS98SEN+yO9uwyQmRLKSp5RziDANL gbCuqnAAue106plloYixiiwTTrwueqGD3Auvx0seOKRR78P5HhEb8NQp/VMGsR5zk97U OdEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=LlXP7LMi; 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 k2-v6si7221135pfh.252.2018.07.05.12.50.23; Thu, 05 Jul 2018 12:50:39 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=LlXP7LMi; 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 S1754044AbeGETto (ORCPT + 99 others); Thu, 5 Jul 2018 15:49:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:50972 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753963AbeGETtn (ORCPT ); Thu, 5 Jul 2018 15:49:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XHAMxw6CXBYg5NE9j2EHSKSy6vVRwvrWIH3vI/OHPM8=; b=LlXP7LMitFFyehyp6eW5ehc5X TWRmeIY1vuNrwY+2w8DS4GcIeqmv1qOrYoFccY9edy3P6gBaojEi2JoPmgHaLfrgbPI1UbaAtoG7T ZlBOacqAzuQLYEN6D2sQw13mWZvLHKYlUEB9DIu9neM0dWVDinIj4uio8LFnByuHFqAqrSrIjv2Ca kM2w4jz6VCI+ANXXk8Tfm7m0xpowCCDAwlxrX64emXrBZb3tjBM3jgLRt2FqCbdCsGp3kiZHHvpbV 3LRFGSkWjaE/6QUnXm0HLxOJ+i6NRYO85U+sJKfLE4RQFWIZpAs8aL8Npay8QcO2jtZCZLEowI4Iw J3DE1fIGA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbAG0-0002Lh-8G; Thu, 05 Jul 2018 19:49:36 +0000 Date: Thu, 5 Jul 2018 12:49:36 -0700 From: Matthew Wilcox To: Dan Williams Cc: Johannes Thumshirn , Andrew Morton , Ross Zwisler , Vishal Verma , Dave Jiang , Jeff Moyer , Christoph Hellwig , linux-nvdimm , Linux MM , Linux Kernel Mailing List Subject: Re: [PATCH 13/13] libnvdimm, namespace: Publish page structure init state / control Message-ID: <20180705194936.GA28447@bombadil.infradead.org> References: <153077334130.40830.2714147692560185329.stgit@dwillia2-desk3.amr.corp.intel.com> <153077341292.40830.11333232703318633087.stgit@dwillia2-desk3.amr.corp.intel.com> <20180705082931.echvdqipgvwhghf2@linux-x5ow.site> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 05, 2018 at 07:46:05AM -0700, Dan Williams wrote: > On Thu, Jul 5, 2018 at 1:29 AM, Johannes Thumshirn wrote: > > On Wed, Jul 04, 2018 at 11:50:13PM -0700, Dan Williams wrote: > >> +static ssize_t memmap_state_store(struct device *dev, > >> + struct device_attribute *attr, const char *buf, size_t len) > >> +{ > >> + int i; > >> + struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); > >> + struct memmap_async_state *async = &nd_pfn->async; > >> + > >> + if (strcmp(buf, "sync") == 0) > >> + /* pass */; > >> + else if (strcmp(buf, "sync\n") == 0) > >> + /* pass */; > >> + else > >> + return -EINVAL; > > > > Hmm what about: > > > > if (strncmp(buf, "sync", 4)) > > return -EINVAL; > > > > This collapses 6 lines into 4. > > ...but that also allows 'echo "syncAndThenSomeGarbage" > > /sys/.../memmap_state' to succeed. if (strncmp(buf, "sync", 4)) return -EINVAL; if (buf[4] != '\0' && buf[4] != '\n') return -EINVAL;