Repository navigation
cdd: correct LINCOMP conversions and support packed integer containers - #59
Merged
Merged
Conversation
Owner
Author
|
cursor review |
Owner
Author
|
cursor review |
Owner
Author
|
cursor review |
Owner
Author
|
cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit db05544. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CDD LINCOMP decoding ignored
div, so raw 502 withf=1,div=100,o=0decoded as 502 and encoding 5.02 failed. STRUCT resolution also discarded the enclosing datatype and treated children as consecutive wire fields, losing the container's size and byte mapping.Normalise LINCOMP to
physical = (f/div)*raw + oand use the existing inverse codec. Preserve exact 64-bit integers for identity conversions, enforce optional limits against raw integers, and reject malformed/non-finite parameters, zero divisors, ambiguous declarations and empty representable ranges. Only an omitted divisor defaults to 1; negative divisors are accepted.Retain STRUCT container metadata and position integer children from its logical least-significant bit. Apply atomic container byte order to the combined value; fixed one-byte arrays use most-significant-byte-first mapping unless the
ReverseBitfieldBytesenumeration resolved withinECUDOC/DEFATTS/DATATYPEATTS(also accepting the explicitReverseBitFieldBytesspelling, with duplicate declarations rejected) reverses the whole sequence. Explicit gaps and unused container space remain reserved: ignored when decoding and zero when encoding. Width checks protect neighbouring fields. Unresolved and overfull layouts fail explicitly.Reference evidence and scope
00 7Ffor Motorola and7F 00for Intel. The independently calculated 7-bit/9-bit case gives91 B5andB5 91.candela.dtdfor 10.0.108 remains unavailable. These findings do not establish every XML attribute requirement. Missing factor/offset remain explicitly unsupported, without invented defaults. Zero-factor conversions need Vector's explicit inverse-value behaviour and remain unsupported rather than being classified as malformed.Validation
go test -race ./...passed.go vet ./...passed.gofmt -l .produced no output;git diff --checkpassed.Conversion handling and packed-field support are in separate commits, followed by focused validation and minimalism fixes.
Note
Medium Risk
Changes core CDD record encode/decode and on-wire layout for LINCOMP and STRUCT containers, which can alter bytes and decoded values for existing catalogs even though behavior is intended to match CANdelaStudio rules.
Overview
Fixes LINCOMP handling so physical values use
(f/div)*raw + o(div defaults to 1), with stricter parsing and codec checks for raw limits (s/e), non-finite parameters, zero divisors, ambiguousCOMP/CVALUETYPE, and empty representable ranges. Encode/decode now validate raw values against those limits when present.STRUCT with a fixed byte-aligned IDENT or TEXTTBL container is resolved as a shared bitfield: children pack from the container LSB with container byte order, optional ReverseBitfieldBytes reversal for one-byte arrays, gaps/reserved bits ignored on decode and zeroed on encode. Record Encode/Decode route bitfield children through
readPacked/writePackedand relax byte-alignment rules only inside bitfields.Test fixtures drop invalid untyped STRUCT wrappers; large reference tests cover conversions, packing, reversal, and rejection cases.
Reviewed by Cursor Bugbot for commit db05544. Configure here.