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 the compile error once enabled Werror #11325
Conversation
On 32 bit operating system,size_t is defined as unsigned int, this is the return type of strlen(), but it isn't aligned with the %ld, when compiling, warning will be reported. Change the type to %zu to avoid the warning. Change-Id: I2943d0dfba88ef42892f14230242008473d6263b
We target C89/C90. As far as I know, C90 doesn't know about the z modifier, and so we can't use it. This would mean that all other code making use of TEST_note() with %z needs to be modified. Note that our BIO_*printf() functions can use it, it has it's own implementation, but test_note() ends up calling vfprintf(). |
Actually, we can find many places use %z in OpenSSL for TEST_note(). Example as below:
Fristly we try to use type cast, but to align with the OpenSSL exist style, we change it like this. As we know, %zu is one c99 addition, can anyone help answer whether we are targeting c89/c90, and whether the exist %zu is proper? |
Sorry, do you mean we should discard all of the z% in the OpenSSL code except in the functions BIO_*printf()? |
As far as I can see So, I think actually we are ok. |
The only place where this is not the case is in bioprinttest.c
I of course only found that one, not the one in basic_output.c
|
24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually. |
Hi mattcaswell&t8m, What further actions should I do? @mattcaswell @t8m |
On 32 bit operating system,size_t is defined as unsigned int, this is the return type of strlen(), but it isn't aligned with the %ld, when compiling, warning will be reported. Change the type to %zu to avoid the warning. Change-Id: I2943d0dfba88ef42892f14230242008473d6263b Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from #11325)
Merged to master. Thank you. |
On 32 bit operating system, execute the following command "linux32 ./config -Werror -g3 --prefix=xxx; make", it reported error "type mismatch in the file test/cmp_ctx_test.c: TEST_note("total=%d len=%ld msg='%s'\n", msg_total_size, strlen(msg), msg);".
On 32 bit system, size_t is defined as unsigned int, this is the return type of strlen(), but the code use %ld to printf it, when compiling, type mismatch warning will be reported. For printf, %zu should be the right specifier of size_t, change to avoid the warning.