modutils-24: use xasprintf and xzalloc where appropriate,
 remove unreachanble code
build system: correct some dependencies in config system
init: convert one #if into if() - for Rob.

function                                             old     new   delta
obj_string_patch                                     136     129      -7
bb_init_module_24                                   4759    4615    -144
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-151)           Total: -151 bytes

diff --git a/modutils/Config.in b/modutils/Config.in
index e7b839d..ce3bce1 100644
--- a/modutils/Config.in
+++ b/modutils/Config.in
@@ -5,20 +5,6 @@
 
 menu "Linux Module Utilities"
 
-config DEFAULT_MODULES_DIR
-	string "Default directory containing modules"
-	default "/lib/modules"
-	help
-	  Directory that contains kernel modules.
-	  Defaults to "/lib/modules"
-
-config DEFAULT_DEPMOD_FILE
-	string "Default name of modules.dep"
-	default "modules.dep"
-	help
-	  Filename that contains kernel modules dependencies.
-	  Defaults to "modules.dep"
-
 config MODPROBE_SMALL
 	bool "Simplified modutils"
 	default n
@@ -193,7 +179,7 @@
 config FEATURE_CHECK_TAINTED_MODULE
 	bool "Support tainted module checking with new kernels"
 	default y
-	depends on !MODPROBE_SMALL
+	depends on (LSMOD || FEATURE_2_4_MODULES) && !MODPROBE_SMALL
 	help
 	  Support checking for tainted modules. These are usually binary
 	  only modules that will make the linux-kernel list ignore your
@@ -227,4 +213,20 @@
 
 	  Say Y if unsure.
 
+config DEFAULT_MODULES_DIR
+	string "Default directory containing modules"
+	default "/lib/modules"
+	depends on DEPMOD || MODPROBE || MODPROBE_SMALL
+	help
+	  Directory that contains kernel modules.
+	  Defaults to "/lib/modules"
+
+config DEFAULT_DEPMOD_FILE
+	string "Default name of modules.dep"
+	default "modules.dep"
+	depends on DEPMOD || MODPROBE || MODPROBE_SMALL
+	help
+	  Filename that contains kernel modules dependencies.
+	  Defaults to "modules.dep"
+
 endmenu
diff --git a/modutils/modutils-24.c b/modutils/modutils-24.c
index 7c75686..4e112a0 100644
--- a/modutils/modutils-24.c
+++ b/modutils/modutils-24.c
@@ -646,7 +646,7 @@
 static void arch_create_got(struct obj_file *f);
 #if ENABLE_FEATURE_CHECK_TAINTED_MODULE
 static int obj_gpl_license(struct obj_file *f, const char **license);
-#endif /* FEATURE_CHECK_TAINTED_MODULE */
+#endif
 #endif /* obj.h */
 //----------------------------------------------------------------------------
 //--------end of modutils obj.h
@@ -1687,11 +1687,11 @@
 	}
 
 	if (pe == NULL) {
-		pe = xmalloc(sizeof(struct arch_list_entry));
+		pe = xzalloc(sizeof(struct arch_list_entry));
 		pe->next = *list;
 		pe->addend = rel->r_addend;
 		pe->offset = offset;
-		pe->inited = 0;
+		/*pe->inited = 0;*/
 		*list = pe;
 		return size;
 	}
@@ -2255,7 +2255,7 @@
 		strcpy(name_buf, SYMBOL_PREFIX);
 		strcpy(name_buf + extra - 1, name);
 		name = name_buf;
-#endif /* SYMBOL_PREFIX */
+#endif
 
 		sym = obj_find_symbol(f, name);
 		if (sym && !(ELF_ST_BIND(sym->info) == STB_LOCAL)) {
@@ -2618,7 +2618,8 @@
 
 	/* Collect the kernel's symbols.  */
 
-	syms = xmalloc(bufsize = 16 * 1024);
+	bufsize = 16 * 1024;
+	syms = xmalloc(bufsize);
  retry_kern_sym_load:
 	if (query_module(NULL, QM_SYMBOLS, syms, bufsize, &ret)) {
 		if (errno == ENOSPC && bufsize < ret) {
@@ -2802,10 +2803,8 @@
 		module->ndeps = n_ext_modules_used;
 	}
 
-	module->init =
-		obj_symbol_final_value(f, obj_find_symbol(f, SPFX "init_module"));
-	module->cleanup =
-		obj_symbol_final_value(f, obj_find_symbol(f, SPFX "cleanup_module"));
+	module->init = obj_symbol_final_value(f, obj_find_symbol(f, SPFX "init_module"));
+	module->cleanup = obj_symbol_final_value(f, obj_find_symbol(f, SPFX "cleanup_module"));
 
 	sec = obj_find_section(f, "__ex_table");
 	if (sec) {
@@ -2863,7 +2862,7 @@
 	size_t len = strlen(string) + 1;
 	char *loc;
 
-	p = xmalloc(sizeof(*p));
+	p = xzalloc(sizeof(*p));
 	p->next = f->string_patches;
 	p->reloc_secidx = secidx;
 	p->reloc_offset = offset;
@@ -2872,7 +2871,7 @@
 	strsec = obj_find_section(f, ".kstrtab");
 	if (strsec == NULL) {
 		strsec = obj_create_alloced_section(f, ".kstrtab", 1, len);
-		p->string_offset = 0;
+		/*p->string_offset = 0;*/
 		loc = strsec->contents;
 	} else {
 		p->string_offset = strsec->header.sh_size;
@@ -2925,38 +2924,37 @@
 
 	for (i = 0; i < HASH_BUCKETS; ++i) {
 		struct obj_symbol *sym;
-		for (sym = f->symtab[i]; sym; sym = sym->next)
+		for (sym = f->symtab[i]; sym; sym = sym->next) {
 			if (sym->secidx == SHN_COMMON) {
 				/* Collect all COMMON symbols and sort them by size so as to
 				   minimize space wasted by alignment requirements.  */
-				{
-					struct common_entry **p, *n;
-					for (p = &common_head; *p; p = &(*p)->next)
-						if (sym->size <= (*p)->sym->size)
-							break;
-
-					n = alloca(sizeof(*n));
-					n->next = *p;
-					n->sym = sym;
-					*p = n;
-				}
+				struct common_entry **p, *n;
+				for (p = &common_head; *p; p = &(*p)->next)
+					if (sym->size <= (*p)->sym->size)
+						break;
+				n = alloca(sizeof(*n));
+				n->next = *p;
+				n->sym = sym;
+				*p = n;
 			}
+		}
 	}
 
 	for (i = 1; i < f->local_symtab_size; ++i) {
 		struct obj_symbol *sym = f->local_symtab[i];
 		if (sym && sym->secidx == SHN_COMMON) {
 			struct common_entry **p, *n;
-			for (p = &common_head; *p; p = &(*p)->next)
+			for (p = &common_head; *p; p = &(*p)->next) {
 				if (sym == (*p)->sym)
 					break;
-				else if (sym->size < (*p)->sym->size) {
+				if (sym->size < (*p)->sym->size) {
 					n = alloca(sizeof(*n));
 					n->next = *p;
 					n->sym = sym;
 					*p = n;
 					break;
 				}
+			}
 		}
 	}
 
@@ -3546,16 +3544,13 @@
 		case 1:
 			set_tainted(fd, m_name, kernel_has_tainted, TAINT_PROPRIETORY_MODULE, "no license", "");
 			break;
-		case 2:
+		default: /* case 2: */
 			/* The module has a non-GPL license so we pretend that the
 			 * kernel always has a taint flag to get a warning even on
 			 * kernels without the proc flag.
 			 */
 			set_tainted(fd, m_name, 1, TAINT_PROPRIETORY_MODULE, "non-GPL license - ", ptr);
 			break;
-		default:
-			set_tainted(fd, m_name, 1, TAINT_PROPRIETORY_MODULE, "Unexpected return from obj_gpl_license", "");
-			break;
 	}
 
 	if (flag_force_load)
@@ -3564,9 +3559,9 @@
 	if (fd >= 0)
 		close(fd);
 }
-#else /* FEATURE_CHECK_TAINTED_MODULE */
+#else /* !FEATURE_CHECK_TAINTED_MODULE */
 #define check_tainted_module(x, y) do { } while (0);
-#endif /* FEATURE_CHECK_TAINTED_MODULE */
+#endif
 
 #if ENABLE_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
 /* add module source, timestamp, kernel version and a symbol for the
@@ -3581,10 +3576,10 @@
 {
 #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
 	return new_get_module_version(f, str);
-#else  /* FEATURE_INSMOD_VERSION_CHECKING */
+#else
 	strncpy(str, "???", sizeof(str));
 	return -1;
-#endif /* FEATURE_INSMOD_VERSION_CHECKING */
+#endif
 }
 
 /* add module source, timestamp, kernel version and a symbol for the
@@ -3609,7 +3604,7 @@
 	char *name, *absolute_filename;
 	char str[STRVERSIONLEN];
 	unsigned i;
-	int l, lm_name, lfilename, use_ksymtab, version;
+	int lm_name, lfilename, use_ksymtab, version;
 	struct stat statbuf;
 
 	/* WARNING: was using realpath, but replaced by readlink to stop using
@@ -3634,20 +3629,10 @@
 		 * is 0xffffff, decimal 16777215.  putting all three fields in
 		 * one symbol is less readable but saves kernel space.
 		 */
-		l = sizeof(symprefix) +                 /* "__insmod_" */
-			lm_name +                       /* module name */
-			2 +                             /* "_O" */
-			lfilename +                     /* object filename */
-			2 +                             /* "_M" */
-			2 * sizeof(statbuf.st_mtime) +  /* mtime in hex */
-			2 +                             /* "_V" */
-			8 +                             /* version in dec */
-			1;                              /* nul */
-		name = xmalloc(l);
 		if (stat(absolute_filename, &statbuf) != 0)
 			statbuf.st_mtime = 0;
 		version = get_module_version(f, str);	/* -1 if not found */
-		snprintf(name, l, "%s%s_O%s_M%0*lX_V%d",
+		name = xasprintf("%s%s_O%s_M%0*lX_V%d",
 				symprefix, m_name, absolute_filename,
 				(int)(2 * sizeof(statbuf.st_mtime)), statbuf.st_mtime,
 				version);
@@ -3662,34 +3647,20 @@
 	/* record where the persistent data is going, same address as previous symbol */
 
 	if (f->persist) {
-		l = sizeof(symprefix) +         /* "__insmod_" */
-			lm_name +               /* module name */
-			2 +                     /* "_P" */
-			strlen(f->persist) +    /* data store */
-			1;                      /* nul */
-		name = xmalloc(l);
-		snprintf(name, l, "%s%s_P%s",
+		name = xasprintf("%s%s_P%s",
 				symprefix, m_name, f->persist);
 		sym = obj_add_symbol(f, name, -1, ELF_ST_INFO(STB_GLOBAL, STT_NOTYPE),
 				sec->idx, sec->header.sh_addr, 0);
 		if (use_ksymtab)
 			new_add_ksymtab(f, sym);
 	}
-#endif /* _NOT_SUPPORTED_ */
+#endif
 	/* tag the desired sections if size is non-zero */
 
 	for (i = 0; i < ARRAY_SIZE(section_names); ++i) {
 		sec = obj_find_section(f, section_names[i]);
 		if (sec && sec->header.sh_size) {
-			l = sizeof(symprefix) +         /* "__insmod_" */
-				lm_name +               /* module name */
-				2 +                     /* "_S" */
-				strlen(sec->name) +     /* section name */
-				2 +                     /* "_L" */
-				8 +                     /* length in dec */
-				1;                      /* nul */
-			name = xmalloc(l);
-			snprintf(name, l, "%s%s_S%s_L%ld",
+			name = xasprintf("%s%s_S%s_L%ld",
 					symprefix, m_name, sec->name,
 					(long)sec->header.sh_size);
 			sym = obj_add_symbol(f, name, -1, ELF_ST_INFO(STB_GLOBAL, STT_NOTYPE),
@@ -3855,7 +3826,7 @@
 		}
 	}
 	k_crcs = 0;
-#endif /* FEATURE_INSMOD_VERSION_CHECKING */
+#endif
 
 	if (query_module(NULL, 0, NULL, 0, NULL))
 		bb_error_msg_and_die("not configured to support old kernels");
@@ -3869,7 +3840,7 @@
 
 	if (m_crcs != k_crcs)
 		obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash);
-#endif /* FEATURE_INSMOD_VERSION_CHECKING */
+#endif
 
 	/* Let the module know about the kernel symbols.  */
 	add_kernel_symbols(f);
@@ -3889,7 +3860,7 @@
 
 #if ENABLE_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
 	add_ksymoops_symbols(f, m_filename, m_name);
-#endif /* FEATURE_INSMOD_KSYMOOPS_SYMBOLS */
+#endif
 
 	new_create_module_ksymtab(f);