From patchwork Fri Sep 29 14:59:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 819998 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=googlegroups.com (client-ip=2a00:1450:400c:c09::23b; helo=mail-wm0-x23b.google.com; envelope-from=swupdate+bncbdd6bwv65qpbb2waxhhakgqehp5c3qa@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="j/5MAbfZ"; dkim-atps=neutral Received: from mail-wm0-x23b.google.com (mail-wm0-x23b.google.com [IPv6:2a00:1450:400c:c09::23b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y3ZXY6LvXz9t4k for ; Sat, 30 Sep 2017 01:02:05 +1000 (AEST) Received: by mail-wm0-x23b.google.com with SMTP id q18sf1652wmg.18 for ; Fri, 29 Sep 2017 08:02:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1506697322; cv=pass; d=google.com; s=arc-20160816; b=uPHWg3CEY0OI7qTyK+qfGNd29Zj87plG3cXq/2zuoyOu9Wh3POqhPyO1cNMOnMQ6Up SQlLIYmqC6DsI/fkieaNYJ50Ecj2pIAZ1hpalUwLbPOgF93zryZTTqR9bzA14xwGCez/ PE8TrNDee34jNlkmsXW/eK2S2UVaV4Mso5VltpqELAj6XbKMNpc7d54HOszI+HkPWhRm rImITWs2GjgBOwnvf+pYnS4KzqY1ZwpJ3k03m68OXoTShD71FR+2dzV+LW2SRekkTvdi gfKeJK4QyPSoxey1e9gFnN7QDRpbAduWESVbFYWJtY+TrHtpuJh5CYHlXXIOX97sfKfx PEow== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=dqbyjYywWVd1B5fuVOhFzl8gRC/wrKvX/itOEEbxQho=; b=VT1pXs1XvL/5F5zs3K5fGIZYtGQGoSredRqAI86YS+qWrUs1YbnvZ8RjLEks8Ha1R9 G85yLC8UQKGPNVNdRMowpZKSrCPo8UXK9QsA33IEDD88hM0mc9UkPRFZWzVQRwnWZ7HW yGsxRd5U6sNMVoMjt3Vu1EszeUuORCHphjpAlRttu41GzcZjRWyt4IfsBOjzWuldZWNf kD7rtemurKGMpRPX4N/4GCV/vqAXaUMl3ZLWV3qPOMmg7lLqzhhRnyMmbNQq38MBJcs+ GGJnMlB69ZeBr7GJ2UxUCbFPbEQe/XCmcmtsDmSZdY5obTYgZCG9D3UUHHUqO7gVLFmK kmeQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.28 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=dqbyjYywWVd1B5fuVOhFzl8gRC/wrKvX/itOEEbxQho=; b=j/5MAbfZHVOXMnGTaU7Md8KUi1nSRpBU7ABScGC2IML1EZNttUp52Fu/2nASbTqRxP pNWmuHGkCeq40wEkIcmkQ63Sa/Vc4+pbO+zrYhX02EHIvfqTAL9GmjziiPTRIoaN69kr 4vjYV2J07WUyCKIULabnJzh70IKfDKkyUmxBAiPT3CwdMNBRqpMmUVCP8QzSwmqgFIs8 eR5782yWbxXjNeo0pweGWQ7w8xcF9m2DW3H771z85XfSFlql3SqJl0qO2WdIxYjXfY5S OKd0sLdbmZnQ98deTiI7BuM4UCJa/FVlMtpzyS5kAUVN9/E86geoR7nTiLOYNVeyewv6 VcOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references: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=dqbyjYywWVd1B5fuVOhFzl8gRC/wrKvX/itOEEbxQho=; b=gu0EIgVB5m7Hq9WJ+pspHVSz5oSsghmW38YS3BiRoVed4cSTGO4gikKb7ij9A2/lf1 TUCCIvPo1RcwoX0pVw/u0618YFxEAh50Os4R7nSNe+oqrHlySyiKDuSXQJLiOcrgU9e8 aItax2J+rcPhP63EgzSiJY2gI6u6WBfGTfl3YbWfoA6ENkDmb5eq1VPOJaR7wAFGPrjl Rxc1JSK4cLVUkTQQJZY1+sOz3XORF5IJMGptvaHG+2zQnT6cs62MScqvy/aYJywTvcAz Von95oyyrAMFV56y2pw4es2UkvyeSOz7wn7UJMM7VZ4IXSBor3Q2VpCqBI+TvBR5dfWp Dmew== Sender: swupdate@googlegroups.com X-Gm-Message-State: AMCzsaWHzwhOvYrQcWY6Garzz0lobAGhX/PNU3OVMRGDUrTzXJ2DPn+m e4LGAtkfoNTbGDaJBHlmNc8= X-Google-Smtp-Source: AOwi7QAVr+wdl+gfoYVu3iSLRkgwk5KELJMM3/ZqxaaxsXJY8wEPik4DDhWxxu1P1HC3CN4frZPuTw== X-Received: by 10.28.63.19 with SMTP id m19mr20435wma.28.1506697322493; Fri, 29 Sep 2017 08:02:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.93.144 with SMTP id r138ls785446wmb.12.canary-gmail; Fri, 29 Sep 2017 08:02:02 -0700 (PDT) X-Received: by 10.28.101.133 with SMTP id z127mr666988wmb.32.1506697322120; Fri, 29 Sep 2017 08:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506697322; cv=none; d=google.com; s=arc-20160816; b=fibG0glJLaBtf57yvYH9uRvZnZQ14ShwpZJOa0csE7ojZ4f6ij1fiDO2cL565a3gJZ dOkAxsfXRentpAVih0grP+wETsZrSXo5p/hiuEuqKoOkvkWS/y7cK6/imyfnsw330znH F5x57oO6nUIjok9CxDB7r0h9EkWL4Qa66kTmSTc4pOAGqwN+lOE4tD3O9QmIOn01x9aZ jXPXchEV2vkjNv/kTJTY5Q6PMbGnXwUPo2V3VD0nXTlwCSJ+z/jhOO90oLiRZEyDCeJp LSvDSE8+O+g//JpPqhwBxYc6QZZmFEiNp494lKIbCEPHkVV2uM75iS6fZf0uEq5uIGqF Pfzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8uXP7SP+ZSlLX5+9CAQxSDTO4ZkLgkTG5xB871GZJn8=; b=AFkKotVmMXK5qGeLn9dFv4ONGkdmlh2NlBr4SfEVV7YgjcQnx4X9Nc+jeddpEd+jKO 7kxM0bSi+bznUKo2u5y8He+4okvmNqBKs+ijfHCyRubVTmzmJJpLAXuTp4sMi63a67aG MGdo+brwN0psNunaDs24uemWYQcutE/Ly8A9hPvGP+Tde2j0RIJcFBkKZVuAxtohzpJp l16XKpXjEuoZkQedykW4lIdgCdDJ3UkCUnlR8zcHte68GmZY2S/yO63YZIeJKJJmDZ0E crMq0a1xVM4d+es/Kjm8foTfWhiCMpxMnWgC/lriPPRdeoEWb9x8UrqMFPe8Wk1ke8Bp Pu1A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.28 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id p70si527024wma.1.2017.09.29.08.02.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 08:02:02 -0700 (PDT) Received-SPF: neutral (google.com: 192.35.17.28 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) client-ip=192.35.17.28; Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id v8TF21OI019058 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 29 Sep 2017 17:02:01 +0200 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.251]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id v8TF21DM014683; Fri, 29 Sep 2017 17:02:01 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH v3] Lua: make handler not found message more pleasant Date: Fri, 29 Sep 2017 16:59:03 +0200 Message-Id: <20170929145903.23007-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20170929145247.16944-1-christian.storm@siemens.com> References: <20170929145247.16944-1-christian.storm@siemens.com> X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.35.17.28 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Currently, a stack dump is printed on a failed require("swupdate_handlers") which is thereafter clarified as being no error. Make this message more friendly. Only package.path is shown as it's assumed that custom Lua handlers won't be written as a .so. In this case, they may be written as a regular handler in C in the first place. Signed-off-by: Christian Storm --- core/swupdate.c | 3 +-- corelib/lua_interface.c | 20 +++++++++++--------- include/lua_util.h | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/swupdate.c b/core/swupdate.c index b490871..f1140d2 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -850,8 +850,7 @@ int main(int argc, char **argv) } } - if (lua_handlers_init()) - printf("\nCustom handlers not found, no error, skipping...\n\n"); + lua_handlers_init(); if(!get_hw_revision(&swcfg.hw)) printf("Running on %s Revision %s\n", swcfg.hw.boardname, swcfg.hw.revision); diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 5f48726..0553c1d 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -472,22 +472,24 @@ int lua_handlers_init(void) { int ret = -1; - gL = NULL; gL = luaL_newstate(); if (gL) { - printf("Searching for custom Lua handlers :"); /* load standard libraries */ luaL_openlibs(gL); luaL_requiref( gL, "swupdate", luaopen_swupdate, 1 ); /* try to load lua handlers for the swupdate system */ - ret = luaL_dostring(gL,"require (\"swupdate_handlers\")"); - if(ret != 0) - { - TRACE("No lua handler found:\n%s", lua_tostring(gL, -1)); - } else - printf(" OK\n"); + if ((ret = luaL_dostring(gL, "require (\"swupdate_handlers\")")) != 0) { + INFO("No Lua handler(s) found."); + if (luaL_dostring(gL, "return package.path:gsub(';','\\n'):gsub('?','swupdate_handlers')") == 0) { + lua_pop(gL, 1); + TRACE("Lua handler search path:\n%s", lua_tostring(gL, -1)); + lua_pop(gL, 1); + } + } else { + INFO("Lua handler(s) found."); + } } else { - printf ("Unable to register Lua context for callbacks\n"); + WARN("Unable to register Lua context for callbacks\n"); } return ret; diff --git a/include/lua_util.h b/include/lua_util.h index d7e8754..7842cc5 100644 --- a/include/lua_util.h +++ b/include/lua_util.h @@ -44,7 +44,7 @@ static inline lua_State *lua_parser_init(const char __attribute__ ((__unused__)) static inline int lua_parser_fn(lua_State __attribute__ ((__unused__)) *L, const char __attribute__ ((__unused__)) *fcn, struct img_type __attribute__ ((__unused__)) *img) { return -1; } -#define lua_handlers_init(void) (0) +static inline int lua_handlers_init(void) { return 0; } #endif