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 msvc warnings #4478

Merged
merged 6 commits into from
Dec 17, 2024
Merged

Fix msvc warnings #4478

merged 6 commits into from
Dec 17, 2024

Conversation

weberph2
Copy link
Contributor

@weberph2 weberph2 commented Dec 16, 2024

This fixes build errors/warnings that occur when building --with-tpm2 on Windows.

Environment: Visual Studio 2022 17.12.3, MSVC 14.42.34433, x64, tpm2-tss 4.1.3, nmake & ninja

e.g.: python.exe configure.py --enable-shared --cc=msvc --cpu=x64 --disable-deprecated-features --werror-mode --module-policy=bsi --debug-mode --library-suffix=D --program-suffix=D.exe --msvc-runtime=MDd --with-build-dir=build_debug_symbol --enable-modules=tpm2,tpm2_rsa,tpm2_ecc,tpm2_crypto_backend --with-tpm2 --with-external-includedir=c:/path/to/tpm2-tss/include --with-external-libdir=c:/path/to/tpm2-tss/x64/Debug --define-build-macro NOMINMAX --build-tool=ninja

The following warnings/errors are fixed:

  1. use BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE (warning C4250) for Botan::TPM2::EC_PublicKey and Botan::TPM2::RSA_PublicKey
build_debug_symbol\build\include\public\botan/tpm2_rsa.h(15): error C2220: the following warning is treated as an error
build_debug_symbol\build\include\public\botan/tpm2_rsa.h(15): warning C4250: 'Botan::TPM2::RSA_PublicKey': inherits 'Botan::RSA_PublicKey::Botan::RSA_PublicKey::algo_name' via dominance

build_debug_symbol\build\include\public\botan/ecc_key.h(99): note: see declaration of 'Botan::EC_PublicKey::estimated_strength'
build_debug_symbol\build\include\public\botan/tpm2_ecc.h(16): warning C4250: 'Botan::TPM2::EC_PublicKey': inherits 'Botan::EC_PublicKey::Botan::EC_PublicKey::get_int_field' via dominance
  1. move defaulted move-constructor/-assignment operator from header to source file to fix "deletion of pointer to incomplete type 'Botan::TPM2::Context::Impl'"
error C2027: use of undefined type 'Botan::TPM2::Context::Impl'
botan/tpm2_context.h(155): note: see reference to class template instantiation 'std::unique_ptr<Botan::TPM2::Context::Impl,std::default_delete<Botan::TPM2::Context::Impl>>' being compiled

error C2338: static_assert failed: 'can't delete an incomplete type'
botan/tpm2_context.h(154): note: see declaration of 'Botan::TPM2::Context::Impl'
  1. fix warning C4267: conversion from 'size_t' to '...', possible loss of data
botan/internal/tpm2_util.h(145): warning C4267: '=': conversion from 'size_t' to 'UINT16', possible loss of data
src/lib/prov/tpm2/tpm2_context.cpp(200): warning C4267: '-=': conversion from 'size_t' to 'uint32_t', possible loss of data
src/lib/prov/tpm2/tpm2_rng.cpp(41): warning C4267: 'argument': conversion from 'size_t' to 'UINT16', possible loss of data
src/lib/prov/tpm2/tpm2_key.cpp(125): warning C4267: '=': conversion from 'size_t' to 'UINT16', possible loss of data
  1. remove duplicate return statement (fixes warning C4702: unreachable code)
src\lib\prov\tpm2\tpm2_hash.cpp(50) : warning C4702: unreachable code

/cc @FAlbertDev @reneme @atreiber94

@coveralls
Copy link

coveralls commented Dec 16, 2024

Coverage Status

coverage: 91.262% (+0.003%) from 91.259%
when pulling b307ce8 on weberph2:fix-msvc-warnings
into 6943449 on randombit:master.

@weberph2 weberph2 marked this pull request as ready for review December 16, 2024 13:56
Copy link
Owner

@randombit randombit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond the open discussion issue, lgtm.

Copy link
Collaborator

@FAlbertDev FAlbertDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes since my last review look good to me 😉

@randombit randombit merged commit eadd6b1 into randombit:master Dec 17, 2024
38 checks passed
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.

4 participants