From patchwork Mon Dec 15 08:46:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 421037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B9496140082 for ; Mon, 15 Dec 2014 20:27:57 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 6DD1F28C226; Mon, 15 Dec 2014 10:24:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 9AEFA28B9AA for ; Mon, 15 Dec 2014 10:23:25 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Mon, 15 Dec 2014 10:23:20 +0100 (CET) Received: by mail-pa0-f45.google.com with SMTP id lf10so10910974pab.32 for ; Mon, 15 Dec 2014 01:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6lF/NeDFo9yzJbtWW2IafD+DFjkZM0sHLPhzRJu73zQ=; b=ZZJUt2eepXADWNqUZliUo647Ee+35GAYEj5tMbZ22nuskOW5mp2l1ZTwAECZRWC1Ov XC/EBIR9oRt9I4+mc61T/rmH6SnkBgyO5uq0vVEcXEhhGajaY5QQ4V3Ce/5eVrweLI9l kUHL2mfGPwx5fHBs1KQxs1+TSCDOIi0CrF84WyqVUxDj8Uo78TuNZjLc0H/lAHVycTtF qxI+CTpqliZjFJxihXl2sWqUZAtAtCQik7OZt1rMz9onc/naL68QKrBDa/OCoZcdfX13 PlRJqVb7BbTNf1Ajff1lYcJXgpEJBW2WsF6UeZ9OcvQejysmNyndXSkuT0rICzDYIsk7 2DhQ== X-Received: by 10.66.217.228 with SMTP id pb4mr49368021pac.116.1418635507456; Mon, 15 Dec 2014 01:25:07 -0800 (PST) Received: from debian.lan ([103.29.140.56]) by mx.google.com with ESMTPSA id rh11sm8631536pdb.66.2014.12.15.01.25.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Dec 2014 01:25:05 -0800 (PST) From: Yousong Zhou To: nbd@openwrt.org Date: Mon, 15 Dec 2014 16:46:49 +0800 Message-Id: <1418633213-50491-9-git-send-email-yszhou4tech@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1418633213-50491-1-git-send-email-yszhou4tech@gmail.com> References: <1418633213-50491-1-git-send-email-yszhou4tech@gmail.com> Cc: openwrt-devel@lists.openwrt.org Subject: [OpenWrt-Devel] [PATCH 08/12] delta: add a simple duplication check when adding delta path. X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Yousong Zhou --- delta.c | 2 ++ uci.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/delta.c b/delta.c index 082633b..b56df5b 100644 --- a/delta.c +++ b/delta.c @@ -87,6 +87,8 @@ int uci_add_delta_path(struct uci_context *ctx, const char *dir) UCI_HANDLE_ERR(ctx); UCI_ASSERT(ctx, dir != NULL); + if (!strcmp(dir, ctx->savedir)) + return -1; e = uci_alloc_generic(ctx, UCI_TYPE_PATH, dir, sizeof(struct uci_element)); uci_list_add(&ctx->delta_path, &e->list); diff --git a/uci.h b/uci.h index 36c8890..eb7470c 100644 --- a/uci.h +++ b/uci.h @@ -262,6 +262,8 @@ extern int uci_set_confdir(struct uci_context *ctx, const char *dir); * * This function allows you to add directories, which contain 'overlays' * for the active config, that will never be committed. + * Caller of this API should ensure that no duplicate entries (including the + * default search path, e.g. `UCI_SAVEDIR') should be added. */ extern int uci_add_delta_path(struct uci_context *ctx, const char *dir);