Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix libxml2 warnings #20

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

WGH-
Copy link
Contributor

@WGH- WGH- commented May 29, 2024

Every commit has detailed description.

I've tested this on Docker images golang:1.22-bullseye (libxml2 2.9.10), golang:1.22-bookworm (libxml2 2.9.14), and on my own system (libxml2 2.12.6).

Closes #19

WGH- added 3 commits May 30, 2024 21:28
Since libxml2 2.12.0, the error pointer is now const[1].

    /usr/include/libxml2/libxml/xmlschemas.h:185:65: note: expected ‘xmlStructuredErrorFunc’ {aka ‘void (*)(void *, const struct _xmlError *)’} but argument is of type ‘void (*)(void *, xmlError *)’ {aka ‘void (*)(void *, struct _xmlError *)’}

Unfortunately, this is not a backward compatible change, and we can't
just add a const, as that would give a warning on <2.12.0 versions instead...

So add an #if.

You can find lots of code going through the same pain on GitHub[2].

[1] https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.12.0
[2] https://github.com/search?type=code&q=%23if+LIBXML_VERSION+21200
Fix this compiler warning:

    ./libxml2.go: In function ‘cleanup’:
    ./libxml2.go:116:5: warning: ‘xmlSchemaCleanupTypes’ is deprecated [-Wdeprecated-declarations]
      116 |     xmlSchemaCleanupTypes();
          |     ^~~~~~~~~~~~~~~~~~~~~
    In file included from ./libxml2.go:9:
    /usr/include/libxml2/libxml/xmlschemastypes.h:37:17: note: declared here
       37 |                 xmlSchemaCleanupTypes           (void);
          |                 ^~~~~~~~~~~~~~~~~~~~~

We are probably safe to remove this call altogether, but let's do this
conservatively.

See [1][2].

[1] https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.10.0
[2] https://gitlab.gnome.org/GNOME/libxml2/-/commit/40483d0ce26119fd3b23aea6cce532a8a78670cf
xmlParseMemory is deprecated since v2.11.0[1][2]. Although it doesn't
cause compiler warnings itself, it doesn't return line/column
information UNLESS xmlLineNumbersDefault(1) is called, which IS
deprecated AND causes compiler warnings.

[1] https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.11.0
[2] https://gitlab.gnome.org/GNOME/libxml2/-/commit/0e49f8826a71be2c56b8f7e86a5c103dd21a8f3f
@terminalstatic terminalstatic merged commit de64dc1 into terminalstatic:master Jul 9, 2024
@terminalstatic
Copy link
Owner

Thanks for the commits and your detailed comments. I haven't tested them, but your comments seemed reasonable.
I'd really like to incorparate changes of a fork into the code and tag a new version in the near future, at least then I'll test it.

@WGH-
Copy link
Contributor Author

WGH- commented Jul 10, 2024

Thanks for the commits and your detailed comments. I haven't tested them, but your comments seemed reasonable.

What if I'm just an LLM? :)

(just kidding, no, I'm not)

@terminalstatic
Copy link
Owner

Well that's why I didn't tag it with a version yet for I'm quite paranoid of getting spoofed by a LLM ;).
And I guess claiming that you are no LLM is probably exactly what a LLM would do ...
Actually I just had such an experience yesterday, no kidding.

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.

Deprecation and incompatible pointer type warning on new libxml2 versions
2 participants