diff mbox

[1/7] rbd: make rbd spec names pointer to const

Message ID 517AC09F.1020900@inktank.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Elder April 26, 2013, 5:59 p.m. UTC
Make the names and image id in an rbd_spec be pointers to constant
data.  This required the use of a local variable to hold the
snapshot name in rbd_add_parse_args() to avoid a warning.

Signed-off-by: Alex Elder <elder@inktank.com>
---
 drivers/block/rbd.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Josh Durgin April 29, 2013, 3:34 p.m. UTC | #1
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 04/26/2013 10:59 AM, Alex Elder wrote:
> Make the names and image id in an rbd_spec be pointers to constant
> data.  This required the use of a local variable to hold the
> snapshot name in rbd_add_parse_args() to avoid a warning.
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   drivers/block/rbd.c |   16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index cacbc30..d989914 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -138,13 +138,13 @@ struct rbd_image_header {
>    */
>   struct rbd_spec {
>   	u64		pool_id;
> -	char		*pool_name;
> +	const char	*pool_name;
>
> -	char		*image_id;
> -	char		*image_name;
> +	const char	*image_id;
> +	const char	*image_name;
>
>   	u64		snap_id;
> -	char		*snap_name;
> +	const char	*snap_name;
>
>   	struct kref	kref;
>   };
> @@ -4375,6 +4375,7 @@ static int rbd_add_parse_args(const char *buf,
>   	size_t len;
>   	char *options;
>   	const char *mon_addrs;
> +	char *snap_name;
>   	size_t mon_addrs_size;
>   	struct rbd_spec *spec = NULL;
>   	struct rbd_options *rbd_opts = NULL;
> @@ -4433,10 +4434,11 @@ static int rbd_add_parse_args(const char *buf,
>   		ret = -ENAMETOOLONG;
>   		goto out_err;
>   	}
> -	spec->snap_name = kmemdup(buf, len + 1, GFP_KERNEL);
> -	if (!spec->snap_name)
> +	snap_name = kmemdup(buf, len + 1, GFP_KERNEL);
> +	if (!snap_name)
>   		goto out_mem;
> -	*(spec->snap_name + len) = '\0';
> +	*(snap_name + len) = '\0';
> +	spec->snap_name = snap_name;
>
>   	/* Initialize all rbd options to the defaults */
>

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index cacbc30..d989914 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -138,13 +138,13 @@  struct rbd_image_header {
  */
 struct rbd_spec {
 	u64		pool_id;
-	char		*pool_name;
+	const char	*pool_name;

-	char		*image_id;
-	char		*image_name;
+	const char	*image_id;
+	const char	*image_name;

 	u64		snap_id;
-	char		*snap_name;
+	const char	*snap_name;

 	struct kref	kref;
 };
@@ -4375,6 +4375,7 @@  static int rbd_add_parse_args(const char *buf,
 	size_t len;
 	char *options;
 	const char *mon_addrs;
+	char *snap_name;
 	size_t mon_addrs_size;
 	struct rbd_spec *spec = NULL;
 	struct rbd_options *rbd_opts = NULL;
@@ -4433,10 +4434,11 @@  static int rbd_add_parse_args(const char *buf,
 		ret = -ENAMETOOLONG;
 		goto out_err;
 	}
-	spec->snap_name = kmemdup(buf, len + 1, GFP_KERNEL);
-	if (!spec->snap_name)
+	snap_name = kmemdup(buf, len + 1, GFP_KERNEL);
+	if (!snap_name)
 		goto out_mem;
-	*(spec->snap_name + len) = '\0';
+	*(snap_name + len) = '\0';
+	spec->snap_name = snap_name;

 	/* Initialize all rbd options to the defaults */