From patchwork Fri Feb 3 01:41:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9553413 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6F6C260424 for ; Fri, 3 Feb 2017 01:42:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 628F7284CE for ; Fri, 3 Feb 2017 01:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5770E284D5; Fri, 3 Feb 2017 01:42:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2F2E284CE for ; Fri, 3 Feb 2017 01:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752316AbdBCBmG (ORCPT ); Thu, 2 Feb 2017 20:42:06 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36433 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbdBCBld (ORCPT ); Thu, 2 Feb 2017 20:41:33 -0500 Received: by mail-pg0-f67.google.com with SMTP id 75so500181pgf.3; Thu, 02 Feb 2017 17:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U8hntTdT3qSkft1HiXUA63nhu07BF4zBGlHiiKXKgP4=; b=kjKu6tYz4gaxL6v5vKcAxrLqg0WGYr2K29RGZeOMorz9wLFfDZRfOI0TCfme7EcLde Vryy9dc2YNzYpKszVsOcbzQHrDeoxIRYKuO0LXFLpHO19/48KPuc7IhHOI4d2vkSztcu 8PhECJPvADZBXoPQmVJ1uQFm2+iw6W0Keqby1cDfBuUlNTDQNa931dKlw8cRJWKVrciA gTImfNtvq5puYwqx2rvXIYq8OaoIf7HXnlyruvAFZLU2ZAT5tfUm3qsFYS1v6wrsVtH/ jiNIlMFToA3FxeLfXPB12rxn+ECGrZTH07VMjHiJ2EBbCw1XhISsV25acJnkPzcj6lRa 10Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U8hntTdT3qSkft1HiXUA63nhu07BF4zBGlHiiKXKgP4=; b=dmO8ifUq5XWzy44jK8OKsYOgT4qrlh6ja1pQSTly2+YfI8kz/C4Psnnionz8EpKoVT ciggxF3hYFWX32n0uc1e46/Q+tg8mqlq5AFgVGA2BDV7EJ1VNEECFs1pO+NGcgeMWcJP PT/nYhnqvedIauPhGhbdfFD7J+pcUVeLOS4Ynzcl9KbT4nwEBTlEaCduMeUtlDDFrUJ4 r2N4Wd1m03sF9UcyTr6KQNCa5vzLl6nNK1idR96LficszD5WMHFn+FatAOO14FWXzl+t IHvQIx5DIR58uVPLHCYzhIAuFk/+R2Hehti9MUwDWMnanf+xj7USqCuoEPVJ7HDDyae1 uOXw== X-Gm-Message-State: AIkVDXJSRaqb1lfqloC/c4B6k9NHWPH+vytlXy3PxRb+7XC/eUYnN/UtuPZEt+vud3Dg2A== X-Received: by 10.98.29.195 with SMTP id d186mr14645326pfd.144.1486086092365; Thu, 02 Feb 2017 17:41:32 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id n28sm1252929pgd.5.2017.02.02.17.41.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Feb 2017 17:41:31 -0800 (PST) From: Dmitry Torokhov To: "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , Mika Westerberg , Hans de Goede , Wolfram Sang Subject: [PATCH v5 2/4] device property: constify property arrays values Date: Thu, 2 Feb 2017 17:41:26 -0800 Message-Id: <20170203014128.317-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170203014128.317-1-dmitry.torokhov@gmail.com> References: <20170203014128.317-1-dmitry.torokhov@gmail.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Data that is fed into property arrays should not be modified, so let's mark relevant pointers as const. This will allow us making source arrays as const/__initconst. Signed-off-by: Dmitry Torokhov --- drivers/base/property.c | 10 +++++----- include/linux/property.h | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index e9fa75645d69..31b942a29fdc 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -718,7 +718,8 @@ static void pset_free_set(struct property_set *pset) static int pset_copy_entry(struct property_entry *dst, const struct property_entry *src) { - const char **d, **s; + const char * const *s; + char **d; size_t i, nval; dst->name = kstrdup(src->name, GFP_KERNEL); @@ -731,12 +732,11 @@ static int pset_copy_entry(struct property_entry *dst, if (src->is_string) { nval = src->length / sizeof(const char *); - dst->pointer.str = kcalloc(nval, sizeof(const char *), - GFP_KERNEL); - if (!dst->pointer.str) + d = kcalloc(nval, sizeof(const char *), GFP_KERNEL); + if (!d) return -ENOMEM; - d = dst->pointer.str; + dst->pointer.raw_data = d; s = src->pointer.str; for (i = 0; i < nval; i++) { d[i] = kstrdup(s[i], GFP_KERNEL); diff --git a/include/linux/property.h b/include/linux/property.h index d37a4498b3ac..7a0a1cce5165 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -160,12 +160,12 @@ struct property_entry { bool is_string; union { union { - void *raw_data; - u8 *u8_data; - u16 *u16_data; - u32 *u32_data; - u64 *u64_data; - const char **str; + const void *raw_data; + const u8 *u8_data; + const u16 *u16_data; + const u32 *u32_data; + const u64 *u64_data; + const char * const *str; } pointer; union { unsigned long long raw_data;