Whether hte arg is the a buf read from in_file. fread(buf, data, 1, size, in_file);
(arg: &Node, visitor: &Visitor)
| 1540 | /// Whether hte arg is the a buf read from in_file. |
| 1541 | /// fread(buf, data, 1, size, in_file); |
| 1542 | pub fn is_read_from_file(arg: &Node, visitor: &Visitor) -> bool { |
| 1543 | if let Clang::DeclRefExpr(dre) = &arg.kind { |
| 1544 | let arg_name = dre.get_name_as_string(); |
| 1545 | let calls = visitor.find_callexprs("fread"); |
| 1546 | if calls.is_empty() { |
| 1547 | return false; |
| 1548 | } |
| 1549 | for call in calls { |
| 1550 | if let Clang::CallExpr(ce) = &call.kind { |
| 1551 | let mut arg_match = false; |
| 1552 | let args = ce.get_childs(call); |
| 1553 | if let Some(array_arg) = args.first() { |
| 1554 | if let Clang::DeclRefExpr(dre) = &array_arg.kind { |
| 1555 | let fread_buf_name = dre.get_name_as_string(); |
| 1556 | if arg_name == fread_buf_name { |
| 1557 | arg_match = true; |
| 1558 | } |
| 1559 | } |
| 1560 | } |
| 1561 | if !arg_match { |
| 1562 | continue; |
| 1563 | } |
| 1564 | if let Some(file_arg) = args.get(3) { |
| 1565 | if let Clang::DeclRefExpr(dre) = &file_arg.kind { |
| 1566 | let fread_file_name = dre.get_name_as_string(); |
| 1567 | if fread_file_name == "in_file" { |
| 1568 | return true; |
| 1569 | } |
| 1570 | } |
| 1571 | } |
| 1572 | } |
| 1573 | } |
| 1574 | } |
| 1575 | false |
| 1576 | } |
| 1577 | |
| 1578 | // Is this arg returned by calls |
| 1579 | pub fn is_ret_by_call(func: &str, arg_pos: usize, visitor: &Visitor) -> bool { |
no test coverage detected