From patchwork Wed Oct 3 13:36:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 978330 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YdomAtH8"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DuNeTK0b"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42QHCM1G0bz9s1x for ; Wed, 3 Oct 2018 23:38:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id: Date:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=pzYlqxu03d7PiOtvoQE9ZIUf9/rQ5d+79uJbO0Qd6vo=; b=YdomAtH8wjsqtS aCVloSm5SgRnaE88G5tSYYxlt+c0VZ5cgPrwwFd1qFAygg7GSnCbNs6SP+rBDMyqOkJezGlKtcVrH fty3BBUKzbT0LUgC92KIrPSQ6t50CtInYgsxYIhSV60HrCEBEHXl+6upf/RGltWN7nyYRZOUcfdqU 2CUCmX8iSMT16iX2JLr3Cm3LfnN3Lh3Ua45DmDKbLqwvXi4ZW1lYYlUNcga0sXg9JuOZcbrveMp8R fZdg8I0y/39NIRglLFP3CwRKlvPBU6EUSQ661lAG7yK/Fp4xG7U2kPO6YHyD0yhRdgeDu6rOkulFl CHeg0o+zYJUQX+z0yQ7A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7hLg-0005m5-1L; Wed, 03 Oct 2018 13:37:56 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7hKN-00059X-Ip for openwrt-devel@lists.openwrt.org; Wed, 03 Oct 2018 13:37:40 +0000 Received: by mail-wm1-x329.google.com with SMTP id 143-v6so5738349wmf.1 for ; Wed, 03 Oct 2018 06:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Q5c3SBCE0pBtFW6XQi4ms8k/vRUdcaUO3ANeV4FA5w0=; b=DuNeTK0bughzpxme+ntYhnyYR9Z39D2KGYugeI2Ef5Zq1X9Vl6/ZbAYO0RLyfm+zjg HxQSQ9kyaKy+5rwSZFxyCR1EUS3s7jilUxIyAW1Oy1iGF5Kx0w8TZdyoPxtsFaiq9JPl qX8BpkCDkChmH6G2pYfvMvTCX+XpNX6NBrsMVTW+6tcMyc5RPf6KkYc/LxwfDE2t3/Uf K/MfnOnG+643RMEbH5p+hD6sbsUKsTugcIgr4OpOVB9HnfIHIanRJLPyRFRzEORencaT zCK2W7LJSunO0bFwKgM/7VGSoPafxhrPBqBk18p78N4SQhasLAytikXeikLE/yaFD1z3 aanQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Q5c3SBCE0pBtFW6XQi4ms8k/vRUdcaUO3ANeV4FA5w0=; b=Q28spL1YlQ/l3W3jNKuWM2LF/pSoYMabaWciMrPZxO6gAwSq9+EFhAC0ooRe4WOueO 90IE9t4QaP9wYDGSVC6jRwMfRUeDb1S4CJztgvp0Z3xIeUEckyUJdIhYlpkGW4ICnFA3 km1rE3CPr6qAPzsfFZ2vbzAOf29yUnY0KUcfHXVH4LnPNh+syGb2xmzNkBZ//Op7djtV RthQL48SiYQkGfRdKHa2IJiJYRAR9GK3OBnQbw3GtDQhDhD5lDSNfwhhRVimr0qlCdw4 BACGxljc7gPd+j2G/RDe2P6u3LthCprEcxwNTrBDk7ySn35lOnI7UKjkuuDz2wO7hZuv ulCg== X-Gm-Message-State: ABuFfoiMe8vj8KtWBJaoPf8A1k4iPNQ33SaP1sFV8CDX5VcUigLFrBbp /pvLcLGe3/OFoULazV8Izleqk47p X-Google-Smtp-Source: ACcGV61IjY8oql0Bf29DaHQ28q1bRHQCby48z6HwhQsmuLofDCQpmuClfwySRo77xndJJTu7ExlrcA== X-Received: by 2002:a1c:be09:: with SMTP id o9-v6mr1545949wmf.109.1538573782365; Wed, 03 Oct 2018 06:36:22 -0700 (PDT) Received: from cplx43.eu.thmulti.com (14.125.146.82.ipv4.evonet.be. [82.146.125.14]) by smtp.gmail.com with ESMTPSA id a6-v6sm1815633wmf.22.2018.10.03.06.36.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Oct 2018 06:36:21 -0700 (PDT) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org Date: Wed, 3 Oct 2018 15:36:15 +0200 Message-Id: <20181003133618.8371-1-dedeckeh@gmail.com> X-Mailer: git-send-email 2.18.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_063635_665771_AF3C89C8 X-CRM114-Status: UNSURE ( 9.94 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:329 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dedeckeh[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [OpenWrt-Devel] [PATCH 1/4][ubus] ubusd_event: move strmatch_len to ubus_common.h X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Dedecker , john@phrozen.org, nbd@nbd.name MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Rename strmatch_len into ubus_strmatch_len and move it to ubus_common.h Signed-off-by: Hans Dedecker --- ubus_common.h | 9 +++++++++ ubusd_event.c | 11 +---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ubus_common.h b/ubus_common.h index 4bb9927..5e4d0ad 100644 --- a/ubus_common.h +++ b/ubus_common.h @@ -21,4 +21,13 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif +static inline bool ubus_strmatch_len(const char *s1, const char *s2, int *len) +{ + for (*len = 0; s1[*len] == s2[*len]; (*len)++) + if (!s1[*len]) + return true; + + return false; +} + #endif diff --git a/ubusd_event.c b/ubusd_event.c index 0469c20..f07f826 100644 --- a/ubusd_event.c +++ b/ubusd_event.c @@ -132,15 +132,6 @@ static void ubusd_send_event_msg(struct ubus_msg_buf **ub, struct ubus_client *c ubus_msg_send(obj->client, *ub); } -static bool strmatch_len(const char *s1, const char *s2, int *len) -{ - for (*len = 0; s1[*len] == s2[*len]; (*len)++) - if (!s1[*len]) - return true; - - return false; -} - int ubusd_send_event(struct ubus_client *cl, const char *id, event_fill_cb fill_cb, void *cb_priv) { @@ -160,7 +151,7 @@ int ubusd_send_event(struct ubus_client *cl, const char *id, int cur_match_len; bool full_match; - full_match = strmatch_len(id, key, &cur_match_len); + full_match = ubus_strmatch_len(id, key, &cur_match_len); if (cur_match_len < match_len) break;