Hi,
resend corrected patch because I missed to move the uts var declaration
also inside the ifdef block.
Denys Vlasenko schrieb:
> On Thursday 02 April 2009 00:50, Guenter wrote:
>> Hi Denys,
>> Guenter schrieb:
>> but while reading through the code here some other observasions/questions:
>>
>> uname(&uts);
>> is called always directly at beginning although the uts struct is only
>> used within '#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING/#endif' --
>> shouldnt we move it just inside the #if block?
>>
>> I think same applies to m_has_modinfo too:
>> m_has_modinfo = (get_modinfo_value(f, "kernel_version") != NULL);
>> is just before the #if block where it is used...
>>
>> if the feature ENABLE_FEATURE_INSMOD_VERSION_CHECKING is disabled then
>> these calls are wasted cpu cycles...
>
> Feel free to send a patch which fixes this.
ok, here's the follow-up patch against recent svn - attached.
greetz, Guen.
--- modutils/modutils-24.c~ 2009-04-06 01:43:36.000000000 +0200
+++ modutils/modutils-24.c 2009-04-06 02:49:18.000000000 +0200
@@ -3774,19 +3774,16 @@
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
+ struct utsname uts;
char m_strversion[STRVERSIONLEN];
- int m_version, m_crcs;
+ int m_has_modinfo, m_version, m_crcs;
#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,10 +3795,9 @@
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) {
if (m_has_modinfo) {
m_version = new_get_module_version(f, m_strversion);
@@ -3811,6 +3807,7 @@
}
}
+ 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"
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox