CC [M] drivers/mymodule/mymem1.o
drivers/mymodule/mymem1.c: In function ‘mem_read’:
drivers/mymodule/mymem1.c:98: warning: ISO C90 forbids mixed declarations and code
drivers/mymodule/mymem1.c: In function ‘mem_write’:
drivers/mymodule/mymem1.c:125: warning: ISO C90 forbids mixed declarations and code
drivers/mymodule/mymem1.c: In function ‘module_initial’:
drivers/mymodule/mymem1.c:207: warning: ‘memory’ may be used uninitialized in this function
which is exactly the following:
memset(device, 0, sizeof(char) * map_size);
memory->device = device;================> (memory is unitialized)
memory->device = device;================> (memory is unitialized)
correct? sorry if i am wrong....
--
Regards,
Peter Teoh
On Sun, Feb 27, 2011 at 3:52 PM, Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote:
As you can see by yourself, you put many data structures as locals toOn Sun, Feb 27, 2011 at 11:57, Sameer Rahmani <lxsameer@xxxxxxxxx> wrote:
> static int __init module_initial(void)
> {
> dev_t dev;
> int result;
> struct memmap *memory;
>
> if (major)
> {
> dev = MKDEV(major, minor);
> result = register_chrdev_region(dev, 1, "memchar");
> }
> else
> {
> result = alloc_chrdev_region(&dev, minor, 1,
> "memchar");
> major = MAJOR(dev);
>
> }
> if (result < 0)
> {
> printk (KERN_ALERT "Cannot register major number.\n");
> return result;
> }
>
> device = kmalloc(sizeof(char) * map_size, GFP_KERNEL);
> if (! device)
> {
> printk (KERN_ALERT "Allocating device failed.\n");
> result = -ENOMEM;
> goto fail;
> }
>
>
> memset(device, 0, sizeof(char) * map_size);
>
> memory->device = device;
> mem_setup_cdev(memory);
>
>
> printk(KERN_ALERT "Major: %d", major);
> return 0;
>
> fail:
> module_cleanup();
> return result;
> }
module_init. So once module_init is thrashed, those variables/pointers
also gone. Result? Easy to guess...lost reference :)
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
--
Regards,
Peter Teoh
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies