yangupdate BUGFIX Windows test link errors - #2573
Merged
michalvasko merged 2 commits intoSep 16, 2026
Merged
Conversation
`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
marked this pull request as ready for review
September 16, 2026 09:27
michalvasko
approved these changes
Sep 16, 2026
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.
LIBYANG_BUILDwas never defined for theyang_updatestatic lib, soLIBYANG_API_DECLresolved todllimportinstead ofdllexporton MSVC, breaking theyangupdate_find_mod1/complex_updatetests with LNK2019.Must be
PUBLIC, notPRIVATE:test.cnever compilesyang_update.c, it only links the lib, and PRIVATE defines don't propagate to linkers.