Skip to content

build: enable -Wcast-qual, fix fallouts - #1527

Closed
vszakats wants to merge 16 commits into
libssh2:masterfrom
vszakats:const
Closed

vszakats wants to merge 16 commits into
libssh2:masterfrom
vszakats:const

Conversation

@vszakats

@vszakats vszakats commented Jan 30, 2025 •

Copy link
Copy Markdown
Member
  • enable compiler warning -Wcast-qual.
  • add LIBSSH2_UNCONST() macro to strip const where absolutely
    necessary to avoid compiler warnings.
  • fix const stripping by constifying where necessary.
  • fix const stripping by using LIBSSH2_UNCONST().
  • libgcrypt.h: drop unnecessary casts.
  • openssl: fix to use new BIO_new_mem_buf() parameter types
    with wolfSSL.

Cherry-picked from #1484

@vszakats vszakats added the build label Jan 30, 2025
```
src/channel.c(371,63): error : cast from 'const char *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
src/channel.c(1046,40): error : cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual]
src/channel.c(1154,40): error : cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual]
src/channel.c(1314,40): error : cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual]
src/channel.c(1578,55): error : cast from 'const char *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
src/channel.c(2486,58): error : cast from 'const char *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
src/comp.c(93,31): error : cast from 'const unsigned char *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
src/openssl.c(81,40): error : cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual]
[...]
```
Some OpenSSL functions are accepting non-const strings,
which need to be fed with literals.

improve LIBSSH2_UNCONST

improve LIBSSH2_UNCONST 2

strip const

strip const

strip const

strip const

strip const

strip const

strip const

strip const

strip const wincng
add const
add missing const

add missing const

add missing const

add missing const

add missing const

add missing const
@vszakats vszakats changed the title build: set -Wcast-qual build: set -Wcast-qual, fix fallouts Jan 30, 2025
OPENSSL_VERSION_NUMBER is set to a conservative value by default in wolfSSL,
but its implementation of this function matches with OpenSSL 1.1.0 and upper.
@vszakats vszakats changed the title build: set -Wcast-qual, fix fallouts build: enable -Wcast-qual, fix fallouts Jan 30, 2025
@vszakats vszakats closed this in 606c102 Jan 30, 2025
@vszakats
vszakats deleted the const branch January 30, 2025 23:57
MingcongBai pushed a commit to AOSC-Tracking/libssh2 that referenced this pull request Jun 26, 2026
- enable compiler warning `-Wcast-qual`.
- add `LIBSSH2_UNCONST()` macro to strip const where absolutely
  necessary to avoid compiler warnings.
- fix const stripping by constifying where necessary.
- fix const stripping by using `LIBSSH2_UNCONST()`.
- libgcrypt.h: drop unnecessary casts.
- openssl: fix to use new `BIO_new_mem_buf()` parameter types
  with wolfSSL.

Cherry-picked from libssh2#1484
Closes libssh2#1527

Signed-off-by: Mingcong Bai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant