Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933011AbeAHTXD (ORCPT + 1 other); Mon, 8 Jan 2018 14:23:03 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:33232 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756537AbeAHTWy (ORCPT ); Mon, 8 Jan 2018 14:22:54 -0500 X-Google-Smtp-Source: ACJfBovtDrFLHOCyZ5huPyM3dHhjIywSFDZssJHQhlliLrg1m8hGjmsCmt6B/9L/i1moHPLne0h1AamXkEHnDVUND8E= MIME-Version: 1.0 In-Reply-To: <20180102100320.24801-2-joeypabalinas@gmail.com> References: <20180102100320.24801-1-joeypabalinas@gmail.com> <20180102100320.24801-2-joeypabalinas@gmail.com> From: Dan Streetman Date: Mon, 8 Jan 2018 14:22:13 -0500 X-Google-Sender-Auth: mU8n730ACx2syKisnqSE6-QJqQI Message-ID: Subject: Re: [PATCH 1/2] mm/zswap: make type and compressor const To: Joey Pabalinas Cc: Linux-MM , Seth Jennings , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, Jan 2, 2018 at 5:03 AM, Joey Pabalinas 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 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 >