From patchwork Fri Sep 29 14:52:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 819997 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:c0c::23e; helo=mail-wr0-x23e.google.com; envelope-from=swupdate+bncbdd6bwv65qpbb4v5xhhakgqequxh7qy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="C6yWOm8U"; dkim-atps=neutral Received: from mail-wr0-x23e.google.com (mail-wr0-x23e.google.com [IPv6:2a00:1450:400c:c0c::23e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y3ZPK1ftpz9t4R for ; Sat, 30 Sep 2017 00:55:48 +1000 (AEST) Received: by mail-wr0-x23e.google.com with SMTP id q42sf758052wrb.3 for ; Fri, 29 Sep 2017 07:55:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1506696946; cv=pass; d=google.com; s=arc-20160816; b=nGcWPYg5pt7ix5TmHA2NANhvdmxAZIMAklpewC9VOJqmkG/Sg1NuO5iZGbupmMtIil 3rDJKu8EMIMGyxpw+E/lyXFw6TX3mstA5K8g1V8JODLlAiPODvMeHifwa+AAUM/A+nIP K1E2GOqUhD7AZGMowuu0d/gWZv2caBlTyD1lLEE5yC7Wyr3JC7mD7EwB6GZ+wHGd6qRV XKBH81YyM28n28YxQqicYJfXRrjx68L/np9h7butwpqYdIYJb0OLkfOuYO5gU9rx8nHq yxocqRj3vm4vV64RIrUuFyDKwMIzCehtvv3mKLJ9Ew0Rntj23d7AXpnxz1OmTR8i81Ai zHHQ== 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=ogrtk218kWFTCP/0h5rSCHnDaKc4JQzirA3FdHzZbEk=; b=sgurbb0iJ5UThY/9PaLuj3+H+wdeEcx4d8jPpwxCoXImQm9PD/EGzPDduU1sN8uBfj F9DFOu4QOTFVMvbpOPUKzhaes9KSCz6f+AHrtkKay8l2+PSTfUO3Wf4/m9IDDGOiaeE+ KTsFGF9lO3PMa7qDwKtNwiVHeF7EiLme25QgAcqs7vTwnXgzRT1fe3C4f04TKC/EicGu s4IpZsACRpxhO/d2LgE7mHXVsWxRKuVq3cPCgflnKiGjYp6n+sh99w/rWDugmZnCb5hq DaPmxYsp7cYN1yjSaVqx3cXGlKffqROlha8PyPYUyG6IJjzZO5MZ8JW7gBHrLHLNahaG YoVQ== 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=ogrtk218kWFTCP/0h5rSCHnDaKc4JQzirA3FdHzZbEk=; b=C6yWOm8ULQDtCUQXLzgz37mgV+s1qKR8Tw+l/vE38hFQTfQ1q6U4z4zVo91BeXOsDg MecuwAA/XYl5A/6hY4kLB6GYUrY2gF9IFVh48+DOuzfGUo7dKPLezJAdNhRsDDZZkvh7 a8doDfMHUwG7mYu52hpQQwtqn4iT7Y4B1MUmdqpDYZENEkGAOy/BXN1DY0sBSz2FZGPH 6Fclu8JB8+s6JDo+WNJCBTGaRrYBis5xcDZE2HeSpAQ627rCqgMY/ZpoYm0Qehw4EcsP dOxBGEv7qI020IyG+vOzkst5N2NBuU1CJfpYfgudK5E6Q6cPAo8EhNpBowEm1Zf7dS3F MTOg== 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=ogrtk218kWFTCP/0h5rSCHnDaKc4JQzirA3FdHzZbEk=; b=Ok+X2HybJepOo5GelMZ3+k+ectCMU7BvaWNQy+7T7ipaKp9mpydscqpOCypFSNpiog zlnvQouGE8HE7CKzkA6+MdNcmkytkiKKektOXuR/c51v3i9NssFQrII/2XnGOl7TnHRL nxPYoV0/pSmJuxolMhJKtfXu7Fzw2lW2/25noTwv5JUg+Y+TbdsCH8LpI6m5A2dpIRrT 2XDcSPzsPFOGaf8EFQsHn8IU6/TY93x/jKkzL2k9CWRhD5TxoRj0K238uWVm5PQQQEYi 45/gZSDwleYwQN4KdLczkIRTFtc7CVpwwkZMj09ImwenFLW2m2Gk1Nq/0cKA0rK89SRp Qnnw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AMCzsaUEAVKt4bfBnUHshgLcjmSTei4phEJHRxTGFLUDN2ogVOR9OaP+ oUiQVMbrfhMSHaCSYEzVWjY= X-Google-Smtp-Source: AOwi7QBRJgYieTbFZaXsXnrybMkiFdt+NI058uWS8ScavsF6AMWJuHkLj8xHdSpaOd9sjysOcKDgNw== X-Received: by 10.28.128.19 with SMTP id b19mr14179wmd.7.1506696946729; Fri, 29 Sep 2017 07:55:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.223.187.19 with SMTP id r19ls1074471wrg.1.gmail; Fri, 29 Sep 2017 07:55:46 -0700 (PDT) X-Received: by 10.28.8.71 with SMTP id 68mr654189wmi.24.1506696946368; Fri, 29 Sep 2017 07:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506696946; cv=none; d=google.com; s=arc-20160816; b=i+hg4iAPf/rpUMo/vewd22rWIVBCXNvLnT6jW7O/hafuPZDgQ9Q7XlYxbb25jJYwpB NWI9P0ePNgZrTIKvsjvejp/HZlbLVLTdSwpWoj+NGtdf1uvxOx3hyaA4TGlwlvLQX3K7 a0lCPINqEWN6WNZ2hdL1cCih3Ei25PWzWmUqKL+epiQF6d/+a599ggpbU4zHJsTSmJhZ SjWZZ/2WH7GiB6ZsgS71qoKuGJzCSwS6hCTsTSbQ/G4XD4Ok8t60aO3hsak3tXwV6hHC UCAqdhOLobdOusbuYdU8iIrMe0Rpq+wv0P76eE517QUP/cWynvtRGeeOKl7h2yluvfPq eHGw== 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=yCz1c1emIbb6BDA4mg29EwYA5kHO1ZHhF2AkGkX9Qe0=; b=hOhGcWDDJZtuMv4rG0a2VmXR9Gbztn/EVnaV6DK0MOWPhnT1DFREKrJXvNXDn0bb2c 6Jg18ckn5OB8/P8Y/Sy5hxkEkoT67F8SXnQPZMLLFpFsSjCY1jbzRoMUNTfAiI7XrSks l5xQL4q8x2jnOCGXyZDqx5f4T/YXcRkJdKZB5TaPzSYjswcmGCdm4E/pOJJEQys62tAN b+CGpQYGk4z6/bDEMwgzaXYfwuH/vTjKLu4TYx/fo4oUcGyIJpzjhR2DyCU2vdJ3kMfr SG218Wk0SXWUGYz2/g28jtwE7s430DYcCuOXkH+N+wOSkfcbX+nSEoGzsJp4pYDPBS3g 2rCQ== 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 h17si612796wmd.0.2017.09.29.07.55.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 07:55:46 -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 v8TEtkZW032475 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 29 Sep 2017 16:55:46 +0200 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.251]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id v8TEtjIK014667; Fri, 29 Sep 2017 16:55:45 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH v2] Lua: make handler not found message more pleasant Date: Fri, 29 Sep 2017 16:52:47 +0200 Message-Id: <20170929145247.16944-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20170929134354.18335-1-christian.storm@siemens.com> References: <20170929134354.18335-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..0667b2b 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) +#define lua_handlers_init(void) { return 0; } #endif