diff mbox series

certs/extract-cert: Fix checkpatch issues

Message ID 20230601190508.56610-1-franziska.naepelt@gmail.com (mailing list archive)
State New
Headers show
Series certs/extract-cert: Fix checkpatch issues | expand

Commit Message

Franziska Näpelt June 1, 2023, 7:05 p.m. UTC
The following issues are fixed:
- WARNING: Missing or malformed SPDX-License-Identifier tag
- WARNING: Prefer __noreturn over __attribute__((noreturn))
- ERROR: trailing statements should be on next line
- WARNING: braces {} are not necessary for single statement blocks
- ERROR: space required before the open parenthesis '('
- ERROR: code indent should use tabs where possible
- WARNING: please, no spaces at the start of a line
- WARNING: Missing a blank line after declarations

Signed-off-by: Franziska Naepelt <franziska.naepelt@gmail.com>
---
 certs/extract-cert.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)


base-commit: 7877cb91f1081754a1487c144d85dc0d2e2e7fc4
--
2.39.2 (Apple Git-143)

Comments

kernel test robot June 2, 2023, 2:27 a.m. UTC | #1
Hi Franziska,

kernel test robot noticed the following build errors:

[auto build test ERROR on 7877cb91f1081754a1487c144d85dc0d2e2e7fc4]

url:    https://github.com/intel-lab-lkp/linux/commits/Franziska-Naepelt/certs-extract-cert-Fix-checkpatch-issues/20230602-030657
base:   7877cb91f1081754a1487c144d85dc0d2e2e7fc4
patch link:    https://lore.kernel.org/r/20230601190508.56610-1-franziska.naepelt%40gmail.com
patch subject: [PATCH] certs/extract-cert: Fix checkpatch issues
config: mips-buildonly-randconfig-r002-20230602 (https://download.01.org/0day-ci/archive/20230602/202306021040.UTvXfH5J-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 4faf3aaf28226a4e950c103a14f6fc1d1fdabb1b)
reproduce (this is a W=1 build):
        mkdir -p ~/bin
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mipsel-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/7fdfaec7a3c9f58676a5892e679d8bca319abd8a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Franziska-Naepelt/certs-extract-cert-Fix-checkpatch-issues/20230602-030657
        git checkout 7fdfaec7a3c9f58676a5892e679d8bca319abd8a
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=mips olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306021040.UTvXfH5J-lkp@intel.com/

All errors (new ones prefixed by >>):

>> certs/extract-cert.c:36:8: error: unknown type name '__noreturn'
   static __noreturn
          ^
   1 error generated.


vim +/__noreturn +36 certs/extract-cert.c

    35	
  > 36	static __noreturn
    37	void format(void)
    38	{
    39		fprintf(stderr,
    40			"Usage: extract-cert <source> <dest>\n");
    41		exit(2);
    42	}
    43
kernel test robot June 2, 2023, 3:09 a.m. UTC | #2
Hi Franziska,

kernel test robot noticed the following build errors:

[auto build test ERROR on 7877cb91f1081754a1487c144d85dc0d2e2e7fc4]

url:    https://github.com/intel-lab-lkp/linux/commits/Franziska-Naepelt/certs-extract-cert-Fix-checkpatch-issues/20230602-030657
base:   7877cb91f1081754a1487c144d85dc0d2e2e7fc4
patch link:    https://lore.kernel.org/r/20230601190508.56610-1-franziska.naepelt%40gmail.com
patch subject: [PATCH] certs/extract-cert: Fix checkpatch issues
config: arm-randconfig-r046-20230531 (https://download.01.org/0day-ci/archive/20230602/202306021102.zQU95cMI-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.3.0
reproduce (this is a W=1 build):
        mkdir -p ~/bin
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/7fdfaec7a3c9f58676a5892e679d8bca319abd8a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Franziska-Naepelt/certs-extract-cert-Fix-checkpatch-issues/20230602-030657
        git checkout 7fdfaec7a3c9f58676a5892e679d8bca319abd8a
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=arm olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306021102.zQU95cMI-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> certs/extract-cert.c:36:18: error: expected ';' before 'void'
      36 | static __noreturn
         |                  ^
         |                  ;
      37 | void format(void)
         | ~~~~              
>> certs/extract-cert.c:37:6: warning: no previous prototype for 'format' [-Wmissing-prototypes]
      37 | void format(void)
         |      ^~~~~~


vim +36 certs/extract-cert.c

    35	
  > 36	static __noreturn
  > 37	void format(void)
    38	{
    39		fprintf(stderr,
    40			"Usage: extract-cert <source> <dest>\n");
    41		exit(2);
    42	}
    43
diff mbox series

Patch

diff --git a/certs/extract-cert.c b/certs/extract-cert.c
index 70e9ec89d87d..dd76fb0f7f8d 100644
--- a/certs/extract-cert.c
+++ b/certs/extract-cert.c
@@ -1,3 +1,4 @@ 
+// SPDX-License-Identifier: LGPL-2.1
 /* Extract X.509 certificate in DER form from PKCS#11 or PEM.
  *
  * Copyright © 2014-2015 Red Hat, Inc. All Rights Reserved.
@@ -32,7 +33,7 @@ 

 #define PKEY_ID_PKCS7 2

-static __attribute__((noreturn))
+static __noreturn
 void format(void)
 {
 	fprintf(stderr,
@@ -63,7 +64,8 @@  static void drain_openssl_errors(void)

 	if (ERR_peek_error() == 0)
 		return;
-	while (ERR_get_error_line(&file, &line)) {}
+	while (ERR_get_error_line(&file, &line))
+		;
 }

 #define ERR(cond, fmt, ...)				\
@@ -73,7 +75,7 @@  static void drain_openssl_errors(void)
 		if (__cond) {				\
 			err(1, fmt, ## __VA_ARGS__);	\
 		}					\
-	} while(0)
+	} while (0)

 static const char *key_pass;
 static BIO *wb;
@@ -107,7 +109,7 @@  int main(int argc, char **argv)
 	if (verbose_env && strchr(verbose_env, '1'))
 		verbose = true;

-        key_pass = getenv("KBUILD_SIGN_PIN");
+	key_pass = getenv("KBUILD_SIGN_PIN");

 	if (argc != 3)
 		format();
@@ -118,6 +120,7 @@  int main(int argc, char **argv)
 	if (!cert_src[0]) {
 		/* Invoked with no input; create empty file */
 		FILE *f = fopen(cert_dst, "wb");
+
 		ERR(!f, "%s", cert_dst);
 		fclose(f);
 		exit(0);
@@ -155,6 +158,7 @@  int main(int argc, char **argv)
 			x509 = PEM_read_bio_X509(b, NULL, NULL, NULL);
 			if (wb && !x509) {
 				unsigned long err = ERR_peek_last_error();
+
 				if (ERR_GET_LIB(err) == ERR_LIB_PEM &&
 				    ERR_GET_REASON(err) == PEM_R_NO_START_LINE) {
 					ERR_clear_error();