free quality report for PLCopenXML exports

Rules / write-series-outlier

One write in a series goes to a different exchange buffer

In a series of identical register writes, one line of the same shape writes to another array, and its index fills exactly the gap in the main buffer's numbering. It is a line copied without changing the buffer name.

Severity: Warning Rule id: write-series-outlier One write in a series goes to another buffer

What the rule checks

A block of uniform writes into an exchange buffer (Real2word(x, ADR(wData[93])), wData[95] := …) is usually typed by copying the neighbouring block. The rule looks for writes of the same shape that go into a DIFFERENT buffer, with their indices sitting exactly in a hole of the main buffer's numbering: the main buffer's indices stop just before them and resume just after. That is the trace of lines copied without renaming the buffer. The damage is twofold: those cells of the main buffer are never filled (the receiver sees zeros), and in the other buffer the writes overwrite values that someone else puts there. Neither the compiler nor bounds checking complains: both arrays are declared and the indices are legal.

What it does to the plant

The receiver sees zeros in the skipped cell, and values someone else writes into the other buffer get overwritten.

Example

Bad: the rule fires
VAR_GLOBAL    aScada : ARRAY[0..63] OF WORD;    aPanel : ARRAY[0..63] OF WORD;    rP1, rP2, rP3, rP4, rP5, rP6, rP7 : REAL;END_VARFUNCTION PackReal : BOOLVAR_INPUT    rValue : REAL;    pDest : POINTER TO DWORD;END_VARpDest^ := REAL_TO_DWORD(rValue);PackReal := TRUE;PROGRAM ExchWritePackReal(gvl.rP1, ADR(gvl.aScada[10]));PackReal(gvl.rP2, ADR(gvl.aScada[12]));PackReal(gvl.rP3, ADR(gvl.aPanel[14]));PackReal(gvl.rP4, ADR(gvl.aScada[16]));PackReal(gvl.rP5, ADR(gvl.aScada[18]));PackReal(gvl.rP6, ADR(gvl.aScada[20]));PackReal(gvl.rP7, ADR(gvl.aScada[22]));
Fixed: the rule is silent
VAR_GLOBAL    aScada : ARRAY[0..63] OF WORD;    aPanel : ARRAY[0..63] OF WORD;    rP1, rP2, rP3, rP4, rP5, rP6, rP7 : REAL;END_VARFUNCTION PackReal : BOOLVAR_INPUT    rValue : REAL;    pDest : POINTER TO DWORD;END_VARpDest^ := REAL_TO_DWORD(rValue);PackReal := TRUE;PROGRAM ExchWritePackReal(gvl.rP1, ADR(gvl.aScada[10]));PackReal(gvl.rP2, ADR(gvl.aScada[12]));PackReal(gvl.rP3, ADR(gvl.aScada[14]));PackReal(gvl.rP4, ADR(gvl.aScada[16]));PackReal(gvl.rP5, ADR(gvl.aScada[18]));PackReal(gvl.rP6, ADR(gvl.aScada[20]));PackReal(gvl.rP7, ADR(gvl.aScada[22]));

Both listings are run through the linter by an automated test: the rule fires on the first and stays silent on the second.

How to fix

  1. Compare the buffer name with the neighbouring lines of the series: if it is the same exchange table, change the buffer and the hole in the numbering closes.
  2. If writing to the other buffer is intended, move it out of the series into its own block with a comment, so nobody takes it for a copy error and "fixes" it back.
Check your project

Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.

Local version on GitHub →

The same linter without uploading a file: command line and GitHub Action.

Related rules

2026-11-26

Processing happens in memory, and the uploaded code is not stored. The tool advises; code changes are up to the engineer (see what the linter can't see). What happens to your code → · Rule reference · Your code & privacy · Industry benchmark · Feedback · GitHub