All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Masahiro Yamada <masahiroy@kernel.org>,
	Michal Marek <michal.lkml@markovi.net>,
	Nick Desaulniers <ndesaulniers@google.com>
Subject: [PATCH v2 01/26] modpost: use bool type where appropriate
Date: Sun,  1 May 2022 17:40:07 +0900	[thread overview]
Message-ID: <20220501084032.1025918-2-masahiroy@kernel.org> (raw)
In-Reply-To: <20220501084032.1025918-1-masahiroy@kernel.org>

Use 'bool' to clarify that the valid value is true or false.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2:
  - postpone mod->gpl_compatible change
  - change is_static_library() as well

 scripts/mod/modpost.c    | 56 ++++++++++++++++++++--------------------
 scripts/mod/modpost.h    | 10 +++----
 scripts/mod/sumversion.c |  8 +++---
 3 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 689a34229809..a6035ab78cd8 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -23,20 +23,20 @@
 #include "../../include/linux/license.h"
 
 /* Are we using CONFIG_MODVERSIONS? */
-static int modversions;
+static bool modversions;
 /* Is CONFIG_MODULE_SRCVERSION_ALL set? */
-static int all_versions;
+static bool all_versions;
 /* If we are modposting external module set to 1 */
-static int external_module;
+static bool external_module;
 /* Only warn about unresolved symbols */
-static int warn_unresolved;
+static bool warn_unresolved;
 /* How a symbol is exported */
 static int sec_mismatch_count;
-static int sec_mismatch_warn_only = true;
+static bool sec_mismatch_warn_only = true;
 /* ignore missing files */
-static int ignore_missing_files;
+static bool ignore_missing_files;
 /* If set to 1, only warn (instead of error) about missing ns imports */
-static int allow_missing_ns_imports;
+static bool allow_missing_ns_imports;
 
 static bool error_occurred;
 
@@ -202,11 +202,11 @@ static struct module *new_module(const char *modname)
 struct symbol {
 	struct symbol *next;
 	struct module *module;
-	unsigned int crc;
-	int crc_valid;
 	char *namespace;
-	unsigned int weak:1;
-	unsigned int is_static:1;  /* 1 if symbol is not global */
+	unsigned int crc;
+	bool crc_valid;
+	bool weak;
+	bool is_static;		/* true if symbol is not global */
 	enum export  export;       /* Type of export */
 	char name[];
 };
@@ -230,7 +230,7 @@ static inline unsigned int tdb_hash(const char *name)
  * Allocate a new symbols for use in the hash of exported symbols or
  * the list of unresolved symbols per module
  **/
-static struct symbol *alloc_symbol(const char *name, unsigned int weak,
+static struct symbol *alloc_symbol(const char *name, bool weak,
 				   struct symbol *next)
 {
 	struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
@@ -239,7 +239,7 @@ static struct symbol *alloc_symbol(const char *name, unsigned int weak,
 	strcpy(s->name, name);
 	s->weak = weak;
 	s->next = next;
-	s->is_static = 1;
+	s->is_static = true;
 	return s;
 }
 
@@ -250,7 +250,7 @@ static struct symbol *new_symbol(const char *name, struct module *module,
 	unsigned int hash;
 
 	hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
-	symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]);
+	symbolhash[hash] = alloc_symbol(name, false, symbolhash[hash]);
 
 	return symbolhash[hash];
 }
@@ -424,7 +424,7 @@ static void sym_set_crc(const char *name, unsigned int crc)
 		return;
 
 	s->crc = crc;
-	s->crc_valid = 1;
+	s->crc_valid = true;
 }
 
 static void *grab_file(const char *filename, size_t *size)
@@ -721,9 +721,9 @@ static void handle_symbol(struct module *mod, struct elf_info *info,
 			sym_add_exported(name, mod, export);
 		}
 		if (strcmp(symname, "init_module") == 0)
-			mod->has_init = 1;
+			mod->has_init = true;
 		if (strcmp(symname, "cleanup_module") == 0)
-			mod->has_cleanup = 1;
+			mod->has_cleanup = true;
 		break;
 	}
 }
@@ -2058,7 +2058,7 @@ static void read_symbols(const char *modname)
 						       sym->st_name));
 
 			if (s)
-				s->is_static = 0;
+				s->is_static = false;
 		}
 	}
 
@@ -2078,7 +2078,7 @@ static void read_symbols(const char *modname)
 	 * the automatic versioning doesn't pick it up, but it's really
 	 * important anyhow */
 	if (modversions)
-		mod->unres = alloc_symbol("module_layout", 0, mod->unres);
+		mod->unres = alloc_symbol("module_layout", false, mod->unres);
 }
 
 static void read_symbols_from_files(const char *filename)
@@ -2310,7 +2310,7 @@ static void add_depends(struct buffer *b, struct module *mod)
 		if (s->module->seen)
 			continue;
 
-		s->module->seen = 1;
+		s->module->seen = true;
 		p = strrchr(s->module->name, '/');
 		if (p)
 			p++;
@@ -2427,10 +2427,10 @@ static void read_dump(const char *fname)
 		mod = find_module(modname);
 		if (!mod) {
 			mod = new_module(modname);
-			mod->from_dump = 1;
+			mod->from_dump = true;
 		}
 		s = sym_add_exported(symname, mod, export_no(export));
-		s->is_static = 0;
+		s->is_static = false;
 		sym_set_crc(symname, crc);
 		sym_update_namespace(symname, namespace);
 	}
@@ -2508,7 +2508,7 @@ int main(int argc, char **argv)
 	while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) {
 		switch (opt) {
 		case 'e':
-			external_module = 1;
+			external_module = true;
 			break;
 		case 'i':
 			*dump_read_iter =
@@ -2517,28 +2517,28 @@ int main(int argc, char **argv)
 			dump_read_iter = &(*dump_read_iter)->next;
 			break;
 		case 'm':
-			modversions = 1;
+			modversions = true;
 			break;
 		case 'n':
-			ignore_missing_files = 1;
+			ignore_missing_files = true;
 			break;
 		case 'o':
 			dump_write = optarg;
 			break;
 		case 'a':
-			all_versions = 1;
+			all_versions = true;
 			break;
 		case 'T':
 			files_source = optarg;
 			break;
 		case 'w':
-			warn_unresolved = 1;
+			warn_unresolved = true;
 			break;
 		case 'E':
 			sec_mismatch_warn_only = false;
 			break;
 		case 'N':
-			allow_missing_ns_imports = 1;
+			allow_missing_ns_imports = true;
 			break;
 		case 'd':
 			missing_namespace_deps = optarg;
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 96d6b3a16ca2..7ccfcc8899c1 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -1,4 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -111,11 +112,10 @@ struct module {
 	struct module *next;
 	int gpl_compatible;
 	struct symbol *unres;
-	int from_dump;  /* 1 if module was loaded from *.symvers */
-	int is_vmlinux;
-	int seen;
-	int has_init;
-	int has_cleanup;
+	bool from_dump;		/* true if module was loaded from *.symvers */
+	bool is_vmlinux;
+	bool seen;
+	bool has_init, has_cleanup;
 	struct buffer dev_table_buf;
 	char	     srcversion[25];
 	// Missing namespace dependencies
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index 79bb9eaa65ac..6bf9caca0968 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -290,13 +290,11 @@ static int parse_file(const char *fname, struct md4_ctx *md)
 	return 1;
 }
 /* Check whether the file is a static library or not */
-static int is_static_library(const char *objfile)
+static bool is_static_library(const char *objfile)
 {
 	int len = strlen(objfile);
-	if (objfile[len - 2] == '.' && objfile[len - 1] == 'a')
-		return 1;
-	else
-		return 0;
+
+	return objfile[len - 2] == '.' && objfile[len - 1] == 'a';
 }
 
 /* We have dir/file.o.  Open dir/.file.o.cmd, look for source_ and deps_ line
-- 
2.32.0


  reply	other threads:[~2022-05-01  8:43 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-01  8:40 [PATCH v2 00/26] kbuild: yet another series of cleanups (modpost and LTO) Masahiro Yamada
2022-05-01  8:40 ` Masahiro Yamada [this message]
2022-05-03 21:43   ` [PATCH v2 01/26] modpost: use bool type where appropriate Nick Desaulniers
2022-05-04  5:47     ` Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 02/26] modpost: change mod->gpl_compatible to bool type Masahiro Yamada
2022-05-03 21:45   ` Nick Desaulniers
2022-05-01  8:40 ` [PATCH v2 03/26] modpost: import include/linux/list.h Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 04/26] modpost: traverse modules in order Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 05/26] modpost: add sym_add_unresolved() helper Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 06/26] modpost: traverse unresolved symbols in order Masahiro Yamada
2022-05-03 21:49   ` Nick Desaulniers
2022-05-01  8:40 ` [PATCH v2 07/26] modpost: use doubly linked list for dump_lists Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 08/26] modpost: traverse the namespace_list in order Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 09/26] modpost: dump Module.symvers in the same order of modules.order Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 10/26] modpost: move static EXPORT_SYMBOL check to check_exports() Masahiro Yamada
2022-05-03 21:54   ` Nick Desaulniers
2022-05-01  8:40 ` [PATCH v2 11/26] modpost: make multiple export error Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 12/26] modpost: make sym_add_exported() always allocate a new symbol Masahiro Yamada
2022-05-03 21:56   ` Nick Desaulniers
2022-05-01  8:40 ` [PATCH v2 13/26] modpost: split new_symbol() to symbol allocation and hash table addition Masahiro Yamada
2022-05-03 22:00   ` Nick Desaulniers
2022-05-01  8:40 ` [PATCH v2 14/26] modpost: mitigate false-negatives for static EXPORT_SYMBOL checks Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 15/26] kbuild: record symbol versions in *.cmd files Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 16/26] kbuild: generate a list of objects in vmlinux Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 17/26] modpost: extract symbol versions from *.cmd files Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 18/26] modpost: generate linker script to collect symbol versions Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 19/26] kbuild: embed symbol versions at final link of vmlinux or modules Masahiro Yamada
2022-05-03  2:55   ` Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 20/26] kbuild: stop merging *.symversions Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 21/26] genksyms: adjust the output format for .cmd files Masahiro Yamada
2022-05-04 20:22   ` Nicolas Schier
2022-05-05 13:47     ` Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 22/26] kbuild: do not create *.prelink.o for Clang LTO or IBT Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 23/26] kbuild: make built-in.a rule robust against too long argument error Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 24/26] kbuild: make *.mod " Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 25/26] modpost: simplify the ->is_static initialization Masahiro Yamada
2022-05-01  8:40 ` [PATCH v2 26/26] modpost: use hlist for hash table implementation Masahiro Yamada
2022-05-01 12:23 ` [PATCH v2 00/26] kbuild: yet another series of cleanups (modpost and LTO) Masahiro Yamada
2022-05-05  6:55 ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220501084032.1025918-2-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.