Fix: lttng: uninitialized pointer free'd when no sessiond is present
[lttng-tools.git] / src / lib / lttng-ctl / filter / filter-visitor-ir-check-binary-op-nesting.c
CommitLineData
953192ba
MD
1/*
2 * filter-visitor-ir-check-binary-op-nesting.c
3 *
4 * LTTng filter IR check binary op nesting
5 *
ab5be9fa 6 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
953192ba 7 *
ab5be9fa 8 * SPDX-License-Identifier: LGPL-2.1-only
953192ba 9 *
953192ba
MD
10 */
11
12#include <stdio.h>
13#include <unistd.h>
14#include <string.h>
15#include <stdlib.h>
16#include <assert.h>
17#include <errno.h>
18#include <inttypes.h>
953192ba 19#include "filter-ast.h"
95b9bd90 20#include "filter-parser.h"
953192ba
MD
21#include "filter-ir.h"
22
a187da1a
DG
23#include <common/macros.h>
24
953192ba
MD
25static
26int check_bin_op_nesting_recursive(struct ir_op *node, int nesting)
27{
28 switch (node->op) {
29 case IR_OP_UNKNOWN:
30 default:
31 fprintf(stderr, "[error] %s: unknown op type\n", __func__);
32 return -EINVAL;
33
34 case IR_OP_ROOT:
35 return check_bin_op_nesting_recursive(node->u.root.child,
36 nesting);
37 case IR_OP_LOAD:
38 return 0;
39 case IR_OP_UNARY:
40 return check_bin_op_nesting_recursive(node->u.unary.child,
41 nesting);
42 case IR_OP_BINARY:
43 {
44 int ret;
45
953192ba 46 ret = check_bin_op_nesting_recursive(node->u.binary.left,
29190311 47 nesting + 1);
953192ba
MD
48 if (ret)
49 return ret;
50 return check_bin_op_nesting_recursive(node->u.binary.right,
29190311 51 nesting + 1);
953192ba
MD
52 }
53 case IR_OP_LOGICAL:
54 {
55 int ret;
56
57 ret = check_bin_op_nesting_recursive(node->u.logical.left,
58 nesting);
59 if (ret)
60 return ret;
61 return check_bin_op_nesting_recursive(node->u.logical.right,
62 nesting);
63 }
64 }
65}
66
a187da1a 67LTTNG_HIDDEN
953192ba
MD
68int filter_visitor_ir_check_binary_op_nesting(struct filter_parser_ctx *ctx)
69{
70 return check_bin_op_nesting_recursive(ctx->ir_root, 0);
71}
This page took 0.064404 seconds and 5 git commands to generate.