From patchwork Tue Apr 30 12:23:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2504371 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 83F34DF2F2 for ; Tue, 30 Apr 2013 12:23:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760552Ab3D3MXp (ORCPT ); Tue, 30 Apr 2013 08:23:45 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:62447 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760543Ab3D3MXp (ORCPT ); Tue, 30 Apr 2013 08:23:45 -0400 Received: by mail-ie0-f170.google.com with SMTP id at1so488977iec.15 for ; Tue, 30 Apr 2013 05:23:44 -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=udIqLkVit/uKXO71Metoe6+y69u7bY/jW1M/l092VRE=; b=exZ+0YLZgbjhR0DJ+qBrkgaX02uGUq2KDQyVCMe0JbLeAy8Ln/11Zw72ERfCAbHpk7 wJMiV8K+2CbLELvTm5SYuCTF8TEclHpxLE6bL4OaR7z4d+iWtgKjuhcPVGNrOO3PLX3q PLqXd8oi22r2C7DSmSgT0StCRIGMdXuL50NiP7dWar2FtYqZ65NveNeWhxyfSzwFZN6N 5zxKqyGB811AivJjNcBr7AIAcUc9prn4cONMzkqBsqAMY28yrZcLcesx4zUOysmhxo3x 5V2mBfNkKkIZikQZZ7fSPtR0urdXiDgsSUwGcmjRojL4epBNRoO8/IQa+tgXzOTBT7jY x3Lw== X-Received: by 10.42.48.7 with SMTP id q7mr3493609icf.35.1367324624694; Tue, 30 Apr 2013 05:23:44 -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 ua6sm22307289igb.0.2013.04.30.05.23.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 05:23:43 -0700 (PDT) Message-ID: <517FB7CE.9050809@inktank.com> Date: Tue, 30 Apr 2013 07:23:42 -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 3/3] rbd: snap names are pointer to constant data References: <517FB770.1070500@inktank.com> In-Reply-To: <517FB770.1070500@inktank.com> X-Gm-Message-State: ALoCoQlO3VEZ3EVZiBPav9hBttUzlPiasj4nZnjfHcWTXq9mWNdxjWmmW2eJ2TkCHk7zW8Kb6wAJ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Make explicit that snapshot names don't change by making functions return and take parameters that that point to const qualified data. This resolves: http://tracker.ceph.com/issues/4857 Signed-off-by: Alex Elder --- drivers/block/rbd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rbd_assert(which < rbd_dev->header.snapc->num_snaps); @@ -3907,7 +3907,7 @@ out: return ret; } -static char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, u32 which) +static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, u32 which) { size_t size; void *reply_buf; @@ -3948,13 +3948,13 @@ out: return snap_name; } -static char *rbd_dev_v2_snap_info(struct rbd_device *rbd_dev, u32 which, +static const char *rbd_dev_v2_snap_info(struct rbd_device *rbd_dev, u32 which, u64 *snap_size, u64 *snap_features) { u64 snap_id; u64 size; u64 features; - char *snap_name; + const char *snap_name; int ret; rbd_assert(which < rbd_dev->header.snapc->num_snaps); @@ -3978,7 +3978,7 @@ out_err: return ERR_PTR(ret); } -static char *rbd_dev_snap_info(struct rbd_device *rbd_dev, u32 which, +static const char *rbd_dev_snap_info(struct rbd_device *rbd_dev, u32 which, u64 *snap_size, u64 *snap_features) { if (rbd_dev->image_format == 1) @@ -4045,7 +4045,7 @@ static int rbd_dev_snaps_update(struct rbd_device *rbd_dev) while (index < snap_count || links != head) { u64 snap_id; struct rbd_snap *snap; - char *snap_name; + const char *snap_name; u64 snap_size = 0; u64 snap_features = 0; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index dbc61e3..ab5c901 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3435,10 +3435,10 @@ static struct rbd_snap *rbd_snap_create(struct rbd_device *rbd_dev, * Returns a dynamically-allocated snapshot name if successful, or a * pointer-coded error otherwise. */ -static char *rbd_dev_v1_snap_info(struct rbd_device *rbd_dev, u32 which, +static const char *rbd_dev_v1_snap_info(struct rbd_device *rbd_dev, u32 which, u64 *snap_size, u64 *snap_features) { - char *snap_name; + const char *snap_name; int i;