Message ID | 20200804202120.31374-1-liu.ming50@gmail.com |
---|---|
State | Accepted |
Headers | show
Return-Path: <swupdate+bncBCW3FSPL7UCRBKUFU74QKGQEXIFMUYA@googlegroups.com> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::339; helo=mail-wm1-x339.google.com; envelope-from=swupdate+bncbcw3fspl7ucrbkufu74qkgqexifmuya@googlegroups.com; receiver=<UNKNOWN>) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=ptFeu1Cn; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=gotSVINV; dkim-atps=neutral Received: from mail-wm1-x339.google.com (mail-wm1-x339.google.com [IPv6:2a00:1450:4864:20::339]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BLmL76mDFz9sRN for <incoming@patchwork.ozlabs.org>; Wed, 5 Aug 2020 06:18:54 +1000 (AEST) Received: by mail-wm1-x339.google.com with SMTP id u144sf1703853wmu.3 for <incoming@patchwork.ozlabs.org>; Tue, 04 Aug 2020 13:18:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1596572331; cv=pass; d=google.com; s=arc-20160816; b=Q2dtfmM4r+0y4IIcQDZ3V2X6zzkzYz4ZejuEKeQg9L6hToSyP0O2G++87jINXIKZbL 53Gy27imVTGcZkT7cDDzuk5NU2E5oycscY0dTh0pqpho+Jjb7LkIhnR2JLMJ4uAnQCXs T4axTfLGOddK/jW5xh4xrWH8ye6LW3Y5RHD6aN8L3qVR0mrIUu6h8ubpVhO1c+MfcJ7g danEux3YzRNqLNBJ/uXc994o4qkY6S2rsqfrIP++tK+/zavOUv+HRGMaSvf59iHk7Qdw 6pYlZPuTbqmQhnXGi0RDsqsIplAV42KgKorrWsDjtV449z5O/33a9q8TkvbJQkeRG6BE tfxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature:dkim-signature; bh=nJULGoDLln3UpgBdwaB3perVtKeDlBkZ5BCrh77ycQE=; b=0+c5XVhWYmMDK9a+hcJ9nExKfBLHjQob8bhKulkH/xTW4Hz55oOPFajofljaLQbQp+ juRpj/Z0Tuf00x4h4ZQfJ2OX2w+16AAo1uqTpW53dQ3y5HWTnTafs1db/iHC/MUFXiBq LsWPnUl00sm9Au4bv1Pj4pgDvX8A9BcMkhszTcfMwlC7w8qzRWjJhAas13ZYJWL4WFwq 6R1TuU3Mf+Gm5Z93v6K4ppQMZ/W36sdCx3GjoeUPUGjBp3PGfrY8qzw99c22owfh7MNA Vw+ZH0IImPJ9MJJCyPNyFHyJBQnT2X8109ZMDRVjeAFx2rNl8aq7KjLRtgmPvfnOoC2K d6AQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FK1LPOhe; spf=pass (google.com: domain of liu.ming50@gmail.com designates 2a00:1450:4864:20::643 as permitted sender) smtp.mailfrom=liu.ming50@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=nJULGoDLln3UpgBdwaB3perVtKeDlBkZ5BCrh77ycQE=; b=ptFeu1Cn9/cnlXUYMullpnjHmbU6eRm8/5FBG+QCKBaDFA2P/MjWo0ZK1f6wTvaBZW n603EXhwD8HaT4mQhfXEudWu9kQfl+6MCBF4aJdY91dmb8BkoYMlq7JTS5nkWgIxI3D2 GF2qYgVzW73SvqDKNkqPl05gmfr4N81OZ84pAqvGgr1TPkwwCIwb0/iPuL0QMSC0HfO3 Z58C6g/VCofTSGXFcfHiPFMDXscgAP365yEGodzAhNikG8ATZxlWiT6bpDjd9UEowLMx VmIjo5zmFYrscF6BU9jEHywgLHzhJJ6mn4iBJxAP/v4EsZrF2t44wvr+U5O3gy9xErAl q6RA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=nJULGoDLln3UpgBdwaB3perVtKeDlBkZ5BCrh77ycQE=; b=gotSVINVJ9+fx5Z4mrC6zJ3Df4Up9mbaEE3WWNDiqsVgsU94+P2YLJ3QIy7S7MJgUm HvXqZymapBFAN3CLU4ZcLbjSqC1Tjxv1sEn2urwyOErlaSRqYabWyN3oHDnuPXJOP7TA Dx8uUtN9VK9/zESqO5UygCga+6B+bm6qQn0908dZ77LJ1VcYtOGZGlQoqFLKPc3WPtV0 sP/xn719N3jxWpaQP6Q1p1dUq5tai6gWxcdxdAdRidWgid+kBzFGovMD2Wsk9z75xYI2 bZnc8LHwBr9X0vyu/x6A48ohNSUnRXSxygOTz7qrsCYq9LFJw5wGU1AgGHcHAio9Y7JZ pAiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=nJULGoDLln3UpgBdwaB3perVtKeDlBkZ5BCrh77ycQE=; b=o3B+MS/jQ2rkaQ12SaI8H8UaSrreToLApBfcLY3hdzpK8UtjFw85XhTkfXSJ+J0fcF qpGkdB5cI6yXbFCggrDYoK4qD8pP7sP76JTCGurj+S33gelbIgFi05nI8nu/tc7FdHXo Ow3UiaodIiriWJgEGnyFY+sXejS2wjIzmJupadtCD4QmJQ1R0IqoAWLmat59lCuHUEra DZQVbnxgTPQ+rX7LXMs0HWh/4a1wa6fSIooi5VKKdXGIGMh8kvjP4GHFi7lSmvSeH/By EU1ENUsNpAsKBUhb0bIGTtlX7XmCY+bM+EXobPh2bnBKhNIO/qiAlGr10pIjpsYOwC7D 7o1A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530RH7FrDUnYYnFML/XE30l1ljJgoZIYU0mxqwQk/Gu/xiMsKavC HvPnHCLDqT83IMHTVQPhy4U= X-Google-Smtp-Source: ABdhPJwoBz4f0j5QKhHaB/yrsg70r8BmzBI4YXP38d7Q8ZCz+GdAWOfOUIprfD1e4eicbZl2IwIo8Q== X-Received: by 2002:a1c:984d:: with SMTP id a74mr152685wme.140.1596572330884; Tue, 04 Aug 2020 13:18:50 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:22cf:: with SMTP id 15ls2069730wmg.1.canary-gmail; Tue, 04 Aug 2020 13:18:50 -0700 (PDT) X-Received: by 2002:a1c:5459:: with SMTP id p25mr128940wmi.85.1596572330191; Tue, 04 Aug 2020 13:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596572330; cv=none; d=google.com; s=arc-20160816; b=qkWH8nGh2+Y5zSa1ZMxukvz2hJui5JSJIqRtidVMhvi41+T5UyHwP6YASLBfKl2Rk7 m0tlDRbB/8bfOG6/VcokKMJCZAKdXPSJtE0ui7WbnEn/wqHtaPBaMWJB8PSG8Gg/bDHS UBuudDfnkPNqimDku++FFG6ovDexYlP3RpJ81HOkKLD5TxOrBIp5hqUJ5p3wvNG94F+M 7j9scPuGf1KrqMJ1IuQCTe2bv5Ew/zFxUR273yRKUr/owoP6yzzf7I8zwRu7Rtv9/tG3 dnMQO4bRDTczpoMoo13O5FxUIJiMUo7WU8yT80WzVDPi+SePVsNfDXN/fmXSVcrqwnec bpZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=XL6WW3vthYMEn+vac8KCxeN2ykGvwocfojVD8zqGsrc=; b=B38eDC3JmuNxVESyN9AM3h3orACuJwhRUjwA16MJIUyYHkHYikHJfokMNoDqUFxi+W w5L33r3N/IexayG2HyQqdugGtmIZi+0Jz3OrD5D7BxjuSKMkMrc3X7sMKAVQLiRP+CIE eVxpSgrl4GdeQoWXccuhPu7Qn7WUsus6ZBJWsZIxDaLmxMb2HISNznhQ6gf+3dnFyJ6c Z4M8iT07yc354DzwB9n28vquoUZQumZoKB8EXXafBvpECX1OQNL70zoz3GbeHXD9k6zB T2rIq0E5vT4Wt7e6BT9BzvACQ+SClhf0OTHqk46jOxaXnkOiXskR1YCPqCCzPnL0UtiC hTfw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FK1LPOhe; spf=pass (google.com: domain of liu.ming50@gmail.com designates 2a00:1450:4864:20::643 as permitted sender) smtp.mailfrom=liu.ming50@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com. [2a00:1450:4864:20::643]) by gmr-mx.google.com with ESMTPS id w6si2402wmk.2.2020.08.04.13.18.50 for <swupdate@googlegroups.com> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Aug 2020 13:18:50 -0700 (PDT) Received-SPF: pass (google.com: domain of liu.ming50@gmail.com designates 2a00:1450:4864:20::643 as permitted sender) client-ip=2a00:1450:4864:20::643; Received: by mail-ej1-x643.google.com with SMTP id kq25so30919277ejb.3 for <swupdate@googlegroups.com>; Tue, 04 Aug 2020 13:18:50 -0700 (PDT) X-Received: by 2002:a17:906:bce9:: with SMTP id op9mr23744752ejb.462.1596572329770; Tue, 04 Aug 2020 13:18:49 -0700 (PDT) Received: from peterliu-Precision-7530.toradex.int (c-3ffb72d5.022-417-73746f13.bbcust.telenor.se. [213.114.251.63]) by smtp.gmail.com with ESMTPSA id ov10sm11381ejb.6.2020.08.04.13.18.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2020 13:18:49 -0700 (PDT) From: liu.ming50@gmail.com To: swupdate@googlegroups.com Cc: Ming Liu <liu.ming50@gmail.com> Subject: [swupdate] [libubootenv] [PATCH V6] Dont store to device if no value changes Date: Tue, 4 Aug 2020 22:21:20 +0200 Message-Id: <20200804202120.31374-1-liu.ming50@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Original-Sender: Liu.ming50@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FK1LPOhe; spf=pass (google.com: domain of liu.ming50@gmail.com designates 2a00:1450:4864:20::643 as permitted sender) smtp.mailfrom=liu.ming50@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: <swupdate.googlegroups.com> X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: <https://groups.google.com/group/swupdate/post>, <mailto:swupdate@googlegroups.com> List-Help: <https://groups.google.com/support/>, <mailto:swupdate+help@googlegroups.com> List-Archive: <https://groups.google.com/group/swupdate List-Subscribe: <https://groups.google.com/group/swupdate/subscribe>, <mailto:swupdate+subscribe@googlegroups.com> List-Unsubscribe: <mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>, <https://groups.google.com/group/swupdate/subscribe> |
Series |
[libubootenv,V6] Dont store to device if no value changes
|
expand
|
diff --git a/src/fw_printenv.c b/src/fw_printenv.c index 18887f9..8b830d5 100644 --- a/src/fw_printenv.c +++ b/src/fw_printenv.c @@ -151,19 +151,32 @@ int main (int argc, char **argv) { } } } else { /* setenv branch */ - if (scriptfile) + bool need_store = false; + if (scriptfile) { libuboot_load_file(ctx, scriptfile); - else { + need_store = true; + } else { for (i = 0; i < argc; i += 2) { - if (i + 1 == argc) - libuboot_set_env(ctx, argv[i], NULL); - else - libuboot_set_env(ctx, argv[i], argv[i+1]); + value = libuboot_get_env(ctx, argv[i]); + if (i + 1 == argc) { + if (value != NULL) { + libuboot_set_env(ctx, argv[i], NULL); + need_store = true; + } + } else { + if (value == NULL || strcmp(value, argv[i+1]) != 0) { + libuboot_set_env(ctx, argv[i], argv[i+1]); + need_store = true; + } + } } } - ret = libuboot_env_store(ctx); - if (ret) - fprintf(stderr, "Error storing the env\n"); + + if (need_store) { + ret = libuboot_env_store(ctx); + if (ret) + fprintf(stderr, "Error storing the env\n"); + } } libuboot_close(ctx);