Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1852577ybi; Thu, 4 Jul 2019 00:41:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7wlAmMFgMaVC4iT1i1LB89vMcYxWRcn75JhBdRPrG5r0FrnOtEBF5+so9Y/AdDOtHQ1tk X-Received: by 2002:a63:dc02:: with SMTP id s2mr42542751pgg.286.1562226105576; Thu, 04 Jul 2019 00:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562226105; cv=none; d=google.com; s=arc-20160816; b=xaByjFiSv2MeQNgnqJeX2dFDj3iiL0+bd0aqtt8RUO5NNpeiM3zt79NVl0NnFNEGH+ LUT05S/cRvkPe7FeUPQXwI3UZyOH9AHENAydsaEfpv52jeM11IzR056aoUSdp8U1ACrb PG4gZCfk8vqwC4xvkxTbMJ6ZTSc/ClBUawxjjon+wTmwiYc9EvLhHvpEsUaiFizVTKEH IrHrG9844FBW1p13GE+Btg34PSJ+1Zr92M92UK8iFLh18mPmIxCdsI/rhJdbKsnZ6dYc 4p4tSINc0zVnld2ciIXATMZnjaPNgKb54xwPAN9MM5UmfgOkNDPdWFTTaMKGNPTCGVxt zV9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=E20Nbg6+smiXQI1BPKQupyEB2AZzzR3IAVEPBxB9rMo=; b=Zi6BYiERK9XRml1JlsECvLHxOK1OFL8dTLnWs6YL/mdJCDwcvfizdNKsX+zjBKp4Tk rKp1BYelJagSQhuw52qDCLWu3BwfNboIq1+rt8SU/Cqoi8zkQysSWJBFtZHqIruO2mRe C2tHrdWLSazPXOvAPzOsrmzLGc/WftrLb3HAYJ8CV0/ckeatKXolNJbInV+FXmS5K+JP Zy0KQP3ucvy2oKX1AdIbT7x9+LIgDXXE5P10mNiC4GMMWovD6aNhhULPpsEdMIpdscVy NeXdHrHPbmlw7OCm6oFiC/J1fPEX++Deeno7mgGp7lsists7ikQEbGUNvc2LzUUu7yso LM+w== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15si2699179pfe.199.2019.07.04.00.41.20; Thu, 04 Jul 2019 00:41:45 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727408AbfGDHkn (ORCPT + 99 others); Thu, 4 Jul 2019 03:40:43 -0400 Received: from mga17.intel.com ([192.55.52.151]:28007 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbfGDHkn (ORCPT ); Thu, 4 Jul 2019 03:40:43 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2019 00:40:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,449,1557212400"; d="scan'208";a="158217438" Received: from ingas-nuc1.sea.intel.com ([10.254.86.21]) by orsmga008.jf.intel.com with ESMTP; 04 Jul 2019 00:40:41 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, Inga Stotland Subject: [PATCH BlueZ] mesh: Use l_dbus_message...() APIs in more consistent fashion Date: Thu, 4 Jul 2019 00:40:40 -0700 Message-Id: <20190704074040.18260-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This removes checks for the return values of l_dbus_message...() calls in the few places where we can rely on ell to handle error cases gracefully. --- mesh/dbus.c | 20 ++++++++++---------- mesh/dbus.h | 2 +- mesh/model.c | 33 +++++++++------------------------ 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/mesh/dbus.c b/mesh/dbus.c index 2b700a1ad..6b9694ab7 100644 --- a/mesh/dbus.c +++ b/mesh/dbus.c @@ -113,29 +113,29 @@ bool dbus_match_interface(struct l_dbus_message_iter *interfaces, return false; } -bool dbus_append_byte_array(struct l_dbus_message_builder *builder, +void dbus_append_byte_array(struct l_dbus_message_builder *builder, const uint8_t *data, int len) { int i; - if (!l_dbus_message_builder_enter_array(builder, "y")) - return false; + if (!builder) + return; - for (i = 0; i < len; i++) - if (!l_dbus_message_builder_append_basic(builder, 'y', - data + i)) - return false; + l_dbus_message_builder_enter_array(builder, "y"); - if (!l_dbus_message_builder_leave_array(builder)) - return false; + for (i = 0; i < len; i++) + l_dbus_message_builder_append_basic(builder, 'y', data + i); - return true; + l_dbus_message_builder_leave_array(builder); } void dbus_append_dict_entry_basic(struct l_dbus_message_builder *builder, const char *key, const char *signature, const void *data) { + if (!builder) + return; + l_dbus_message_builder_enter_dict(builder, "sv"); l_dbus_message_builder_append_basic(builder, 's', key); l_dbus_message_builder_enter_variant(builder, signature); diff --git a/mesh/dbus.h b/mesh/dbus.h index 879649452..e7643a59d 100644 --- a/mesh/dbus.h +++ b/mesh/dbus.h @@ -22,7 +22,7 @@ bool dbus_init(struct l_dbus *dbus); struct l_dbus *dbus_get_bus(void); -bool dbus_append_byte_array(struct l_dbus_message_builder *builder, +void dbus_append_byte_array(struct l_dbus_message_builder *builder, const uint8_t *data, int len); void dbus_append_dict_entry_basic(struct l_dbus_message_builder *builder, const char *key, const char *signature, diff --git a/mesh/model.c b/mesh/model.c index e4a7ba94e..b605d0148 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -249,10 +249,9 @@ static void config_update_model_pub_period(struct mesh_node *node, &period); l_dbus_message_builder_leave_array(builder); - if (l_dbus_message_builder_finalize(builder)) - l_dbus_send(dbus, msg); - + l_dbus_message_builder_finalize(builder); l_dbus_message_builder_destroy(builder); + l_dbus_send(dbus, msg); } static void append_dict_uint16_array(struct l_dbus_message_builder *builder, @@ -291,10 +290,9 @@ static void config_update_model_bindings(struct mesh_node *node, append_dict_uint16_array(builder, mod->bindings, "Bindings"); l_dbus_message_builder_leave_array(builder); - if (l_dbus_message_builder_finalize(builder)) - l_dbus_send(dbus, msg); - + l_dbus_message_builder_finalize(builder); l_dbus_message_builder_destroy(builder); + l_dbus_send(dbus, msg); } static void forward_model(void *a, void *b) @@ -714,28 +712,15 @@ static void send_msg_rcvd(struct mesh_node *node, uint8_t ele_idx, bool is_sub, builder = l_dbus_message_builder_new(msg); - if (!l_dbus_message_builder_append_basic(builder, 'q', &src)) - goto error; - - if (!l_dbus_message_builder_append_basic(builder, 'q', &key_idx)) - goto error; + l_dbus_message_builder_append_basic(builder, 'q', &src); + l_dbus_message_builder_append_basic(builder, 'q', &key_idx); + l_dbus_message_builder_append_basic(builder, 'b', &is_sub); - if (!l_dbus_message_builder_append_basic(builder, 'b', &is_sub)) - goto error; - - if (!dbus_append_byte_array(builder, data, size)) - goto error; - - if (!l_dbus_message_builder_finalize(builder)) - goto error; + dbus_append_byte_array(builder, data, size); + l_dbus_message_builder_finalize(builder); l_dbus_message_builder_destroy(builder); l_dbus_send(dbus, msg); - return; - -error: - l_dbus_message_builder_destroy(builder); - l_dbus_message_unref(msg); } bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, -- 2.21.0