Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp555698ybg; Mon, 1 Jun 2020 08:19:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyF8L2gXYmShRxfNfLueoG0w43qWwh5Yx+lzed/xAtKBA030NTZuSqB0yUNIePm+xP8hTRo X-Received: by 2002:a17:906:ca4e:: with SMTP id jx14mr2126070ejb.285.1591024744109; Mon, 01 Jun 2020 08:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591024744; cv=none; d=google.com; s=arc-20160816; b=FLnh0+B7rUcf7UFWHDIEEqgjt6Nq2tOuV/KhsLZz+rB8xJ3xahtUpfY6mnZJSCy9KG JlohwpbpsZEy8RmeWrR8ik97nsWeORf8EsJ58tM36bXFAlBMl9lDE50kJQ6Fa1aM7I84 npALTc4xpahiBGnjFUMh/u7NK7EmzuQLmT+pq84AV2lM+xrmJdDbb5ls5h2ujDYEteke zNHA5M1q2L/HCsMwk+P7ywEUULmrWXlXIUlSoTztrPe8Xn735gF+TlQFDjqkw9Eq9YDV SeYelDNDm2LBTxiiCuwuoLNNH5c/LqomhzqBMDpT1XZv55q3FDGOUEf/GdzwkDesvZlM 8+3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=D1NrWnBXAgRg2KxeLwW3lntZ1glhDJtcdN6wq+Yi4xU=; b=ltBenkprv6Z2OuMzIY2JEBCJSAmgB2H0uu7BN/D9Hzs0bli+sK1g3OEUmUHWMCSfwR QU/rBFFX+i0e7NbVEiRZbBswVA1xM4Ld2soPGvNZYv7Ho0KdWWAWIKEc1WD1jinf+JPa AoArVIH7ReN2pJUpCUNMRLWX4GFQlDTf4cMY7aCavMTtv+urAoeWgi9u5uI8nIx+NxDf ZP4AXCOUXG2oqV6XbTDrbCXMcJOCaR52sGpXfACp8gVg9pNPt2xU4eH+RgBSFMMGN+0+ vYHzQGzuS6ms8IOZrIBY/m9+J0gAkbPrk3HriPs8Mj9wIYxPx2EP6Ozg5LO4DYpozboJ fIcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=s5FPHdwy; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si10879645ejh.293.2020.06.01.08.18.22; Mon, 01 Jun 2020 08:19:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=s5FPHdwy; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726125AbgFAPSV (ORCPT + 99 others); Mon, 1 Jun 2020 11:18:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbgFAPSU (ORCPT ); Mon, 1 Jun 2020 11:18:20 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B681C05BD43 for ; Mon, 1 Jun 2020 08:18:20 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id o9so8589707ljj.6 for ; Mon, 01 Jun 2020 08:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=D1NrWnBXAgRg2KxeLwW3lntZ1glhDJtcdN6wq+Yi4xU=; b=s5FPHdwyTRiWjZTOyyta1XIkfCT+fnvNXmjFpodI8rZkC2pw5ptI57INJDMLnzjCLY AHysbWqwbC6OrtgmBgOV2zgIkra5Nqxizx7eYI41iXGWmGm/MDnXMh149kNZfhiIfR8T +tJL+zl3vkqKfq7q/ub7RYHazI2+QxzqtEPSKFrpNqorOYel61sgWHNGiohmB+vyUGX5 HcLaW/Dny0Vf5YJi8THWg1Z5IlJnySqrK4UcK/dveiMOUTfexCDu5+QYGl2L0iqYf2uh uwvveBX1LzuKe3E0H5B2zLJxebXLNkJ+0dRpKjbcppuni6gX7YAnTD+KmO7Oq+BdI97r A2gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=D1NrWnBXAgRg2KxeLwW3lntZ1glhDJtcdN6wq+Yi4xU=; b=VhEl5xU+2NZpWYnlCn3+4/CwI+tViBloITY7j19HTbJF25mfmi/S0HD9OpomoVFFFa bAlbO1TmVgqzLa/iJMwG3egiWCBO5RN0FgsAEUitbKhnrwikrKuOPk0gEJ+irr95TU2C ksfc59KgLukOHJu2zVh7VLhzvg5e/J2YlKSBQwWP8TVqKBE0SmtV1Y94fEQ5qRMqnTVF LI7AhyaxP0Ai2lwWkY5t8dpXo3ouEH1NDSHRZ9hFgBrdMeOfd8frI/e39lbY27dtwuk7 TYXRTd7k1ZbO9f8vD2BOEvm+bsJbTo1tSOzODERQVlJ+m/ntJrzCc311E0z0FZsc6rUO ++TA== X-Gm-Message-State: AOAM533I3z0hTEBLgLM7C6WVNmYlJn+Xf+YrLM9qCy9cyqWW5kkpmwrH iz/ja9WnNXSbZGvoBO3sWyYdZhE6Ml0PG+vvy3x+gg== X-Received: by 2002:a2e:9586:: with SMTP id w6mr10599490ljh.274.1591024698761; Mon, 01 Jun 2020 08:18:18 -0700 (PDT) MIME-Version: 1.0 References: <20200529153814.213125-1-alainm@chromium.org> <20200529153814.213125-5-alainm@chromium.org> In-Reply-To: From: Alain Michaud Date: Mon, 1 Jun 2020 11:18:06 -0400 Message-ID: Subject: Re: [BlueZ PATCH v3 4/4] fixing const decoration warnins on options. To: Luiz Augusto von Dentz Cc: Alain Michaud , "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz, On Fri, May 29, 2020 at 1:17 PM Luiz Augusto von Dentz wrote: > > Hi Alain, > > On Fri, May 29, 2020 at 8:41 AM Alain Michaud wrote: > > > > This changes fixes const decoration warnins on options. > > What us this fixing? > > > --- > > > > Changes in v3: None > > Changes in v2: None > > > > src/main.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/src/main.c b/src/main.c > > index ca27f313d..cea50a3d2 100644 > > --- a/src/main.c > > +++ b/src/main.c > > @@ -80,7 +80,7 @@ static enum { > > MPS_MULTIPLE, > > } mps = MPS_OFF; > > > > -static const char *supported_options[] = { > > +static const char * const supported_options[] = { > > "Name", > > "Class", > > "DiscoverableTimeout", > > @@ -129,7 +129,7 @@ static const char * const controller_options[] = { > > NULL > > }; > > > > -static const char *policy_options[] = { > > +static const char * const policy_options[] = { > > "ReconnectUUIDs", > > "ReconnectAttempts", > > "ReconnectIntervals", > > @@ -137,7 +137,7 @@ static const char *policy_options[] = { > > NULL > > }; > > > > -static const char *gatt_options[] = { > > +static const char * const gatt_options[] = { > > "Cache", > > "KeySize", > > "ExchangeMTU", > > @@ -146,8 +146,8 @@ static const char *gatt_options[] = { > > }; > > > > static const struct group_table { > > - const char *name; > > - const char **options; > > + const char * const name; > > + const char * const * const options; > > } valid_groups[] = { > > { "General", supported_options }, > > { "Controller", controller_options }, > > @@ -243,7 +243,7 @@ static enum jw_repairing_t parse_jw_repairing(const char *jw_repairing) > > > > > > static void check_options(GKeyFile *config, const char *group, > > - const char **options) > > + const char * const * const options) > > { > > char **keys; > > int i; > > -- > > 2.27.0.rc0.183.gde8f92d652-goog > > > > I wonder how usufull is to tell it is a constant pointer to a constant > character given that is so rarely in the kernel and userspace, > something like const char * const * const would be very hard to keep > it readable. I'm personally a big fan of leveraging the compiler to find bugs, but in this case it also allows the compiler to put all the strings into read only sections. In this example, it will catch code trying to write into the string or prevent code execution in the read only sections if there is ever a bug that leverages this data section to store code that can be manipulated. For readability, I've seen other platforms use type definitions LPCSTR to typedef const char * const etc.. I'm happy to follow guidance here. > > -- > Luiz Augusto von Dentz