Jens Nerche wrote:
> Looked into sources of kernel 2.3.39 - has to be
>
> if (!create_proc_info_entry("freemware", 0, NULL, (get_info_t
>*)fmw_read_procmem))
>
> in host-linux.c.
No! The argument types really changed -- this is a *bug*, and it is just
due to luck (and the peculiarities of the function calling convention used
by Linux on Intel) that this doesn't crash. Do *not* silence the compiler
warning that points out the bug, *fix* the bug ;-)
Note the function argument types
Linux 2.0.36: int (*get_info)(char *, char **, off_t, int, int);
Linux 2.3.29: typedef int (get_info_t)(char *, char **, off_t, int);
2.3.29 has one argument less. This means that announcing a pointer
to a function with the wrong number of arguments will lead to this
routine being called with one argument less than it expects. Fortunately,
as the Linux kernel uses the cdecl calling convention, the caller itself
cleans up the call stack, so it doesn't crash. Were it using the stdcall
convention, where the callee cleans up by using the ret $nn instruction,
this would crash the kernel.
The correct fix is to have something like
int
#if LINUX_VERSION_CODE >= VERSION_CODE(?,?,?)
fmw_read_procmem(char *buf, char **start, off_t offset,
int len)
#else
fmw_read_procmem(char *buf, char **start, off_t offset,
int len, int unused)
#endif
so that you actually pass a correct function pointer. In this case,
you'll notice that you got it right by the fact that the compiler
warning will disappear ;-)
The only problem is that I'm not sure in which kernel version
the additional argument was removed ...
Bye,
Ulrich
--
Ulrich Weigand,
IMMD 1, Universitaet Erlangen-Nuernberg,
Martensstr. 3, D-91058 Erlangen, Phone: +49 9131 85-27688