Commit 58e01fca authored by Masahiro Yamada's avatar Masahiro Yamada

modpost: use bool type where appropriate

Use 'bool' to clarify that the valid value is true or false.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent 63cbee7f
...@@ -23,20 +23,20 @@ ...@@ -23,20 +23,20 @@
#include "../../include/linux/license.h" #include "../../include/linux/license.h"
/* Are we using CONFIG_MODVERSIONS? */ /* Are we using CONFIG_MODVERSIONS? */
static int modversions; static bool modversions;
/* Is CONFIG_MODULE_SRCVERSION_ALL set? */ /* Is CONFIG_MODULE_SRCVERSION_ALL set? */
static int all_versions; static bool all_versions;
/* If we are modposting external module set to 1 */ /* If we are modposting external module set to 1 */
static int external_module; static bool external_module;
/* Only warn about unresolved symbols */ /* Only warn about unresolved symbols */
static int warn_unresolved; static bool warn_unresolved;
/* How a symbol is exported */ /* How a symbol is exported */
static int sec_mismatch_count; static int sec_mismatch_count;
static int sec_mismatch_warn_only = true; static bool sec_mismatch_warn_only = true;
/* ignore missing files */ /* 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 */ /* 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; static bool error_occurred;
...@@ -202,11 +202,11 @@ static struct module *new_module(const char *modname) ...@@ -202,11 +202,11 @@ static struct module *new_module(const char *modname)
struct symbol { struct symbol {
struct symbol *next; struct symbol *next;
struct module *module; struct module *module;
unsigned int crc;
int crc_valid;
char *namespace; char *namespace;
unsigned int weak:1; unsigned int crc;
unsigned int is_static:1; /* 1 if symbol is not global */ bool crc_valid;
bool weak;
bool is_static; /* true if symbol is not global */
enum export export; /* Type of export */ enum export export; /* Type of export */
char name[]; char name[];
}; };
...@@ -230,7 +230,7 @@ static inline unsigned int tdb_hash(const 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 * Allocate a new symbols for use in the hash of exported symbols or
* the list of unresolved symbols per module * 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 *next)
{ {
struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1)); 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, ...@@ -239,7 +239,7 @@ static struct symbol *alloc_symbol(const char *name, unsigned int weak,
strcpy(s->name, name); strcpy(s->name, name);
s->weak = weak; s->weak = weak;
s->next = next; s->next = next;
s->is_static = 1; s->is_static = true;
return s; return s;
} }
...@@ -250,7 +250,7 @@ static struct symbol *new_symbol(const char *name, struct module *module, ...@@ -250,7 +250,7 @@ static struct symbol *new_symbol(const char *name, struct module *module,
unsigned int hash; unsigned int hash;
hash = tdb_hash(name) % SYMBOL_HASH_SIZE; 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]; return symbolhash[hash];
} }
...@@ -424,7 +424,7 @@ static void sym_set_crc(const char *name, unsigned int crc) ...@@ -424,7 +424,7 @@ static void sym_set_crc(const char *name, unsigned int crc)
return; return;
s->crc = crc; s->crc = crc;
s->crc_valid = 1; s->crc_valid = true;
} }
static void *grab_file(const char *filename, size_t *size) 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, ...@@ -721,9 +721,9 @@ static void handle_symbol(struct module *mod, struct elf_info *info,
sym_add_exported(name, mod, export); sym_add_exported(name, mod, export);
} }
if (strcmp(symname, "init_module") == 0) if (strcmp(symname, "init_module") == 0)
mod->has_init = 1; mod->has_init = true;
if (strcmp(symname, "cleanup_module") == 0) if (strcmp(symname, "cleanup_module") == 0)
mod->has_cleanup = 1; mod->has_cleanup = true;
break; break;
} }
} }
...@@ -2058,7 +2058,7 @@ static void read_symbols(const char *modname) ...@@ -2058,7 +2058,7 @@ static void read_symbols(const char *modname)
sym->st_name)); sym->st_name));
if (s) if (s)
s->is_static = 0; s->is_static = false;
} }
} }
...@@ -2078,7 +2078,7 @@ static void read_symbols(const char *modname) ...@@ -2078,7 +2078,7 @@ static void read_symbols(const char *modname)
* the automatic versioning doesn't pick it up, but it's really * the automatic versioning doesn't pick it up, but it's really
* important anyhow */ * important anyhow */
if (modversions) 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) static void read_symbols_from_files(const char *filename)
...@@ -2310,7 +2310,7 @@ static void add_depends(struct buffer *b, struct module *mod) ...@@ -2310,7 +2310,7 @@ static void add_depends(struct buffer *b, struct module *mod)
if (s->module->seen) if (s->module->seen)
continue; continue;
s->module->seen = 1; s->module->seen = true;
p = strrchr(s->module->name, '/'); p = strrchr(s->module->name, '/');
if (p) if (p)
p++; p++;
...@@ -2427,10 +2427,10 @@ static void read_dump(const char *fname) ...@@ -2427,10 +2427,10 @@ static void read_dump(const char *fname)
mod = find_module(modname); mod = find_module(modname);
if (!mod) { if (!mod) {
mod = new_module(modname); mod = new_module(modname);
mod->from_dump = 1; mod->from_dump = true;
} }
s = sym_add_exported(symname, mod, export_no(export)); s = sym_add_exported(symname, mod, export_no(export));
s->is_static = 0; s->is_static = false;
sym_set_crc(symname, crc); sym_set_crc(symname, crc);
sym_update_namespace(symname, namespace); sym_update_namespace(symname, namespace);
} }
...@@ -2508,7 +2508,7 @@ int main(int argc, char **argv) ...@@ -2508,7 +2508,7 @@ int main(int argc, char **argv)
while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) { while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) {
switch (opt) { switch (opt) {
case 'e': case 'e':
external_module = 1; external_module = true;
break; break;
case 'i': case 'i':
*dump_read_iter = *dump_read_iter =
...@@ -2517,28 +2517,28 @@ int main(int argc, char **argv) ...@@ -2517,28 +2517,28 @@ int main(int argc, char **argv)
dump_read_iter = &(*dump_read_iter)->next; dump_read_iter = &(*dump_read_iter)->next;
break; break;
case 'm': case 'm':
modversions = 1; modversions = true;
break; break;
case 'n': case 'n':
ignore_missing_files = 1; ignore_missing_files = true;
break; break;
case 'o': case 'o':
dump_write = optarg; dump_write = optarg;
break; break;
case 'a': case 'a':
all_versions = 1; all_versions = true;
break; break;
case 'T': case 'T':
files_source = optarg; files_source = optarg;
break; break;
case 'w': case 'w':
warn_unresolved = 1; warn_unresolved = true;
break; break;
case 'E': case 'E':
sec_mismatch_warn_only = false; sec_mismatch_warn_only = false;
break; break;
case 'N': case 'N':
allow_missing_ns_imports = 1; allow_missing_ns_imports = true;
break; break;
case 'd': case 'd':
missing_namespace_deps = optarg; missing_namespace_deps = optarg;
......
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -113,11 +114,11 @@ struct module { ...@@ -113,11 +114,11 @@ struct module {
struct module *next; struct module *next;
int gpl_compatible; int gpl_compatible;
struct symbol *unres; struct symbol *unres;
int from_dump; /* 1 if module was loaded from *.symvers */ bool from_dump; /* true if module was loaded from *.symvers */
int is_vmlinux; bool is_vmlinux;
int seen; bool seen;
int has_init; bool has_init;
int has_cleanup; bool has_cleanup;
struct buffer dev_table_buf; struct buffer dev_table_buf;
char srcversion[25]; char srcversion[25];
// Missing namespace dependencies // Missing namespace dependencies
......
...@@ -290,13 +290,11 @@ static int parse_file(const char *fname, struct md4_ctx *md) ...@@ -290,13 +290,11 @@ static int parse_file(const char *fname, struct md4_ctx *md)
return 1; return 1;
} }
/* Check whether the file is a static library or not */ /* 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); int len = strlen(objfile);
if (objfile[len - 2] == '.' && objfile[len - 1] == 'a')
return 1; return objfile[len - 2] == '.' && objfile[len - 1] == 'a';
else
return 0;
} }
/* We have dir/file.o. Open dir/.file.o.cmd, look for source_ and deps_ line /* We have dir/file.o. Open dir/.file.o.cmd, look for source_ and deps_ line
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment