Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'getContent' : not all control paths return a value "

Tags:

c

`getContent` : not all control paths return a value

This is a warning I get while compiling a C program, where getContent is a bool method with website name and a buffer as its parameters and it is called recursively within that function if a desired page is not retrieved in the buffer.

How can I remove this warning?

like image 617
Mandar Avatar asked Nov 21 '25 01:11

Mandar


1 Answers

not all control paths return a value

This warning occurs when, well, not all control paths return a value. For example, the following code may produce the warning.

int f(bool b)
{
    if(b)
    {
        return 42; 
    } 
}

In order to fix this warning, you should return a value from all control paths.

 int f(bool b)
{
    if(b)
    {
        return 42; 
    }
    return 50; //<--
}
like image 171
Armen Tsirunyan Avatar answered Nov 23 '25 15:11

Armen Tsirunyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!