Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1019727imm; Thu, 5 Jul 2018 13:06:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfJNifFhshsa7x/w8AvHXnySEcDAG6YrbB5iTDTMjXTC8Mrtr4tqOGcBCbJcVF97DHSOvrO X-Received: by 2002:a65:64d3:: with SMTP id t19-v6mr6883610pgv.148.1530821196542; Thu, 05 Jul 2018 13:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530821196; cv=none; d=google.com; s=arc-20160816; b=wY4d1BmgmiyTzCG61xKAqgBgQDhy/RQJYXo0wFNRNAHAR09rhylt7trfXt6j2Mtcso yXd2R7EkpTMVbf3YVGiGYh91Ix7zMoOdmylZOCw7n7YRbtBM5U9Z5jqlZecWoKSLt3iU aWl/OweBZUS5lO9QhcFKgwO37oVW7eXsTDZFymm4MLQY3/KTkl5Fdj7CjJQH6DlfJmc/ Fb7im20Ok52PnY/mgnHEUHVSCzcXNChsXhjVWOuwrBj5n/L8A9132GLYokqQPPnblH6O O1/12Uo/4eaKhCyIxQ5FG12FpK/NvECF6Q9KazDRiis/NGC5uHXTOXdCDvEtybi5sYLY +3zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=KIC16vNbqmLNLC2xRVzYA4sLE03eUSMFYWj08BRNe0k=; b=eOwOH1ZBc4jmfHyQTjn/uJq2ft4AWkxGhzgGojbr+hDEcW5R6TEYmbtsGk1vpdJKOW Fsib9eVRv9dWyf6XO/YRpanLvA7NkPgWRnutNjOCzTIOEum4jBvmW8bvEkyy0XRVvOvm QfCFJY7rzduw8yC65gZ+KatNDXsnDNf8YRNAWfgLA7hI2cuchuc7y6lv52wJO5nivxwb MNyXC5EBklX5jHaI8McuN2yXzsC9Kmk793OANLzivoGXyDwzxNW/259J3o0Y9touH2KX 3LOoeXzQXh8ojcHGOAXBiQOMl9njbZkm7C9DaFjqjgOIdz6SJZ8GpKXcSKr1KsEQzz/V rT9w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10-v6si6184676pgc.261.2018.07.05.13.06.09; Thu, 05 Jul 2018 13:06:36 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754044AbeGEUA2 (ORCPT + 99 others); Thu, 5 Jul 2018 16:00:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36672 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753961AbeGEUA1 (ORCPT ); Thu, 5 Jul 2018 16:00:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 553E940B6C0F; Thu, 5 Jul 2018 20:00:26 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 42B012026D74; Thu, 5 Jul 2018 20:00:25 +0000 (UTC) From: Jeff Moyer To: Dan Williams Cc: Matthew Wilcox , Johannes Thumshirn , Andrew Morton , Ross Zwisler , Vishal Verma , Dave Jiang , Christoph Hellwig , linux-nvdimm , Linux MM , Linux Kernel Mailing List Subject: Re: [PATCH 13/13] libnvdimm, namespace: Publish page structure init state / control 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> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-PCLoadLetter: What the f**k does that mean? Date: Thu, 05 Jul 2018 16:00:25 -0400 In-Reply-To: (Dan Williams's message of "Thu, 5 Jul 2018 12:52:07 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 05 Jul 2018 20:00:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 05 Jul 2018 20:00:26 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jmoyer@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dan Williams writes: > 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. WFM. I don't like that I had to go digging around in sysfs documentation to convince myself that strcmp was safe, but I guess that's my problem. ;-) Cheers, Jeff