Main Content

Check for utilization of the return value of functions

Check ID: mathworks.jmaab_v6.mp_0040

Guideline: mp_0040: Usage of return value of a function

Description

Checks whether the return values of functions are assigned to variables before use.

This check applies to the following target components:

  • MATLAB Function blocks in Simulink®.

  • MATLAB® functions in Stateflow® charts.

  • States, transitions, and truth tables in Stateflow MATLAB charts.

  • External MATLAB files referenced in a model.

This check requires a Simulink Check™ license.

Check Parameterization

This check does not include sub-checks because the JMAAB modeling guideline provides only one sub ID.

For reference, the guideline sub ID(s) that are recommended for use by the JMAAB modeling standards organizations are:

  • JMAAB — a

Select Check external .m files referenced in the model, to include .m files referenced by a model in the analysis. The check box is selected by default.

Select Exclude conditional statements, to exclude while, if-else, for, and switch statements from analysis. The check box is not selected by default.

Results and Recommended Actions

ConditionRecommended Action
The return values of one or more functions are not assigned to variables before use.Assign the return values of functions to variables before use.

Capabilities and Limitations

  • Does not check if the return value of anonymous functions is assigned to variables before use.

  • Considers undefined variables as functions that do not return values and flags them.

  • Analyzes content of library-linked blocks. By default, the input parameter Follow links is set to on.

  • Analyzes content in masked subsystems. By default, the input parameter Look under masks is set to all.

  • Runs on library models.

  • Allows exclusion of blocks and charts.