From: Dan Streetman <ddstreet@ieee.org>
To: Joey Pabalinas <joeypabalinas@gmail.com>
Cc: Linux-MM <linux-mm@kvack.org>,
Seth Jennings <sjenning@redhat.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] mm/zswap: make type and compressor const
Date: Mon, 8 Jan 2018 14:22:13 -0500 [thread overview]
Message-ID: <CALZtOND9r9gz8cUPYfRN7Wjaowcx1uHnqQbNw8Qxo8pRSgJwcw@mail.gmail.com> (raw)
In-Reply-To: <20180102100320.24801-2-joeypabalinas@gmail.com>
On Tue, Jan 2, 2018 at 5:03 AM, Joey Pabalinas <joeypabalinas@gmail.com> wrote:
> The characters pointed to by `zswap_compressor`, `type`, and `compressor`
> aren't ever modified. Add const to the static variable and both parameters in
> `zswap_pool_find_get()`, `zswap_pool_create()`, and `__zswap_param_set()`
>
> Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>
Nak.
Those variables are not const; they are updated in
__zswap_param_set(). They aren't modified in pool_find_get() or
pool_create(), but they certainly aren't globally const.
>
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index d39581a076c3aed1e9..a4f2dfaf9131694265 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -90,7 +90,7 @@ module_param_cb(enabled, &zswap_enabled_param_ops, &zswap_enabled, 0644);
>
> /* Crypto compressor to use */
> #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
> -static char *zswap_compressor = ZSWAP_COMPRESSOR_DEFAULT;
> +static const char *zswap_compressor = ZSWAP_COMPRESSOR_DEFAULT;
> static int zswap_compressor_param_set(const char *,
> const struct kernel_param *);
> static struct kernel_param_ops zswap_compressor_param_ops = {
> @@ -475,7 +475,8 @@ static struct zswap_pool *zswap_pool_last_get(void)
> }
>
> /* type and compressor must be null-terminated */
> -static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor)
> +static struct zswap_pool *zswap_pool_find_get(const char *type,
> + const char *compressor)
> {
> struct zswap_pool *pool;
>
> @@ -495,7 +496,8 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor)
> return NULL;
> }
>
> -static struct zswap_pool *zswap_pool_create(char *type, char *compressor)
> +static struct zswap_pool *zswap_pool_create(const char *type,
> + const char *compressor)
> {
> struct zswap_pool *pool;
> char name[38]; /* 'zswap' + 32 char (max) num + \0 */
> @@ -658,7 +660,7 @@ static void zswap_pool_put(struct zswap_pool *pool)
>
> /* val must be a null-terminated string */
> static int __zswap_param_set(const char *val, const struct kernel_param *kp,
> - char *type, char *compressor)
> + const char *type, const char *compressor)
> {
> struct zswap_pool *pool, *put_pool = NULL;
> char *s = strstrip((char *)val);
> --
> 2.15.1
>
--
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:[~2018-01-08 19:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-02 10:03 [PATCH 0/2] mm/zswap: add minor const/conditional optimizations Joey Pabalinas
2018-01-02 10:03 ` [PATCH 1/2] mm/zswap: make type and compressor const Joey Pabalinas
2018-01-08 19:22 ` Dan Streetman [this message]
2018-01-02 10:03 ` [PATCH 2/2] mm/zswap: move `zswap_has_pool` to front of `if ()` Joey Pabalinas
2018-01-08 19:34 ` 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=CALZtOND9r9gz8cUPYfRN7Wjaowcx1uHnqQbNw8Qxo8pRSgJwcw@mail.gmail.com \
--to=ddstreet@ieee.org \
--cc=joeypabalinas@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sjenning@redhat.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