Skip to content

Conversation

@stefano-garzarella
Copy link
Contributor

@stefano-garzarella stefano-garzarella commented Nov 12, 2024

If FILE_BACKED_NV is set to NO(0), the delete variable is unused, causing a compiler warning:

Platform/src/NVMem.c: In function ‘_plat__NVDisable’:
Platform/src/NVMem.c:185:9: error: unused variable ‘delete’ [-Werror=unused-variable]
  185 |     int delete = ((intptr_t)platParameter != 0)
      |         ^~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:2674: Platform/src/libplatform_a-NVMem.o] Error 1

Use NOT_REFERENCED() to silence this warning.

stefano-garzarella added a commit to stefano-garzarella/svsm that referenced this pull request Nov 12, 2024
The pthread library is only required for the simulator, but we
don't build it, so let's use this workaround to make the `cofigure`
happy and avoid checks that the pthread is available.

When the  TrustedComputingGroup/TPM#7 will be
merged we can revert this commit and call `./configure --disable-pthread`.

With this patch we can then avoid using our fork in Coconut and switch
to using the upstream version directly (in the next commit).

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
stefano-garzarella added a commit to stefano-garzarella/svsm that referenced this pull request Nov 12, 2024
The next commit switches to TCG TPM, but there is a problem when the
`FILE_BACKED_NV` macro is set to `NO`. It produces the following compile
error because a variable is not used:

    Platform/src/NVMem.c: In function ‘_plat__NVDisable’:
    Platform/src/NVMem.c:185:9: error: unused variable ‘delete’ [-Werror=unused-variable]
      185 |     int delete = ((intptr_t)platParameter != 0)
          |         ^~~~~~
    cc1: all warnings being treated as errors
    make[2]: *** [Makefile:2674: Platform/src/libplatform_a-NVMem.o] Error 1

This commit can be reverted when the following PR will be merged:
TrustedComputingGroup/TPM#7

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
#if FILE_BACKED_NV
if(NULL != s_NvFile)
{
int delete = ((intptr_t)platParameter != 0)
Copy link
Member

Choose a reason for hiding this comment

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

I would rather leave the interpretation of the parameter (the check and cast to boolean) outside the #if because I don't want the meaning of the parameter to depend upon the #ifdef. Instead just add a reference to the variable in a #else (or immediately after calculating it), to silence the warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see.

I'll add NOT_REFERENCED(delete) immediately after calculating it.

stefano-garzarella added a commit to stefano-garzarella/svsm that referenced this pull request Nov 13, 2024
The pthread library is only required for the simulator, but we
don't build it, so let's use this workaround to make the `cofigure`
happy and avoid checks that the pthread is available.

When the  TrustedComputingGroup/TPM#7 will be
merged we can revert this commit and call `./configure --disable-pthread`.

With this patch we can then avoid using our fork in Coconut and switch
to using the upstream version directly (in the next commit).

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
stefano-garzarella added a commit to stefano-garzarella/svsm that referenced this pull request Nov 13, 2024
The next commit switches to TCG TPM, but there is a problem when the
`FILE_BACKED_NV` macro is set to `NO`. It produces the following compile
error because a variable is not used:

    Platform/src/NVMem.c: In function ‘_plat__NVDisable’:
    Platform/src/NVMem.c:185:9: error: unused variable ‘delete’ [-Werror=unused-variable]
      185 |     int delete = ((intptr_t)platParameter != 0)
          |         ^~~~~~
    cc1: all warnings being treated as errors
    make[2]: *** [Makefile:2674: Platform/src/libplatform_a-NVMem.o] Error 1

This commit can be reverted when the following PR will be merged:
TrustedComputingGroup/TPM#7

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
If FILE_BACKED_NV is set to NO(0), the `delete` variable is unused,
causing a compiler warning:

    Platform/src/NVMem.c: In function ‘_plat__NVDisable’:
    Platform/src/NVMem.c:185:9: error: unused variable ‘delete’ [-Werror=unused-variable]
      185 |     int delete = ((intptr_t)platParameter != 0)
          |         ^~~~~~
    cc1: all warnings being treated as errors
    make[2]: *** [Makefile:2674: Platform/src/libplatform_a-NVMem.o] Error 1

Use NOT_REFERENCED() to silence this warning.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
@stefano-garzarella
Copy link
Contributor Author

v2:

  • used NOT_REFERENCED() instead of moving the declaration in the #if [@bradlitterell]

Copy link
Member

@bradlitterell bradlitterell left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

@bradlitterell bradlitterell merged commit f490f00 into TrustedComputingGroup:main Nov 15, 2024
stefano-garzarella added a commit to stefano-garzarella/svsm that referenced this pull request Nov 18, 2024
The pthread library is only required for the simulator, but we
don't build it, so let's use this workaround to make the `configure`
happy and avoid checks that the pthread is available.

When the  TrustedComputingGroup/TPM#7 will be
merged we can revert this commit and call `./configure --disable-pthread`.

With this patch we can then avoid using our fork in Coconut and switch
to using the upstream version directly (in the next commit).

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
stefano-garzarella added a commit to stefano-garzarella/svsm that referenced this pull request Nov 18, 2024
The next commit switches to TCG TPM, but there is a problem when the
`FILE_BACKED_NV` macro is set to `NO`. It produces the following compile
error because a variable is not used:

    Platform/src/NVMem.c: In function ‘_plat__NVDisable’:
    Platform/src/NVMem.c:185:9: error: unused variable ‘delete’ [-Werror=unused-variable]
      185 |     int delete = ((intptr_t)platParameter != 0)
          |         ^~~~~~
    cc1: all warnings being treated as errors
    make[2]: *** [Makefile:2674: Platform/src/libplatform_a-NVMem.o] Error 1

This commit can be reverted when the following PR will be merged:
TrustedComputingGroup/TPM#7

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
stefano-garzarella added a commit to stefano-garzarella/svsm that referenced this pull request Jun 4, 2025
The pthread library is only required by the TPM simulator, which we
don't build (we need only the library). Since libcrt doesn't support
pthreads, and the upstream now supports --disable-pthread
(TrustedComputingGroup/TPM#7), we can safely
disable pthread support at configure time.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
stefano-garzarella added a commit to stefano-garzarella/svsm that referenced this pull request Jun 4, 2025
This reverts commit 5b99b1e.

TrustedComputingGroup/TPM#7 is now merged,
so we can safely drop this workaround, since we disabled pthread
check in the previous commit.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
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.

2 participants