Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1899682rwb; Thu, 8 Dec 2022 17:13:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf6lx3nxc/HLR6oMZcV/UjNaHWR2Wt0hA3CXrZJvwe0HHnw2lsj4jmMaMCVAJ3jDA97vgS6b X-Received: by 2002:a17:902:aa4b:b0:187:204a:d92b with SMTP id c11-20020a170902aa4b00b00187204ad92bmr3641132plr.10.1670548391859; Thu, 08 Dec 2022 17:13:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670548391; cv=none; d=google.com; s=arc-20160816; b=qQ0Drf9bYPQO6h14fKNB9o/KCMzL89vMx7z4thNh9mX3pC+p1EOUOcyUFkOGxkenK6 FceiWEJtKe2tJAFXc6zyG8N4CM8U9aLxvj4hR6YqDR8G/bOFth/0mlJ4V/nas2shco3A twACGFdMvPyMVu+upwIjAvsr7e2H9N0zpOrJjC0dCZyeJhCygG8Ij7A7vmhlvuXBCE3X USwyDiVTpZD7RddDjBA9bNGQCKsP7/C/+SHv8eqQ9SCs24wsnZ3tGl7T6tNaJuQKPikl YXmCyLryLaVZvriv1yuv3Q0jSjT+JQ1sIST3Bzcx8EuMHRr1434pQdRSSQI+oinfNIiy iRTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=uIG1fSR1LOk0TcUreHrxo/p2PRAMeYSvgKLfpsnCyGw=; b=PzZ/puJ2+5w+ubTfq8mHR+LVnICIbeQDgDncox4nm2elVLgklVuYXJxGUqoDkt74c5 ulV5I/msDsqHh6YtHLUdDDwOPfG69kEij0m6IW29eiGd2wSvLrpnVQUDktWyU1xmv/Pw lxDmNRc4+ni9nyUKdGnPdewM/FZleakN8xHKvPw4sEwhcYUtLxnOkN0Vhdu6qDRSL08E 5cl4IJdpe+j2Y4v2v7LW8NTRgJhkDkp7JIIpWV9kfMf86+158TxdI2Ve/LZ/tS4K8Dlt 60miFTkW3LlxNWXO02qWDtx5uMuu6cxYGk1/Hqk2B+NuTUJpbpFVI1+MRc3IvXStMTyz sHNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cuPTOIf3; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij27-20020a170902ab5b00b00186897fb90dsi184016plb.233.2022.12.08.17.13.00; Thu, 08 Dec 2022 17:13:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cuPTOIf3; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229478AbiLIBDY (ORCPT + 99 others); Thu, 8 Dec 2022 20:03:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbiLIBDV (ORCPT ); Thu, 8 Dec 2022 20:03:21 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBB3694192 for ; Thu, 8 Dec 2022 17:03:20 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id q1so2513754pgl.11 for ; Thu, 08 Dec 2022 17:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uIG1fSR1LOk0TcUreHrxo/p2PRAMeYSvgKLfpsnCyGw=; b=cuPTOIf3lqLXGwy0TSP7hKgJ4s+exdm/BzVrX/Z7s89t4YfWCUuypg/W1SWGAXZenu gvLtuLc9chBdj1vwkfHwPH1jYRsptvzcolLQzLv8ljdjwsB2ALIdkshr5cbQ/3DMFNMn IR0FOSh3pOkS1BCdoHEaosfTxAXMUVSzqRoy8a2rKEFEqtJklHgvBgF5UjSx+fNZjXRU jiWq1oOpfFzmhu9RK6rJ/MnwXqCXJb2ES+LfU1eGz5lvcLCpa91a7RLAGWZ76Is/DMAq RZio6JlIn/DzPRb8+MW+cktrZX5RelulFs/+R1Lh6iCQ04FzG4vjTRoYNvDqbYoS+jsh HBvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uIG1fSR1LOk0TcUreHrxo/p2PRAMeYSvgKLfpsnCyGw=; b=yKp2hqgb2UXqaO8YDH/4Zm1NtfpRO35p4y6j+eNdTP6Qyu53gsxE0ZAGF6RyGIJGM4 5aSqVHaQmBYeYf23kovXzQLGKHc5u2WsoJODJiKvddum3L1yjniYUPTCdSjx6CfcJTh0 Kf2KTbZO+FYCdgEsonpBGGooX/SVOY1h8U2CTW/DQOERewcpL/reyqZF100beS7lOiNw B0eBa8+13uAnljo09t9Fbyf0a/3Ok1w6kdeyppPulPj7M7qtJ80uXTrepPbOSwOJ2wyq gQXVB5n4cZnQ3jSj/9KD74qnxCO1qRzp2Xm8WI8EUfYPstbTogiA/TSrMCzj4lbbEBOO 9DXQ== X-Gm-Message-State: ANoB5plPdDqNRSxQ0EPlTmDVBOTpsHmOChxf+6Z7f/QJuXgJpLcZ/Tgr R3N3s3KU4ovzfXIOhHDTgoB1j0pE+gwTtw== X-Received: by 2002:aa7:8b4d:0:b0:56c:962:fe7e with SMTP id i13-20020aa78b4d000000b0056c0962fe7emr3763292pfd.32.1670547799784; Thu, 08 Dec 2022 17:03:19 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id z21-20020aa79495000000b005746c3b2445sm100253pfk.151.2022.12.08.17.03.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 17:03:19 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/5] shared/gatt-db: Allow passing NULL to gatt_db_attribute_write Date: Thu, 8 Dec 2022 17:03:13 -0800 Message-Id: <20221209010314.707606-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221209010314.707606-1-luiz.dentz@gmail.com> References: <20221209010314.707606-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes gatt_db_attribute_write to accept NULL as a func when storing directly on the db itself. --- src/shared/gatt-db.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index ba47c75ff70c..9a92090ec493 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -2095,7 +2095,7 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset, { uint8_t err = 0; - if (!attrib || !func) + if (!attrib || (!func && attrib->write_func)) return false; if (attrib->write_func) { @@ -2158,7 +2158,8 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset, memcpy(&attrib->value[offset], value, len); done: - func(attrib, err, user_data); + if (func) + func(attrib, err, user_data); return true; } -- 2.37.3