Skip to main content

SA0042: Usage of different access paths

Detects the usage of different access paths for the same variable

Justification: Different access to the same element decreases the readability and maintainability of a program. We recommend the consistent usage of {attribute 'qualified-only'} for libraries, global variable lists, and enumerations. This forces a fully qualified access.

Importance: Low

Example 51. Example
VAR_GLOBAL
    iTemp:INT;
    instPOU:POU;
END_VAR
FUNCTION_BLOCK POU
VAR
    a:INT;
END_VAR
a := INT#1;
PROGRAM SA0042
VAR
    ptiTemp:POINTER TO INT;
    sTemp:STRING;
END_VAR
ptiTemp := ADR(iTemp);

ptiTemp^ := INT#1;
iTemp := INT#2;    //  SA0042 - direct access on variable
GVL.iTemp := INT#3;    //  SA0042 - access on variable via GVL

sTemp := CONCAT( 'ab', 'cd');    // SA0042 - direct access on function
sTemp := Standard.CONCAT( 'ab', 'cd');    // SA0042 - access on function via Standard

instPOU();    //  SA0042 - direct access on POU instance
GVL.instPOU();    //  SA0042 - access via GVL

Output in the Messages view:

  • sa_icon_message.png SA0042: Different access paths for 'CONCAT'

  • sa_icon_message.png SA0042: Different access paths for 'Standard.CONCAT'

  • sa_icon_message.png SA0042: Different access paths for 'instPOU'

  • sa_icon_message.png SA0042: Different access paths for 'GVL.instPOU'

  • sa_icon_message.png SA0042: Different access paths for 'iTemp'

  • sa_icon_message.png SA0042: Different access paths for 'GVL.iTemp'