C1856: Return <expression> expected

[DISABLE, ERROR, WARNING , INFORMATION]

Description

A return statement without expression is executed while the function expects a return value. In ANSI-C, this is correct but not clean. In such a case, the program runs back to the caller. If the caller uses the value of the function call then the behavior is undefined.

Example
  int foo(void){

  
    return;

  
  }

  
  void main(void){

  
  int a;

  
    ...

  
    a = foo();

  
    ...         // behavior undefined

  
  }

  
Tips
  #define ERROR_CASE_VALUE 0

  
  int foo(void){

  
    return ERROR_CASE_VALUE;   // return something...

  
  }

  
  void main(void){

  
  int a;

  
    ...

  
    a = foo();

  
    if (a==ERROR_CASE_VALUE){  // ... and treat this case

  
      ...

  
    } else {

  
      ...

  
    }

  
    ...

  
  }