]> git.ipfire.org Git - thirdparty/zstd.git/commit
fileio_types.h : avoid dependency on mem.h 3232/head
authorYann Collet <cyan@fb.com>
Wed, 3 Aug 2022 19:39:35 +0000 (21:39 +0200)
committerYann Collet <cyan@fb.com>
Wed, 3 Aug 2022 19:39:35 +0000 (21:39 +0200)
commit3dfcafacd74e5b36fad1191dc8b3a1e1cdcbcb8c
tree6e7e7e4a5e4be0f907497c81c705a4abd2338556
parent7e6278a706909c8c433377f26aa5165a52edb31a
fileio_types.h : avoid dependency on mem.h

fileio_types.h cannot be parsed by itself
because it relies on basic types defined in `lib/common/mem.h`.
As for #3231, it likely wasn't detected because `mem.h` was probably included before within target files.
But this is not proper.

A "easy" solution would be to add the missing include,
but each dependency should be considered "bad" by default,
and only allowed if it brings some tangible value.

In this case, since these types are only used to declare internal structure variables
which are effectively only flags,
I believe it's really not valuable to add a dependency on `mem.h` for this purpose
while the standard `int` type can do the same job.

I was expecting some compiler warnings following this change,
but it turns out we don't use `-Wconversion` by default on `zstd` source code,
so there is none.

Nevertheless, I enabled `-Wconversion` locally and proceeded to fix a few conversion warnings in the process.

Adding `-Wconversion` to the list of flags used for `zstd` is something I would be favorable over the long term,
but it cannot be done overnight,
because the nb of places where this warning is triggered is daunting.
Better progressively reduce the nb of triggered `-Wconversion` warnings before enabling this flag by default.
programs/fileio.c
programs/fileio.h
programs/fileio_types.h
programs/zstdcli.c