From patchwork Tue Oct 10 10:22:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 823785 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::23d; helo=mail-wm0-x23d.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbyv66lhakgqej2l2bei@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="f4VEIBQZ"; dkim-atps=neutral Received: from mail-wm0-x23d.google.com (mail-wm0-x23d.google.com [IPv6:2a00:1450:400c:c09::23d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBCpt353Bz9tY3 for ; Tue, 10 Oct 2017 21:22:29 +1100 (AEDT) Received: by mail-wm0-x23d.google.com with SMTP id 196sf5317545wma.6 for ; Tue, 10 Oct 2017 03:22:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1507630946; cv=pass; d=google.com; s=arc-20160816; b=IJUYVGV3GFssr+Q4/JLbqvxQgEBLVrJ1luZDrUbAMk6ngsSuzb7X4s94KMvbeOJ4pJ 6LS1iKavQweZDT+jsG0tdESDwZx35CXa3PNiGs+H6G4w1z4MFntR5vMrScBn1nMeSBht SMWzGmrO7jGW++zMzYn8cXyazzywoA7Lw+xJpBmWirwxwnaAnARLP5lmyeii3eS76wyr iDvuyrrwuw3/Ug6eGQDo7gkHSn7iQO2ew5LSnp6fhO9LfXTDTstRx7gPVeyuOI3FXnxw 04Kv3IeaJobzXXjkTvXAqANxyN5KC+bSXWzrVA4QnaG39Nd4nSasMAdXdU4mOzFoShJm 6SdQ== 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:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=PnWzdHwk+tyhMZPHSxicN6jb6IW8iJyXS8Svb8+qCM4=; b=LMuhdPTGQaJ9XwsQehWqptIcZ5x8RoDrOrtk+NPK8Qnj1+SGIKJNr82MEh7O1W67WK p3i9Z4tIRi2mjdK27cWBJW3eZ6klIc6miVUCo1nQsEZ6rV3vUGA+OGDHGnQFmx9DmRfg Kf36f05NMIJl0ucnXdaH5a/Xo/ojr3rB8SaBq4VVAzjA4zKVskX4bERoEQPr/uRwyEUW cB4dvViAj61ifko6shv7/37RPViQvlFtjToMibflluS+xSwhz4qzavy2P+E7h/74dlZT zezWJecVNulQWlPdKaDKbqkRMBFv6EM6/vwu8gMfm7/ZOJnK8hH2JtXrMwiojiAvEVl7 uu8g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.14 is neither permitted nor denied by 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 :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=PnWzdHwk+tyhMZPHSxicN6jb6IW8iJyXS8Svb8+qCM4=; b=f4VEIBQZBXkpe33HdnMoEYCuC4rwG2iq9CCAR3fX85l5sWptU0VxKWEXWIMW7IdVoc UdYKzvOEFAyvHYoc1W62hUXsMZmKedVlG6Kf2Trp1cbaFa0N/Ov5BcR08KFQWLiqlViA WSnhquCduiT8ahbQ+hV2uoaoqUMrzGVd4p2AvCZFUPKLNZyl400PY3cf9POV9e3iZbDn 6v6ob9Bwuv1vW8N5n1MuKeGz7pTNza17JqeBBDRo1KPWTYH8fuugb5h8OAmkBWuq76ap tPNAUTtNKXMUI57wgEmgXHxcFmphx4uK+6qF/d1Zc2Bxtd3CLj1IlubqDohu+set5yhT iuyg== 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: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=PnWzdHwk+tyhMZPHSxicN6jb6IW8iJyXS8Svb8+qCM4=; b=IH9e53HhaXJhCFBVZRDA0r+FzzwMUhcKCkxQCGLbfvgGKfgCTreGKh1aQjKv1n8BQx 6Rq+Q+7tfp5xvfkFDwd1wpmayYK3aiGYsBQnz+6etrtN9UcVIKxM0G0ryKk6hxvjH6wb +CSe4ZIwTQZNsGYhsL30JEFcvvEbb5yuTBfxTLDdEqQ3VY/a6SiG5bcAIy2qApUMmHBV /wLxpE7F+QIcB+D0Q7BSoMQhNca5mNA+KbLqj/MrmgJRddsVTVcMYP2pkfcaTXAfqYQe Afs6L0QZn8AYbLBPIwJsbAPPVeY8j7l1grQ+0KM8YFqDcL/Pm1GPOn9TMgobtMqkkfH2 VnRA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AMCzsaV5Vid9Q1K9ZC/ff5Db/PGlLcOtN+oIZvEcq/suf7qjHzX+5pJX yyGQAzzxJcVLdbukGKN+Rw4= X-Google-Smtp-Source: AOwi7QA0lH/zQrO1WHBmNvKT275iTpejJ4xrBFmAo9SWjKjZf9a3h472nqxBirbNyr/pXLnGm/7ElA== X-Received: by 10.28.55.82 with SMTP id e79mr21769wma.7.1507630946257; Tue, 10 Oct 2017 03:22:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.223.160.247 with SMTP id n52ls1598058wrn.6.gmail; Tue, 10 Oct 2017 03:22:25 -0700 (PDT) X-Received: by 10.223.175.45 with SMTP id z42mr962888wrc.27.1507630945943; Tue, 10 Oct 2017 03:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507630945; cv=none; d=google.com; s=arc-20160816; b=JbnkpBCXhh0JXTFNQt1K77cGJmdsOyjI9cjEdiVU0nYZ1+KWWyaBVhyStnZOKWFF1E TNQRL0trXUXObaGmuRk+zn4FgOI1etL6BwZwx3R7CUWNSpQmR98448QxNRGMSvX4noXo TQtmKZ03md5EKc1YC7HqmMJPjTp/Q78Mx3atOMabSrdodbthW24UDX2UXRLqmgs9iuIk xJGNnwKKcDNwr+1GB1+jiQdMss2i4USYVY4u0dsxoTm3xMIvWxJPW1U+xjQDZ5r6BwPt UMkxmmJkEk2FdX27zooNZz7S8yRrO5nLl/4q8ebU2YaGtxStBgvnUx0PjFriy8xojR6l V2/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=c1gI6kDj31khs0xWIDgl15ml+a9ak4/DGQfpLmP1GRE=; b=sGR/yD7asndxqaMwlDNYGJfBkiTvc+MxPJ39kKhcvt7bSwYbXwLVNaYr6MMkmzt3mX SGt1uHFdquaEU2X9ov9xMRdAtu3CNcyxE09qWQv9cJBYOAcnYRYv3y2lFT8Ha4oKSBOG oU8Cv7BxceLSUvTSkUijpaXmEVimvneVCQGn5R5oUAeYCQZFAJ7cCdq1CNrhUGxWaIv8 ltyaa86cxO6cyqOrAZrdIccXHoe014cNUQ1IelqStaq4bvVmuA/W/2NhF/gzSKkKhVMi vJMZVqvKANfjAAa5OP1FvkGPlqcuX+t198rAgL+OgAfCBuKbyMBTTZzqKEjK77xoR3jW Y5Ug== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.14 is neither permitted nor denied by domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id m74si990395wma.0.2017.10.10.03.22.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 03:22:25 -0700 (PDT) Received-SPF: neutral (google.com: 192.35.17.14 is neither permitted nor denied by domain of christian.storm@siemens.com) client-ip=192.35.17.14; Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id v9AAMP9A019672 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Oct 2017 12:22:25 +0200 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.251]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id v9AAMPJB017326; Tue, 10 Oct 2017 12:22:25 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH] Lua: Lua'ify l_register_handler() error path Date: Tue, 10 Oct 2017 12:22:06 +0200 Message-Id: <20171010102206.17038-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.14.2 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.35.17.14 is neither permitted nor denied by 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: , Since l_register_handler() is called from the Lua realm, return the count of return values, which is 0, instead of -1. Also clean up the stack in the error code path. Signed-off-by: Christian Storm --- corelib/lua_interface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 5b7860f..39ed01f 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -480,7 +480,8 @@ static int l_register_handler( lua_State *L ) { int *l_func_ref = malloc(sizeof(int)); if(!l_func_ref) { ERROR("lua handler: unable to allocate memory\n"); - return -1; + lua_pop(L, 2); + return 0; } else { const char *handler_desc = luaL_checkstring(L, 1); /* store the callback function in registry */