From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x242.google.com (mail-oi0-x242.google.com [IPv6:2607:f8b0:4003:c06::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 96930210C283F for ; Thu, 5 Jul 2018 12:52:09 -0700 (PDT) Received: by mail-oi0-x242.google.com with SMTP id k12-v6so19141057oiw.8 for ; Thu, 05 Jul 2018 12:52:09 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <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> <20180705194936.GA28447@bombadil.infradead.org> From: Dan Williams Date: Thu, 5 Jul 2018 12:52:07 -0700 Message-ID: Subject: Re: [PATCH 13/13] libnvdimm, namespace: Publish page structure init state / control List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Matthew Wilcox Cc: linux-nvdimm , Linux Kernel Mailing List , Christoph Hellwig , Linux MM , Andrew Morton List-ID: On Thu, Jul 5, 2018 at 12:49 PM, Matthew Wilcox wrote: > 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; > Not sure that's a win either, I'd rather just: + if (strcmp(buf, "sync") == 0 || strcmp(buf, "sync\n") == 0) + /* pass */; + else + return -EINVAL; If we're trying to save those 2 lines. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm