public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>,
	Peter Kalauskas <peskal@google.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] zram: fix bug storing backing_dev
Date: Wed, 15 Aug 2018 20:32:26 -0700	[thread overview]
Message-ID: <20180815203226.2c7e48b2f9395d2772ecfcb2@linux-foundation.org> (raw)
In-Reply-To: <20180816014835.GA2793@jagdpanzerIV>

On Thu, 16 Aug 2018 10:48:35 +0900 Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:

> > The implementation might be able to use strim() somehow.
> 
> strim() trims white-spaces.

Which includes \n.

> What we have here is a trailing new line symbol,
> which echo appends to the string it writes to the kernel [echo -n switch
> disables it]. So we receive a "/dev/name\n" device name from sysfs, which we
> unsuccessfully try to open(). To make it all work we need to remove that
> trailing new line.
> 
> A side note,
> There is sysfs_strcmp(), which takes care of that "user space may append
> a new line to the string" case, I wonder if we should finally have
> sysfs_strcpy(), which would not copy the trailing new line. I think this
> "if string[sz - 1] == '\n' then string[sz - 1] == 0x00" is quite common.

Sure, some additional well-chosen helpers here would be good.  There's
a LOT of code which does basically-the-same-thing with sysfs input. 
And a lot of it misses things, such as leading whitespace.  Passing all
this through helpers would provide consistency as well as code-size
reductions, improved reviewability, etc.



  parent reply	other threads:[~2018-08-16  3:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180808223100.225086-1-peskal@google.com>
2018-08-13  6:16 ` [PATCH] zram: fix bug storing backing_dev Minchan Kim
2018-08-13  7:38   ` Sergey Senozhatsky
2018-08-14 23:45     ` Andrew Morton
2018-08-16  1:48       ` Sergey Senozhatsky
2018-08-16  1:57         ` Sergey Senozhatsky
2018-08-16  3:32         ` Andrew Morton [this message]
     [not found]       ` <20180821160307.GA63897@google.com>
2018-08-22  1:28         ` Peter Kalauskas
     [not found]         ` <20180822004504.GB2218@jagdpanzerIV>
2018-08-22  1:29           ` Peter Kalauskas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180815203226.2c7e48b2f9395d2772ecfcb2@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=peskal@google.com \
    --cc=sergey.senozhatsky.work@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox