svn commit: [26074] trunk/busybox/modutils

vda at busybox.net vda at busybox.net
Sun Apr 12 14:21:30 UTC 2009


Author: vda
Date: 2009-04-12 14:21:29 +0000 (Sun, 12 Apr 2009)
New Revision: 26074

Log:
modutils: small optimization

function                                             old     new   delta
bb_init_module_24                                   4570    4565      -5



Modified:
   trunk/busybox/modutils/modutils-24.c


Changeset:
Modified: trunk/busybox/modutils/modutils-24.c
===================================================================
--- trunk/busybox/modutils/modutils-24.c	2009-04-12 14:00:12 UTC (rev 26073)
+++ trunk/busybox/modutils/modutils-24.c	2009-04-12 14:21:29 UTC (rev 26074)
@@ -3774,19 +3774,14 @@
 	unsigned long m_size;
 	ElfW(Addr) m_addr;
 	struct obj_file *f;
-	struct utsname uts;
 	int exit_status = EXIT_FAILURE;
-	int m_has_modinfo;
 	char *m_name;
 #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
-	char m_strversion[STRVERSIONLEN];
-	int m_version, m_crcs;
+	int m_has_modinfo;
 #endif
 	char *image;
 	size_t image_size = 64 * 1024 * 1024;
 
-	uname(&uts);
-
 	/* Load module into memory and unzip if compressed */
 	image = xmalloc_open_zipped_read_close(m_filename, &image_size);
 	if (!image)
@@ -3798,19 +3793,22 @@
 
 	f = obj_load(image, image_size, LOADBITS);
 
-	m_has_modinfo = (get_modinfo_value(f, "kernel_version") != NULL);
-
 #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
 	/* Version correspondence?  */
+	m_has_modinfo = (get_modinfo_value(f, "kernel_version") != NULL);
 	if (!flag_quiet) {
+		char m_strversion[STRVERSIONLEN];
+		struct utsname uts;
+
 		if (m_has_modinfo) {
-			m_version = new_get_module_version(f, m_strversion);
+			int m_version = new_get_module_version(f, m_strversion);
 			if (m_version == -1) {
-				bb_error_msg_and_die("cannot find the kernel version the module was "
-						"compiled for");
+				bb_error_msg_and_die("cannot find the kernel version "
+					"the module was compiled for");
 			}
 		}
 
+		uname(&uts);
 		if (strncmp(uts.release, m_strversion, STRVERSIONLEN) != 0) {
 			bb_error_msg("%skernel-module version mismatch\n"
 				"\t%s was compiled for kernel version %s\n"
@@ -3821,7 +3819,6 @@
 				goto out;
 		}
 	}
-	k_crcs = 0;
 #endif
 
 	if (query_module(NULL, 0, NULL, 0, NULL))
@@ -3830,12 +3827,13 @@
 	k_crcs = new_is_kernel_checksummed();
 
 #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
-	m_crcs = 0;
-	if (m_has_modinfo)
-		m_crcs = new_is_module_checksummed(f);
-
-	if (m_crcs != k_crcs)
-		obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash);
+	{
+		int m_crcs = 0;
+		if (m_has_modinfo)
+			m_crcs = new_is_module_checksummed(f);
+		if (m_crcs != k_crcs)
+			obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash);
+	}
 #endif
 
 	/* Let the module know about the kernel symbols.  */



More information about the busybox-cvs mailing list