Skip to content

Commit

Permalink
Moving few variables out of global scope and adding -Wall
Browse files Browse the repository at this point in the history
  • Loading branch information
tpiekarski committed Mar 30, 2020
1 parent c184877 commit 7d198d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

SHELL:=/bin/bash

ccflags-y := -Wall

obj-m += lkm_device.o lkm_parameters.o lkm_proc.o lkm_sandbox.o lkm_skeleton.o

all:
Expand Down
7 changes: 5 additions & 2 deletions lkm_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ static int device_open_count = 0;
static char message_buffer[MESSAGE_BUFFER_LENGTH];
static char *message_ptr;

static struct file_operations device_fops = { .open = device_open,
static struct file_operations device_fops = { .owner = THIS_MODULE,
.open = device_open,
.read = device_read,
.release = device_release,
.write = device_write };
struct proc_dir_entry *proc_major_entry;

module_param(param_major_num, int, PARAM_MAJOR_NUM_PERMISSION);

Expand Down Expand Up @@ -182,13 +182,16 @@ static int device_init_sub(void)

static int proc_init_sub(void)
{
struct proc_dir_entry *proc_major_entry = NULL;

printk(KERN_INFO
"lkm_device: Registered sandbox device with major number %d.\n",
major_num);

printk(KERN_INFO
"lkm_device: Creating /proc file %s for storing major number %d.\n",
PROC_FILE_NAME, major_num);

proc_major_entry = proc_create_single(PROC_FILE_NAME, PROC_PERMISSION,
PROC_PARENT, proc_show);

Expand Down
8 changes: 4 additions & 4 deletions lkm_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ static int lkm_proc_show(struct seq_file *seq, void *v);
#define LKM_PROC_PARENT NULL // root of /proc
#define LKM_PROC_PERMISSION 0444

struct proc_dir_entry *lkm_proc_entry;

static int __init lkm_proc_init(void)
{
struct proc_dir_entry *lkm_proc_entry = NULL;

printk(KERN_INFO
"lkm_proc: Initializing module for accessing /proc/%s.\n",
LKM_PROC_FILE_NAME);

lkm_proc_entry =
proc_create_single(LKM_PROC_FILE_NAME, LKM_PROC_PERMISSION,
LKM_PROC_PARENT, lkm_proc_show);
Expand All @@ -61,8 +62,7 @@ static int __init lkm_proc_init(void)

static void __exit lkm_proc_exit(void)
{
printk(KERN_INFO "lkm_proc: Removing /proc/%s.\n",
LKM_PROC_FILE_NAME);
printk(KERN_INFO "lkm_proc: Removing /proc/%s.\n", LKM_PROC_FILE_NAME);

remove_proc_entry(LKM_PROC_FILE_NAME, LKM_PROC_PARENT);
}
Expand Down

0 comments on commit 7d198d3

Please sign in to comment.