swtpm: Fix issues raised by -Wextra

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2021-06-24 12:55:06 -04:00 committed by Stefan Berger
parent 84c10ba7e4
commit fa2fc871d2
7 changed files with 39 additions and 11 deletions

View File

@ -7,7 +7,9 @@
SUBDIRS = swtpm
noinst_HEADERS = \
compiler_dependencies.h \
sys_dependencies.h
EXTRA_DIST = \
compiler_dependencies.h \
sys_dependencies.h

View File

@ -0,0 +1,17 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* compiler_dependencies.h: Compiler-dependent defines etc.
*
* Author: Stefan Berger, stefanb@linux.ibm.com
*
* Copyright (c) IBM Corporation, 2021
*/
#ifndef _SWTPM_COMPILER_DEPENDENCIES_H
#define _SWTPM_COMPILER_DEPENDENCIES_H
#ifdef __GNUC__ /* gcc and clang */
# define SWTPM_ATTR_UNUSED __attribute__((unused))
#endif
#endif /* _SWTPM_COMPILER_DEPENDENCIES_H */

View File

@ -117,6 +117,7 @@ swtpm_cuse_SOURCES = \
swtpm_cuse_CFLAGS = \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_srcdir)/include/swtpm \
$(GLIB_CFLAGS) \
$(LIBFUSE_CFLAGS) \

View File

@ -41,6 +41,8 @@
#include <stdbool.h>
#include "compiler_dependencies.h"
int handle_log_options(char *options);
int handle_key_options(char *options);
int handle_migration_key_options(char *options);
@ -56,8 +58,8 @@ int handle_flags_options(char *options, bool *need_init_cmd,
#ifdef WITH_SECCOMP
int handle_seccomp_options(char *options, unsigned int *seccomp_action);
#else
static inline int handle_seccomp_options(char *options,
unsigned int *seccomp_action)
static inline int handle_seccomp_options(char *options SWTPM_ATTR_UNUSED,
unsigned int *seccomp_action SWTPM_ATTR_UNUSED)
{
return 0;
}

View File

@ -245,7 +245,8 @@ static const char *usage =
"\n";
static TPM_RESULT
ptm_io_getlocality(TPM_MODIFIER_INDICATOR *loc, uint32_t tpmnum)
ptm_io_getlocality(TPM_MODIFIER_INDICATOR *loc,
uint32_t tpmnum SWTPM_ATTR_UNUSED)
{
*loc = locality;
return TPM_SUCCESS;
@ -396,7 +397,7 @@ static int cached_stateblob_copy(void *dest, size_t destlen,
/*
* worker_thread: the worker thread
*/
static void worker_thread(gpointer data, gpointer user_data)
static void worker_thread(gpointer data, gpointer user_data SWTPM_ATTR_UNUSED)
{
struct thread_message *msg = (struct thread_message *)data;
@ -499,7 +500,8 @@ static void ptm_write_fatal_error_response(TPMLIB_TPMVersion l_tpmversion)
/*
* ptm_send_startup: Send a TPM/TPM2_Startup
*/
static int ptm_send_startup(uint16_t startupType, TPMLIB_TPMVersion l_tpmversion)
static int ptm_send_startup(uint16_t startupType,
TPMLIB_TPMVersion l_tpmversion SWTPM_ATTR_UNUSED)
{
uint32_t command_length;
unsigned char command[sizeof(struct tpm_startup)];
@ -597,8 +599,8 @@ static void ptm_read_stateblob(fuse_req_t req, size_t size)
* Depending on the current state of the transfer interface (read/write)
* return either the results of TPM commands or a data of a TPM state blob.
*/
static void ptm_read(fuse_req_t req, size_t size, off_t off,
struct fuse_file_info *fi)
static void ptm_read(fuse_req_t req, size_t size, off_t off SWTPM_ATTR_UNUSED,
struct fuse_file_info *fi SWTPM_ATTR_UNUSED)
{
switch (tx_state.state) {
case TX_STATE_RW_COMMAND:
@ -918,7 +920,8 @@ cleanup:
* on what is being transferred using the write()
*/
static void ptm_write(fuse_req_t req, const char *buf, size_t size,
off_t off, struct fuse_file_info *fi)
off_t off SWTPM_ATTR_UNUSED,
struct fuse_file_info *fi SWTPM_ATTR_UNUSED)
{
switch (tx_state.state) {
case TX_STATE_RW_COMMAND:
@ -959,7 +962,8 @@ static void ptm_open(fuse_req_t req, struct fuse_file_info *fi)
* needed buffer
*/
static void ptm_ioctl(fuse_req_t req, int cmd, void *arg,
struct fuse_file_info *fi, unsigned flags,
struct fuse_file_info *fi SWTPM_ATTR_UNUSED,
unsigned flags SWTPM_ATTR_UNUSED,
const void *in_buf, size_t in_bufsz, size_t out_bufsz)
{
TPM_RESULT res = TPM_FAIL;

View File

@ -64,6 +64,7 @@
#include "mainloop.h"
#include "utils.h"
#include "sys_dependencies.h"
#include "compiler_dependencies.h"
/* local variables */
static TPM_MODIFIER_INDICATOR locality;
@ -73,7 +74,7 @@ bool mainloop_terminate;
TPM_RESULT
mainloop_cb_get_locality(TPM_MODIFIER_INDICATOR *loc,
uint32_t tpmnum)
uint32_t tpmnum SWTPM_ATTR_UNUSED)
{
*loc = locality;

View File

@ -89,6 +89,7 @@
#include "tpmlib.h"
#include "tlv.h"
#include "utils.h"
#include "compiler_dependencies.h"
/* local structures */
typedef struct {
@ -1394,7 +1395,7 @@ err_exit:
TPM_RESULT SWTPM_NVRAM_SetStateBlob(unsigned char *data,
uint32_t length,
TPM_BOOL is_encrypted,
uint32_t tpm_number,
uint32_t tpm_number SWTPM_ATTR_UNUSED,
uint32_t blobtype)
{
TPM_RESULT res;