On Mon, May 25, 2009 at 12:42 PM, Vipul Jain <vipulsj@xxxxxxxxx> wrote:
In the code, you are just printing a local variable without initializing it. It can contain garbage of the stack and that is why gcc is cribbing.
static int proc_read_xtime(char *page, char **start,
off_t off, int count,
int *eof, void *data)
{
int len;
struct timespec tv;
len = sprintf(page, "xtime : tv_secs = %ld tv_nvsecs = %ld \n",
(long)tv.tv_sec, tv.tv_nsec);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
return len;
Thanks -
Manish
Hi All,
I am trying to learn adding entry in proc file system and currently
using the the example given in
Documentation/DocBook/procfs_example.c. I would like to make a
entry in the proc file system that
will print the struct timespec values on read i.e. cat . I am
getting the following error on compilation
and am confused as everything looks ok to me. I was wondering if
you guys could please help me.
In the code, you are just printing a local variable without initializing it. It can contain garbage of the stack and that is why gcc is cribbing.
static int proc_read_xtime(char *page, char **start,
off_t off, int count,
int *eof, void *data)
{
int len;
struct timespec tv;
len = sprintf(page, "xtime : tv_secs = %ld tv_nvsecs = %ld \n",
(long)tv.tv_sec, tv.tv_nsec);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
return len;
Thanks -
Manish
/home/vipul/linux/ldd/test/procfs_example.c: In function ‘proc_read_xtime’:
/home/vipul/linux/ldd/test/procfs_example.c:68: warning: ‘tv.tv_sec’
is used uninitialized in this function
/home/vipul/linux/ldd/test/procfs_example.c:68: warning: ‘tv.tv_nsec’
is used uninitialized in this function
Building modules, stage 2.
Regards,
Vipul.
--
Thanks -
Manish