Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp333121ybg; Wed, 10 Jun 2020 01:56:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw47xuRlX5hH08Fjws6h+yYurRtBsjafJJRn43idqo7CTPEROJiAUV29LugxXJtjVOEBpw X-Received: by 2002:a17:906:ae5b:: with SMTP id lf27mr2529225ejb.156.1591779394370; Wed, 10 Jun 2020 01:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591779394; cv=none; d=google.com; s=arc-20160816; b=lLBE38l3wKVT3v/e6Eyw/ACFSLP/F6sX2c19bo9KR64Btel2vjKYU/663+tV9nc9W9 h5THmRb22LGY/So4VWIBkusqf6zsDtkoUUrL+YjrShcii3bdVoTTFEbrh+59WacUDHM8 XMlz8NTHCU1kx63fdozqqFommjknYQlGje20VmLTpZBRPHBOfcUTy1wmm/ylrBqMeqri 2KKEUGb2/98wH4v+bG9TQrpsYRtkMcNNpKTyD+1EDDn3/hIdvL30Z8ga7y81/4BT52zm RqVNddlOutaCbAA7C62Sr9gbvKrYXCxE+VW2wV1g6Nos7pF1rKszUkrCigIhBzgdu5SO QaCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=SfvkGii5oMyn0xn7FrN6geYFZUIQ6PgR81CBXKIZemg=; b=fW7pr0YStCB9z7RTipNyy3NY3TlABqG0yzR+A80jOlziLqd53p2F6HzIJCAYi6Stcc otLfXz2xmr5y+hHqKLXfG5seARw4N9mel18wsLSRLisWNzuYOujeSNsVWwx/KkO6SDl7 XXuj0LcQdX0v3LKtEvdL3ndPvW0T/s6vgoFhtSKM8LSIMfNYOpDpGqRmmSg0xHOeOJQ0 /d35HXmk8hhjn8A/5yMDCQ9MnL2M0rFz05wbZgEexTpSorOSUb/WdpYzNPK/0uCmcIYY 8BlTd7hzgbYgcmsaGPMGp858nkWg6Hed4FD0n7Tots4ZIeVMezpWfB5iblh6XA3mAsDG mxrw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si12434102edb.577.2020.06.10.01.56.09; Wed, 10 Jun 2020 01:56:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726886AbgFJIzN convert rfc822-to-8bit (ORCPT + 99 others); Wed, 10 Jun 2020 04:55:13 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:49217 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbgFJIzN (ORCPT ); Wed, 10 Jun 2020 04:55:13 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 086BDCECE0; Wed, 10 Jun 2020 11:05:01 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [BlueZ PATCH v3 4/4] fixing const decoration warnins on options. From: Marcel Holtmann In-Reply-To: Date: Wed, 10 Jun 2020 10:55:10 +0200 Cc: Luiz Augusto von Dentz , Alain Michaud , "linux-bluetooth@vger.kernel.org" Content-Transfer-Encoding: 8BIT Message-Id: References: <20200529153814.213125-1-alainm@chromium.org> <20200529153814.213125-5-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Alain, >>> --- >>> >>> 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. I am a big fan of letting the compiler help us, but the readability concerns me a bit in this case. Can we explore what kind of macros we might be able to introduce to make this easier on the eyes. Regards Marcel