Skip to content

Commit 64282a7

Browse files
nathanchancegregkh
authored andcommitted
extract-cert: Wrap key_pass with '#ifdef USE_PKCS11_ENGINE'
commit 4f96b7c upstream. A recent strengthening of -Wunused-but-set-variable (enabled with -Wall) in clang under a new subwarning, -Wunused-but-set-global, points out an unused static global variable in certs/extract-cert.c: certs/extract-cert.c:46:20: error: variable 'key_pass' set but not used [-Werror,-Wunused-but-set-global] 46 | static const char *key_pass; | ^ After commit 558bdc4 ("sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3"), key_pass is only used with the OpenSSL engine API, not the new provider API. Wrap key_pass's declaration and assignment with '#ifdef USE_PKCS11_ENGINE' so that it is only included with its use to clear up the warning. While this is a little uglier than just marking key_pass with the unused attribute, this will make it easier to clean up all code associated with the use of the engine API if it were ever removed in the future. While in the area, use a tab for the key_pass assignment line to match the rest of the file. Cc: stable@vger.kernel.org Fixes: 558bdc4 ("sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3") Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nick Desaulniers <ndesaulniers@google.com> Link: https://patch.msgid.link/20260325-certs-extract-cert-key_pass-unused-but-set-global-v1-1-ecf94326d532@kernel.org Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4b2738b commit 64282a7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

certs/extract-cert.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ void format(void)
4343
exit(2);
4444
}
4545

46+
#ifdef USE_PKCS11_ENGINE
4647
static const char *key_pass;
48+
#endif
4749
static BIO *wb;
4850
static char *cert_dst;
4951
static bool verbose;
@@ -135,7 +137,9 @@ int main(int argc, char **argv)
135137
if (verbose_env && strchr(verbose_env, '1'))
136138
verbose = true;
137139

138-
key_pass = getenv("KBUILD_SIGN_PIN");
140+
#ifdef USE_PKCS11_ENGINE
141+
key_pass = getenv("KBUILD_SIGN_PIN");
142+
#endif
139143

140144
if (argc != 3)
141145
format();

0 commit comments

Comments
 (0)