Doxygen: Missing Call graph for internal functions - doxygen

I started using Doxygen 1.8.7. I noticed that call graphs are missing when the called function is located deeper in a file. In the below example, the call graph for function1() is absent. Is there any dependency on the parsing level?
void function1(int cmd, int arg)
{
int ret = 0;
switch (cmd)
{
case 1:
if(arg == 10) { ret = function2(); }
break;
case 2:
if(arg == 10) { ret = function3(); }
break;
case 3:
if(arg == 10) { ret = function4(); }
break;
default:
ret = function5();
}
return;
}

Related

Incompatible Types: T cannot be converted to LinkedList<T>.Node, confused about how to fix

I'm trying to implement a remove method from scratched for the LinkedList class and like the title says, I've been getting the :
"incompatible types: T cannot be converted to LinkedList.Node"
Here's my code :
public class LinkedList<T> implements LinkedListInterface<T> {
private Node head;
private Node tail;
private int count;
public LinkedList () {
head = null;
tail = null;
count = 0;
}
class Node {
T data;
Node next;
Node(T data) {
this.data = data;
next = null;
}
}
public Node getHead() {
return head;
}
public T remove(int pos) throws ListException {
if (pos < 1 || pos > count) {
throw new ListException("Invalid position to remove from");
}
Node removedItem = null;
if (count == 1) {
removedItem = head.data; // Here it says the error
head = null;
tail = null;
}
else if (pos == 1) {
removedItem = head.data;
head = head.next;
}
else if (pos == count) {
removedItem = tail.data; // Same error
Node prev = jump(pos - 2);
prev.next = null;
tail = prev;
}
else {
Node prev = jump(pos - 2);
removedItem = prev.next.data; // Same error
prev.next = prev.next.next;
}
count--;
return removedItem; // Same error
}
}
I've been so confused on how to fix it, I tried putting this.head.data or this.tail.data but to no avail, any ideas? Thanks

Continue in Scala for loops

How do i convert below Java code to scala and use continue in for loop, this program remove minimum number of extra closed parenthesis in a given string
input : lee(t(c)o)de)
output : leet(t(c)o)de
public String minRemoveToMakeValid(String s){
StringBuilder sb =new StringBuilder();
in open =0;
for (char c : s.toCharArray()){
if(c == '('){
open++
}
else if(c == ')'){
if(open == 0) continue;
open --;
}
sb.append(c)
}
return sb
}
https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/
import util.control.Breaks._
val searchMe = "peter piper picked a peck of pickled peppers"
var numPs = 0
for (i <- 0 until searchMe.length) {
breakable {
if (searchMe.charAt(i) != 'p') {
break // break out of the 'breakable', continue the outside loop
} else {
numPs += 1
}
}
}
println("Found " + numPs + " p's in the string.")
Try it: https://scastie.scala-lang.org/R9sr95WESLyiKamCHHUVdQ
Im able to get it worked using below code
def minRemoveToMakeValid(s: String): String = {
var open = 0
val sb = new StringBuilder
for (c <- s.toCharArray) {
breakable {
if (c == '(') open += 1
else if (c == ')') {
if (open == 0)break
open -= 1
}
sb.append(c)
}
}
var result = new StringBuilder()
for(i<-sb.length()-1 to 0 by -1)
{
breakable{
open-=1
if(sb.charAt(i) == '(' && open >0) break
result.append(sb.charAt(i))
}
}
result.reverse.toString()
}

How can i fix my code to make my count value update from my function

How can i make _handlerRadioValuegender() update my count value which I declared as var count = 3 on top.
I tried what i can do and here are all debugprint() functions results. It is now always taking the value which I define on top means my _handler function has no effect on the count value.
var count = 3;
int _handleRadioValuegender(int value) {
setState(() {
_gender = value;
switch (_gender) {
case 0:
debugPrint('case0');
count++;
debugPrint('$count');
break;
case 1:
debugPrint('case1');
this.count++;
this.count++;
debugPrint('$count');
break;
}
});
}
String gender() {
if (count == 1) {
debugPrint('$count');
return 'Male';
} else if (count == 3) {
debugPrint('$count');
return 'Female';
} else {
debugPrint('$count');
}
}
I want my count value to be updated from my _handlerRadioValuegender() function and when gender() access it, then it should return value according to that.Screenshot of debugprints()

How to do parenthesis balancing using scala, recursion ,one function and one parameter for the function?

I am builing a little method for parenthesis balancing using scala and recursion.
I came out this code which surprisingly doesn't work.
object Test{
def balance(chars: List[Char]): Boolean=
{
var opening_index: Int = -1
var closing_index: Int = -1
opening_index = chars.indexOf('(')
closing_index = chars.indexOf(')')
println(opening_index)
println(closing_index)
if ( chars.size == 0 ) true
if ((opening_index == -1) & (closing_index== -1))
{
true
}
if (closing_index> -1 & opening_index> -1)
{
if (closing_index< opening_index) return(false)
else
{
balance(chars.filter(_!=chars(closing_index)).filter(_!=chars(opening_index)))
}
}
else
return (false)
}
val lst:List[Char] = List('(',')' ,'3','4')
balance(lst)
}
I am aware that there are other similar posts but I am more interested in using this approach than the other ones.
You probably wanted to filter by index, not by character. As it is, your code erases all parentheses in the first round.
This here works with zipWithIndex, and compares the index with opening_index and closing_index:
def balance(chars: List[Char]): Boolean = {
val opening_index = chars.indexOf('(')
val closing_index = chars.indexOf(')')
if ( chars.size == 0 ) {
true
} else if ((opening_index == -1) && (closing_index== -1)) {
true
} else if (closing_index > -1 && opening_index > -1) {
if (closing_index < opening_index) {
false
} else {
balance(
chars.zipWithIndex.filterNot{
case (c, i) => i == opening_index || i == closing_index
}.map(_._1)
)
}
} else {
false
}
}
println(balance("()34".toList))
println(balance("()34)".toList))
println(balance("(x)(y(z))".toList))
println(balance("(x)(y(z)".toList))
Output:
true
false
true
false
You can use below solution to check balance parenthesis.
object Driver extends App{
def balance(chars: List[Char]): Boolean=
{
if (chars.mkString("").length() == 0) {
return true;
}
if (chars.mkString("").contains("()")) {
return balance(chars.mkString("").replaceFirst("\\(\\)", "").toCharArray.toList);
}
if (chars.mkString("").contains("[]")) {
return balance(chars.mkString("").replaceFirst("\\[\\]", "").toCharArray.toList);
}
if (chars.mkString("").contains("{}")) {
return balance(chars.mkString("").replaceFirst("\\{\\}", "").toCharArray.toList);
} else {
return false;
}
}
println(balance(List('(','{','}')))
println(balance(List('(','{','}',')')))
}
There are two main (functional) problems with this code.
Firstly, this test does nothing because the result is thrown away
if ((opening_index == -1) & (closing_index== -1))
{
true
}
You probably meant return true
Secondly, the recursive call is wrong
balance(chars.filter(_ != chars(closing_index)).filter(_ != chars(opening_index)))
These two calls to filter are removing all the parentheses from the list, so the call to balance will always succeed even if the rest of the list is unbalanced.
You probably want to use three slice calls to remove the specific parentheses at opening_index and closing_index.

OpenSSL Blocking Sockets SSL_read blocks [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am using blocking sockets in OpenSSL connection. SSL_read blocks sometimes for few seconds. In server - BIO_write is used to send data in variable buffer size. In client - first SSL_read to get buffer size succeeds but following SSL_read to get buffer data blocks for few seconds(this issue is simulated after 2 to 3mins) even though data sent successfully. I wait on poll() to invoke client read function. How to correct these problem in blocking sockets?
Server Code
void process_and_send() {
// sending variable size buffer each time
// sbuf - first 4 bytes contains sbuf size information
send_data(sbuf, sbufSize);
}
void send_data(void *sbuf, int pending_len) {
while(pending_len > 0) {
result = BIO_write(bio, sbuf, pending_len);
if(result == 0) {
attempts = 0;
LOG_D("%s", log_str(SSL_CONN_CLOSE));
SSL_FN_TRACE("connection closed\n");
break;
}
else if(result < 0) {
LOG_I("%s", log_str(SSL_WRITE_FAIL));
SSL_FN_TRACE("BIO_write fail\n");
if(errno == EINTR) {
continue;
}
if(errno == EAGAIN) {
attempts++;
continue;
}
if(errno == EWOULDBLOCK) {
attempts++;
continue;
}
break;
}
else {
BIO_flush(bio);
pending_len -= result;
sbuf += result;
}
}
}
Client Code
// wait on poll() and call receive_and_process
void receive_and_process() {
int rbufSize = 0;
// get the size of data to read
receive_data((void *)&rbufSize, sizeof(Int));
// this call blocks for few seconds
receive_data(rbuf, rbufSize);
}
void receive_data(void *rbuf, int pending_len) {
while(pending_len > 0) {
result = SSL_read(ssl, rbuf, pending_len);
if(result == 0) {
LOG_D("%s", log_str(SSL_CONN_CLOSE));
SSL_FN_TRACE("connection closed\n");
return NULL;
}
else if(result < 0) {
if(errno == ETIMEDOUT) {
SSL_FN_ERROR("SSL read timeout: \n");
continue;
}
if(errno == EINTR) {
continue;
}
if(errno == EAGAIN) {
continue;
}
if(errno == EWOULDBLOCK) {
continue;
}
SSL_FN_ERROR("SSL read fail error no: %s\n",
ERR_reason_error_string(ERR_get_error()));
LOG_I("%s", log_str(SSL_READ_FAIL));
return NULL;
}
pending_len -= result;
rbuf += result;
FN_ERROR("after read full data pending len %d\n", pending_len);
}
}
Well, for starters, your client code can't compile as shown, because receive_data() has a void return type, so return NULL is a compiler error. Also, you can't use the += operator on a void* pointer, that is also a compiler error.
Beside that, if SSL_read() returns < 0, you need to use SSL_get_error() instead of errno to find out why it failed. Don't use errno unless SSL_get_error() returns SSL_ERROR_SYSCALL. If SSL_get_error() returns SSL_ERROR_SSL, use ERR_get_error() and related functions instead. And, make sure you are handling the SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE errors.
Also, when sending multi-byte integers, you have to deal with endian issues if you are sending across machine boundaries. Best to use functions like htonl() and ntohl() to send integers over the connection in network byte order.
Try something more like this:
Server:
void process_and_send() {
// sending variable size buffer each time
// sbuf - DO NOT store the size information in the first 4 bytes!
// handle the size separately...
int32_t size = htonl(sbufSize);
if (send_data(&size, sizeof(size)))
send_data(sbuf, sbufSize);
}
bool send_data(void *sbuf, int pending_len) {
unsigned char *pbuf = (unsigned char *) sbuf;
while (pending_len > 0) {
result = BIO_write(bio, pbuf, pending_len);
if (result > 0) {
BIO_flush(bio);
pbuf += result;
pending_len -= result;
}
else if (result == 0) {
attempts = 0;
LOG_D("%s", log_str(SSL_CONN_CLOSE));
SSL_FN_TRACE("connection closed\n");
return false;
}
else if (!BIO_should_retry(bio)) {
LOG_I("%s", log_str(SSL_WRITE_FAIL));
SSL_FN_TRACE("BIO_write fail\n");
return false;
}
else {
++attempts;
}
}
return true;
}
Client:
// wait on poll() and call receive_and_process
void receive_and_process() {
int32_t rbufSize = 0;
// get the size of data to read
if (receive_data(&rbufSize, sizeof(rbufSize))) {
rbufSize = ntohl(rbufSize);
// TODO: make sure rbuf is at least rbufSize in size...
receive_data(rbuf, rbufSize);
}
}
bool receive_data(void *rbuf, int pending_len) {
unsigned char *pbuf = (unsigned char *) rbuf;
while (pending_len > 0) {
result = SSL_read(ssl, pbuf, pending_len);
if (result > 0) {
pbuf += result;
pending_len -= result;
FN_ERROR("after read full data pending len %d\n", pending_len);
}
else {
result = SSL_get_error();
if (result == SSL_ERROR_ZERO_RETURN) {
LOG_D("%s", log_str(SSL_CONN_CLOSE));
SSL_FN_TRACE("connection closed\n");
}
else {
if (result == SSL_ERROR_WANT_READ) {
// TODO: use select() to wait for the socket to be readable before trying again...
continue;
}
else if (result == SSL_ERROR_WANT_WRITE) {
// TODO: use select() to wait for the socket to be writable before trying again...
continue;
}
else if (result == SSL_ERROR_SYSCALL) {
if ((errno == EINTR) || (errno == EAGAIN) || (errno == EWOULDBLOCK)) {
continue;
}
if (errno == ETIMEDOUT) {
SSL_FN_ERROR("SSL read timeout: \n");
continue;
}
SSL_FN_ERROR("SSL read fail error no: %d\n", errno);
}
else if (result == SSL_ERROR_SSL) {
SSL_FN_ERROR("SSL read fail error no: %s\n",
ERR_reason_error_string(ERR_get_error()));
}
else {
SSL_FN_ERROR("SSL read fail error no: %d\n", result);
}
LOG_I("%s", log_str(SSL_READ_FAIL));
}
return false;
}
}
return true;
}