Main Content

Review and Fix Function Not Called Checks

This topic describes how to systematically review the results of a Function not called check in Polyspace® Code Prover™.

Follow one or more of these steps until you determine a fix for the Function not called check. There are multiple ways to fix this check. For a description of the check and code examples, see Function not called.

If you determine that the check represents defensive code or a function that is part of a library, add a comment and justification in your result or code explaining why you did not change your code. See Address Results in Polyspace User Interface Through Bug Fixes or Justifications or Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access).

Note

This check is not turned on by default. To turn on this check, you must specify the appropriate analysis option. For more information, see Detect uncalled functions (-uncalled-function-checks).

Step 1: Interpret Check Information

On the Results List pane, select the check. On the Source pane, the body of the function is highlighted in gray.

Step 2: Determine Root Cause of Check

  1. Search for the function name and see if you can find a call to the function in your code.

    On the Search pane, enter the function name. From the drop-down list beside the search field, select Source.

    Possible fix: If you do not find a call to the function, determine why the function definition exists in your code.

  2. If you find a call to the function, see if it occurs in the body of another uncalled function.

    Possible fix: Investigate why the latter function is not called.

  3. See if you call the function indirectly, for example, through function pointers.

    If the indirection is too deep, Polyspace sometimes cannot determine that a certain function is called.

    Possible fix: If Polyspace cannot determine that you are calling a function indirectly, you must verify the function separately. You do not need to write a new main function for this other verification. Polyspace can generate a main function if you do not provide one in your source. You can change the main generation options if needed. For more information on the options, see Code Prover Verification.

Step 3: Look for Common Causes of Check

Look for the following common causes of the Function not called check.

  • Determine if you intended to call the function but used another function instead.

  • Determine if you intended to replace some code with a function call. You wrote the function definition, but forgot to replace the original code with the function call.

    If this situation occurs, you are likely to have duplicate code.

  • See if you intend to call the function from yet unwritten code. If so, retain the function definition.

  • For code intended for multitasking, see if you have specified all your entry point functions.

    To see the options used for the result, select the link View configuration for results on the Dashboard pane.

    For more information, see Tasks (-entry-points).

  • For code intended for multitasking, see if your main function contains an infinite loop. Polyspace Code Prover requires that your main function must complete execution before the other entry points begin.

    For more information, see Configuring Polyspace Multitasking Analysis Manually.