From patchwork Fri Apr 26 17:59:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2494581 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 648B7DF230 for ; Fri, 26 Apr 2013 18:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756757Ab3DZSAD (ORCPT ); Fri, 26 Apr 2013 14:00:03 -0400 Received: from mail-ie0-f178.google.com ([209.85.223.178]:53162 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756661Ab3DZSAB (ORCPT ); Fri, 26 Apr 2013 14:00:01 -0400 Received: by mail-ie0-f178.google.com with SMTP id aq17so5373879iec.9 for ; Fri, 26 Apr 2013 11:00:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=ZZkBJCCT/bDs3ml/wQsuOygrfVHM4yNzEuxYs4Gg0hs=; b=GcqF3fkQs5q5l4KYkZQLebXAOJagzKnEBLLLjxTwA3FJZrrTVR1MemNsBDsxk/o39X ebDwOabj0McC5IByD+PrSZ1NsbPRms/ZmVvzlPVfTJE/N8o7xZtj7L2zghq8WwT5N1V5 cXJcUgn9BIzwPY6lZJa37bb0cFSrZXFkfO00M1sFgVNiWrVU6MusCTzsM0TUdG4dZoHZ QSL/wVF3g/GEsk16zrawn+XHPNwi6sDfUSuHM1Z59+519RURd4UJPYvqUV1e2cJJSqzO BmQfF4rD3o0QfB4wW7MUST1HOIRo4irEJbHFpwsBbXnjNbFs7JuqML+190dBzmDZ7h6e t9ow== X-Received: by 10.50.180.197 with SMTP id dq5mr2483716igc.22.1366999200725; Fri, 26 Apr 2013 11:00:00 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id fl5sm4337380igb.9.2013.04.26.10.59.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Apr 2013 11:00:00 -0700 (PDT) Message-ID: <517AC09F.1020900@inktank.com> Date: Fri, 26 Apr 2013 12:59:59 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 1/7] rbd: make rbd spec names pointer to const References: <517AC047.6060000@inktank.com> In-Reply-To: <517AC047.6060000@inktank.com> X-Gm-Message-State: ALoCoQnMw2x4cq7Mxgvjzb39z91y5pGMW/xRshWAbNQBS2T4u0bCfrhvL3iMb1HZCIBgafo5rJrF Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 Reviewed-by: Josh Durgin --- 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 */