Skip to content

yangupdate BUGFIX Windows test link errors - #2573

Merged
michalvasko merged 2 commits into
CESNET:develfrom
jktjkt:fix/windows-yangupdate-test-link
Sep 16, 2026
Merged

michalvasko merged 2 commits into
CESNET:develfrom
jktjkt:fix/windows-yangupdate-test-link

Conversation

@jktjkt

@jktjkt jktjkt commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

LIBYANG_BUILD was never defined for the yang_update static lib, so LIBYANG_API_DECL resolved to dllimport instead of dllexport on MSVC, breaking the yangupdate_find_mod1/complex_update tests with LNK2019.

Must be PUBLIC, not PRIVATE: test.c never compiles yang_update.c, it only links the lib, and PRIVATE defines don't propagate to linkers.

jktjkt and others added 2 commits September 16, 2026 11:06
`LIBYANG_BUILD` was never defined for the `yang_update` static lib, so
`LIBYANG_API_DECL` expanded to `dllimport` instead of `dllexport` on
MSVC, breaking the `yangupdate_find_mod1`/`complex_update` tests with
LNK2019.

It is `PUBLIC`, not `PRIVATE`, because `test.c` doesn't compile
`yang_update.c` directly, it only links the lib, and `PRIVATE` defines
won't propagate to linkers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
All three spots read a whole file with fopen(path, "r") + ftell()-sized
fread(), then null-terminate at the ftell() size. On Windows, text-mode
fread() collapses \r\n to \n, so it returns fewer bytes than ftell()
reported whenever the file has CRLF line endings. That left the tail
of each buffer as uninitialized heap garbage instead of content.

In yang_update.c this fed a YANG parser garbage after the real module
text, failing with "Trailing garbage ... after module, expected
end-of-input." In the two test files it just desynced the compared
buffer's length.

Use fread()'s actual return value to size/terminate the buffer instead
of trusting ftell(), regardless of the file's on-disk line endings.
Opening in binary mode instead would dodge the byte-count mismatch too,
but the two test files compare against libyang's own LF-only printer
output, so a CRLF checkout would then fail on stray \r's instead - a
checkout-dependent bug rather than a fixed one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jktjkt
jktjkt marked this pull request as ready for review September 16, 2026 09:27
@michalvasko
michalvasko merged commit de3e28f into CESNET:devel Sep 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants