Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\trace\trace_events_filter.c Create Date:2022-07-28 12:25:16
Last Modify:2022-05-22 20:19:57 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Read the filter string once to calculate the number of predicates* as well as how deep the parentheses go.* Returns:* 0 - everything is fine (err is undefined)* -1 - too many ')'* -2 - too many '('* -3 - No matching quote

Proto:static int calc_stack(const char *str, int *parens, int *preds, int *err)

Type:int

Parameter:

TypeParameterName
const char *str
int *parens
int *preds
int *err
1410  bool is_pred = false
1411  nr_preds = 0
1412  open = 1
1413  last_quote = 0
1414  max_open = 1
1415  quote = 0
1418  err = 0
1420  When str[i] cycle
1421  If Note: isspace() must return false for %NUL-terminator (str[i]) Then Continue
1423  If quote Then
1424  If str[i] == quote Then quote = 0
1426  Continue
1430  Case str[i] == '\''
1431  Case str[i] == '"'
1432  quote = str[i]
1433  last_quote = i
1434  Break
1435  Case str[i] == '|'
1436  Case str[i] == '&'
1437  If str[i + 1] != str[i] Then Break
1439  is_pred = false
1440  Continue
1441  Case str[i] == '('
1442  is_pred = false
1443  open++
1444  If open > max_open Then max_open = open
1446  Continue
1447  Case str[i] == ')'
1448  is_pred = false
1449  If open == 1 Then
1450  err = i
1451  Return TOO_MANY_CLOSE
1453  open--
1454  Continue
1456  If Not is_pred Then
1457  nr_preds++
1458  is_pred = true
1462  If quote Then
1463  err = last_quote
1464  Return MISSING_QUOTE
1467  If open != 1 Then
1468  level = open
1471  When i cycle
1472  If quote Then
1473  If str[i] == quote Then quote = 0
1475  Continue
1478  Case str[i] == '('
1479  If level == open Then
1480  err = i
1481  Return TOO_MANY_OPEN
1483  level--
1484  Break
1485  Case str[i] == ')'
1486  level++
1487  Break
1488  Case str[i] == '\''
1489  Case str[i] == '"'
1490  quote = str[i]
1491  Break
1495  err = 0
1496  Return TOO_MANY_OPEN
1500  parens = max_open
1501  preds = nr_preds
1502  Return 0
Caller
NameDescribe
process_preds