From: Andrew Morton <akpm@linux-foundation.org>
To: Dan Streetman <ddstreet@ieee.org>
Cc: Seth Jennings <sjennings@variantweb.net>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
kbuild test robot <fengguang.wu@intel.com>
Subject: Re: [PATCH 1/2] zpool: define and use max type length
Date: Tue, 18 Aug 2015 15:38:18 -0700 [thread overview]
Message-ID: <20150818153818.cab58a99f60113c2aca2f006@linux-foundation.org> (raw)
In-Reply-To: <1439928361-31294-1-git-send-email-ddstreet@ieee.org>
On Tue, 18 Aug 2015 16:06:00 -0400 Dan Streetman <ddstreet@ieee.org> wrote:
> Add ZPOOL_MAX_TYPE_NAME define, and change zpool_driver *type field to
> type[ZPOOL_MAX_TYPE_NAME]. Remove redundant type field from struct zpool
> and use zpool->driver->type instead.
>
> The define will be used by zswap for its zpool param type name length.
>
Patchset is fugly. All this putzing around with fixed-length strings,
worrying about overflow and is-it-null-terminated-or-isnt-it. Shudder.
It's much better to use variable-length strings everywhere. We're not
operating in contexts which can't use kmalloc, we're not
performance-intensive and these strings aren't being written to
fixed-size fields on disk or anything. Why do we need any fixed-length
strings?
IOW, why not just replace that alloca with a kstrdup()?
> --- a/include/linux/zpool.h
> +++ b/include/linux/zpool.h
>
> ...
>
> @@ -79,7 +77,7 @@ static struct zpool_driver *zpool_get_driver(char *type)
>
> spin_lock(&drivers_lock);
> list_for_each_entry(driver, &drivers_head, list) {
> - if (!strcmp(driver->type, type)) {
> + if (!strncmp(driver->type, type, ZPOOL_MAX_TYPE_NAME)) {
Why strncmp? Please tell me these strings are always null-terminated.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-08-18 22:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-18 20:06 Dan Streetman
2015-08-18 20:06 ` [PATCH 2/2] zswap: use const max length for kparam names Dan Streetman
2015-08-18 22:38 ` Andrew Morton [this message]
2015-08-19 2:20 ` [PATCH 1/2] zpool: define and use max type length Dan Streetman
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=20150818153818.cab58a99f60113c2aca2f006@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=ddstreet@ieee.org \
--cc=fengguang.wu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sjennings@variantweb.net \
/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