Fix bug in `expr_clone` 54/32354/1 accepted/tizen_3.0.m2_mobile accepted/tizen_3.0.m2_tv accepted/tizen_3.0.m2_wearable accepted/tizen_3.0_common accepted/tizen_3.0_ivi accepted/tizen_3.0_mobile accepted/tizen_3.0_tv accepted/tizen_3.0_wearable tizen_3.0 tizen_3.0.2014.q4_common tizen_3.0.2015.q1_common tizen_3.0.2015.q2_common tizen_3.0.m1_mobile tizen_3.0.m1_tv tizen_3.0.m2 tizen_3.0_ivi tizen_3.0_tv accepted/tizen/3.0.m2/mobile/20170105.024719 accepted/tizen/3.0.m2/tv/20170105.024857 accepted/tizen/3.0.m2/wearable/20170105.025026 accepted/tizen/3.0/common/20161114.111229 accepted/tizen/3.0/ivi/20161011.050532 accepted/tizen/3.0/mobile/20161015.033658 accepted/tizen/3.0/tv/20161016.005241 accepted/tizen/3.0/wearable/20161015.083719 accepted/tizen/common/20141218.172009 accepted/tizen/ivi/20141225.103508 accepted/tizen/ivi/20160218.025301 accepted/tizen/mobile/20150224.002805 accepted/tizen/tv/20150324.014607 accepted/tizen/wearable/20150129.005756 submit/tizen_3.0.m2/20170104.093753 submit/tizen_3.0_common/20161104.104000 submit/tizen_3.0_ivi/20161010.000004 submit/tizen_3.0_mobile/20161015.000004 submit/tizen_3.0_tv/20161015.000004 submit/tizen_3.0_wearable/20161015.000004 submit/tizen_common/20141218.170817 submit/tizen_ivi/20141225.222222 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000006 submit/tizen_mobile/20150129.000000 submit/tizen_mobile/20150213.000000 submit/tizen_mobile/20150223.000001 submit/tizen_tv/20150130.050505 submit/tizen_tv/20150320.000002 submit/tizen_tv/20150323.050640 submit/tizen_wearable/20150127.000001 submit/tizen_wearable/20150128.000000 tizen_3.0.m1_mobile_release tizen_3.0.m1_tv_release tizen_3.0.m2.a1_mobile_release tizen_3.0.m2.a1_tv_release tizen_3.0_ivi_release
authorJosé Bollo <jose.bollo@open.eurogiciel.org>
Wed, 17 Dec 2014 10:17:33 +0000 (11:17 +0100)
committerJosé Bollo <jose.bollo@open.eurogiciel.org>
Wed, 17 Dec 2014 10:17:33 +0000 (11:17 +0100)
On allocation failure of nhls for EXPR_OP_CALL2,
EXPR_OP_UP, EXPR_OP_CALL1, the correct behaviour,
that is returning -1, was only effective if

  node->kind == EXPR_OP_CALL2 and node->u.call.own_rhs

This change implements the correct behaviour.

It also solves a warning when compiling with gcc4.9 that
broke integration when compiling with -Werror: the compiler
was hurt to use nrhs that he suspected (wrongly) to be
uninitialised.

Change-Id: I184fea5e121d38fa1df5d0a8680edf51e9fff1a8
Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
expr.c

diff --git a/expr.c b/expr.c
index 4059a32..3220509 100644 (file)
--- a/expr.c
+++ b/expr.c
@@ -229,21 +229,25 @@ expr_clone(struct expr_node *retp, const struct expr_node *node)
                                         node->u.call.own_rhs) < 0)
                        return -1;
                retp->u.call.rhs = nrhs;
-               /* Fall through.  */
 
-       case EXPR_OP_UP:
-       case EXPR_OP_CALL1:
                if (expr_alloc_and_clone(&nlhs, node->lhs, node->own_lhs) < 0) {
-                       if (node->kind == EXPR_OP_CALL2
-                           && node->u.call.own_rhs) {
+                       if (node->u.call.own_rhs) {
                                expr_destroy(nrhs);
                                free(nrhs);
-                               return -1;
                        }
+                       return -1;
                }
 
                retp->lhs = nlhs;
                return 0;
+
+       case EXPR_OP_UP:
+       case EXPR_OP_CALL1:
+               if (expr_alloc_and_clone(&nlhs, node->lhs, node->own_lhs) < 0)
+                       return -1;
+
+               retp->lhs = nlhs;
+               return 0;
        }
 
        assert(!"Invalid value of node kind");