Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8866934ybi; Wed, 10 Jul 2019 00:41:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4+25ZFNTwLjcl/Q8k7Xqh0VUQUcI1B7hCMj5gv+q2sbAKH8vghHT0V1Jc2VcHMXOVjsRH X-Received: by 2002:a17:902:6a85:: with SMTP id n5mr35092923plk.73.1562744488049; Wed, 10 Jul 2019 00:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562744488; cv=none; d=google.com; s=arc-20160816; b=QSXdPSfG1BgPXvNg8CjigsUXRm4WEh6Z1Vgf/aAjd7hCsXJLsQAr+qXVSdc5IaP/UW XDeBzYCR4B6TX0nJ5A2NMdKQ3nauDzLj1qkR9hVJek4NpOsJCIMS/aA9fhCuEg/Jbd1K EnYL3AyLO3/JPrR23+jx/2M7hYJ2N3K8V6OB/WB3a5ulECDdR/5qsIcU9eM7218BeXfO IWt6QJ/UgI8XhXD1aRKkbIKq3YPRGR92Au/RiO48X0vt+3dUnOWKCvg4dTYe3e79E71Q O9+myy8MLE7KqLBi1xyUZmh+m8m/CeFYZaCaeP0UnV88tDldEGvq/4gMcFGp1KX2U1DO wj+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=CZDxR4xgfgD0Xnp8CDS9w0flO3T8ocjdBsGpxn2o0ms=; b=CqUBkksf9/sbgyZf9hyBgRZDDsti7Ifd62/Aa66IPSc1WA5ntxOk+CHjiIH1WBsMN6 rxmwzVDqDAXTX16+41hKHsED5ACyfacQJVb/409PIzI4iDRqDEpVQf1gx5+VWlMF8dH+ wFTJyVMcWUsDUtc5Sa9r1gHvHg+udZLVTEmVd2GjHjq44eSjYvvJ01Ire3raxG9+Cx0a DDYGMfHQWaEWa0QTWhKaCPYW4KQ3jKw3NTHdeKHaws5HnUzGvUbNtmnTrjlqyWY8dsRB /zI+LZPoaAW+4dL7rncBRWsRqUkvwgIkYNbmupLclYDTjXNs6oWnAxD7CItzkPxBlLX9 Y7lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=wrNc50jL; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y12si1519155pge.187.2019.07.10.00.41.13; Wed, 10 Jul 2019 00:41:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=wrNc50jL; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726203AbfGJHic (ORCPT + 99 others); Wed, 10 Jul 2019 03:38:32 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:39612 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbfGJHic (ORCPT ); Wed, 10 Jul 2019 03:38:32 -0400 Received: by mail-lj1-f196.google.com with SMTP id v18so1047362ljh.6 for ; Wed, 10 Jul 2019 00:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=CZDxR4xgfgD0Xnp8CDS9w0flO3T8ocjdBsGpxn2o0ms=; b=wrNc50jLxfAg1bK3CpFw7ewu8Ck51Rh8A+4hiVjGNcktaL+LX4NlnZUZHwAYOWgHg9 UbDRgZNxsKR75x7KjPXG9xoXr3Mezo/mQejHikOXVMoHkkxKDctU7O+fbVtpkCCnJpZy QNZjh1g8cp/GrC10e2+gfhj3O9e8ZwuMlQc2PUapPVuUd4c8QWLgor72xIPeiqxnuOBX WSe3v3vtb8UvEHQR5J3Ryn6J002BUPrsst5fdedJgRNCgkCgt6DEjdWzrKqW/t+CGepF Whc3UCsq6DiE7hcGpAepgHIQQWRwkQV4+/O9ImtzSWaCBHJxr48e7CnXky6qytfEk6Q8 LlIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=CZDxR4xgfgD0Xnp8CDS9w0flO3T8ocjdBsGpxn2o0ms=; b=MJXmlNJ0ldZc2pG/WE+AkPXLikImNxaWlMVaS4RLxnTpHI/kC4g+8FQgX4oToJGAjm wZeDdZiaNdFrQECHH+6uyClpx2uHwRQsuy/fMfrMiftMm3ClnOj4U6r+qzkyr5yLQX1T qNcefgLOaabyncu9ZfslDVW0HsKwLLY4GDVmAEERjtrn7daTmfRgyN4BQZt6LfqaemJl 53IF7bbGwrGWaK5wIAqNmIZdArOCN+24U89QFz/QwYbz2jNnU9OCiLAajjsyzVD5qZfD n4VhvkSgmxMua4/DjnFKWpGlHRnjdXAqLKMo7Usfdd+07e2hiUsaoxOUk+u7I59XWDYl pCpA== X-Gm-Message-State: APjAAAVNHEErat7tQOXmQ6CNAu2+tEvsnkY6yO038Ck8ytbkj/KKJQH1 BEOQgcz1zqLtBkyUtAtkqV3yoQ== X-Received: by 2002:a2e:995a:: with SMTP id r26mr16476166ljj.107.1562744310199; Wed, 10 Jul 2019 00:38:30 -0700 (PDT) Received: from mlowasrzechonek2133 ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id n124sm228454lfd.46.2019.07.10.00.38.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 10 Jul 2019 00:38:29 -0700 (PDT) Date: Wed, 10 Jul 2019 09:38:27 +0200 From: =?utf-8?Q?Micha=C5=82?= Lowas-Rzechonek To: Inga Stotland Cc: linux-bluetooth@vger.kernel.org, brian.gix@intel.com, jakub.witowski@silvair.com Subject: Re: [PATCH BlueZ 4/9] mesh: Generalize mesh-config APIs Message-ID: <20190710073827.5ktzlyynztmebiv6@mlowasrzechonek2133> Mail-Followup-To: Inga Stotland , linux-bluetooth@vger.kernel.org, brian.gix@intel.com, jakub.witowski@silvair.com References: <20190710050959.7321-1-inga.stotland@intel.com> <20190710050959.7321-5-inga.stotland@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190710050959.7321-5-inga.stotland@intel.com> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Inga, On 07/09, Inga Stotland wrote: > This changes argument for each mesh-config API to use void* as > a pointer to a node configuration object. This makes usage of JSON > opaque for the rest of the code and allows to plug in a non-JSON > configuration storage implementation. > --- > mesh/mesh-config-json.c | 228 +++++++++++++++++++++++----------------- > mesh/mesh-config.h | 107 +++++++++---------- > 2 files changed, 180 insertions(+), 155 deletions(-) > > diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c > index 8fcb8afe3..5ca086ad0 100644 > --- a/mesh/mesh-config-json.c > +++ b/mesh/mesh-config-json.c > @@ -252,10 +252,14 @@ static json_object *jarray_key_del(json_object *jarray, int16_t idx) > return jarray_new; > } > > -bool mesh_config_read_iv_index(json_object *jobj, uint32_t *idx, bool *update) > +bool mesh_config_read_iv_index(void *cfg, uint32_t *idx, bool *update) I'm not a fan of using void* for polymorphism. While there are places this makes sense (e.g. user_data pointers in callbacks), I think we should try to avoid this in our APIs. Since the proposed patch assumes that we would switch backends during the build, and you can't have two different config formats compiled in at the same time, how about this: mesh-config.h: union mesh_config; union mesh_config *mesh_config_create_config(void); void mesh_config_release_config(union mesh_config *config); mesh-config-json.c: union mesh_config { json_object *json }; union mesh_config *mesh_config_create_config(void) { return (union mesh_config*)json_object_new_object(); } void mesh_config_release_config(union mesh_config *cfg) { json_object *jnode = (json_object *)cfg; if (!cfg) return; json_object_put(jnode); } etc. -- Michał Lowas-Rzechonek Silvair http://silvair.com Jasnogórska 44, 31-358 Krakow, POLAND