Commit 8fbe71f0 authored by Tetsuo Handa's avatar Tetsuo Handa Committed by James Morris

TOMOYO: Make read function to void.

Read functions do not fail. Make them from int to void.
Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent cb917cf5
...@@ -352,14 +352,12 @@ static int tomoyo_write_profile(struct tomoyo_io_buffer *head) ...@@ -352,14 +352,12 @@ static int tomoyo_write_profile(struct tomoyo_io_buffer *head)
* tomoyo_read_profile - Read profile table. * tomoyo_read_profile - Read profile table.
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
*
* Returns 0.
*/ */
static int tomoyo_read_profile(struct tomoyo_io_buffer *head) static void tomoyo_read_profile(struct tomoyo_io_buffer *head)
{ {
int index; int index;
if (head->read_eof) if (head->read_eof)
return 0; return;
if (head->read_bit) if (head->read_bit)
goto body; goto body;
tomoyo_io_printf(head, "PROFILE_VERSION=%s\n", "20090903"); tomoyo_io_printf(head, "PROFILE_VERSION=%s\n", "20090903");
...@@ -434,7 +432,6 @@ static int tomoyo_read_profile(struct tomoyo_io_buffer *head) ...@@ -434,7 +432,6 @@ static int tomoyo_read_profile(struct tomoyo_io_buffer *head)
} }
if (index == TOMOYO_MAX_PROFILES) if (index == TOMOYO_MAX_PROFILES)
head->read_eof = true; head->read_eof = true;
return 0;
} }
/* /*
...@@ -538,17 +535,15 @@ static int tomoyo_write_manager_policy(struct tomoyo_io_buffer *head) ...@@ -538,17 +535,15 @@ static int tomoyo_write_manager_policy(struct tomoyo_io_buffer *head)
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
* Returns 0.
*
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static int tomoyo_read_manager_policy(struct tomoyo_io_buffer *head) static void tomoyo_read_manager_policy(struct tomoyo_io_buffer *head)
{ {
struct list_head *pos; struct list_head *pos;
bool done = true; bool done = true;
if (head->read_eof) if (head->read_eof)
return 0; return;
list_for_each_cookie(pos, head->read_var2, list_for_each_cookie(pos, head->read_var2,
&tomoyo_policy_manager_list) { &tomoyo_policy_manager_list) {
struct tomoyo_policy_manager_entry *ptr; struct tomoyo_policy_manager_entry *ptr;
...@@ -561,7 +556,6 @@ static int tomoyo_read_manager_policy(struct tomoyo_io_buffer *head) ...@@ -561,7 +556,6 @@ static int tomoyo_read_manager_policy(struct tomoyo_io_buffer *head)
break; break;
} }
head->read_eof = done; head->read_eof = done;
return 0;
} }
/** /**
...@@ -1004,18 +998,16 @@ static bool tomoyo_print_entry(struct tomoyo_io_buffer *head, ...@@ -1004,18 +998,16 @@ static bool tomoyo_print_entry(struct tomoyo_io_buffer *head,
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
* Returns 0.
*
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static int tomoyo_read_domain_policy(struct tomoyo_io_buffer *head) static void tomoyo_read_domain_policy(struct tomoyo_io_buffer *head)
{ {
struct list_head *dpos; struct list_head *dpos;
struct list_head *apos; struct list_head *apos;
bool done = true; bool done = true;
if (head->read_eof) if (head->read_eof)
return 0; return;
if (head->read_step == 0) if (head->read_step == 0)
head->read_step = 1; head->read_step = 1;
list_for_each_cookie(dpos, head->read_var1, &tomoyo_domain_list) { list_for_each_cookie(dpos, head->read_var1, &tomoyo_domain_list) {
...@@ -1070,7 +1062,6 @@ static int tomoyo_read_domain_policy(struct tomoyo_io_buffer *head) ...@@ -1070,7 +1062,6 @@ static int tomoyo_read_domain_policy(struct tomoyo_io_buffer *head)
break; break;
} }
head->read_eof = done; head->read_eof = done;
return 0;
} }
/** /**
...@@ -1122,13 +1113,13 @@ static int tomoyo_write_domain_profile(struct tomoyo_io_buffer *head) ...@@ -1122,13 +1113,13 @@ static int tomoyo_write_domain_profile(struct tomoyo_io_buffer *head)
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static int tomoyo_read_domain_profile(struct tomoyo_io_buffer *head) static void tomoyo_read_domain_profile(struct tomoyo_io_buffer *head)
{ {
struct list_head *pos; struct list_head *pos;
bool done = true; bool done = true;
if (head->read_eof) if (head->read_eof)
return 0; return;
list_for_each_cookie(pos, head->read_var1, &tomoyo_domain_list) { list_for_each_cookie(pos, head->read_var1, &tomoyo_domain_list) {
struct tomoyo_domain_info *domain; struct tomoyo_domain_info *domain;
domain = list_entry(pos, struct tomoyo_domain_info, list); domain = list_entry(pos, struct tomoyo_domain_info, list);
...@@ -1140,7 +1131,6 @@ static int tomoyo_read_domain_profile(struct tomoyo_io_buffer *head) ...@@ -1140,7 +1131,6 @@ static int tomoyo_read_domain_profile(struct tomoyo_io_buffer *head)
break; break;
} }
head->read_eof = done; head->read_eof = done;
return 0;
} }
/** /**
...@@ -1170,7 +1160,7 @@ static int tomoyo_write_pid(struct tomoyo_io_buffer *head) ...@@ -1170,7 +1160,7 @@ static int tomoyo_write_pid(struct tomoyo_io_buffer *head)
* The PID is specified by tomoyo_write_pid() so that the user can obtain * The PID is specified by tomoyo_write_pid() so that the user can obtain
* using read()/write() interface rather than sysctl() interface. * using read()/write() interface rather than sysctl() interface.
*/ */
static int tomoyo_read_pid(struct tomoyo_io_buffer *head) static void tomoyo_read_pid(struct tomoyo_io_buffer *head)
{ {
if (head->read_avail == 0 && !head->read_eof) { if (head->read_avail == 0 && !head->read_eof) {
const int pid = head->read_step; const int pid = head->read_step;
...@@ -1188,7 +1178,6 @@ static int tomoyo_read_pid(struct tomoyo_io_buffer *head) ...@@ -1188,7 +1178,6 @@ static int tomoyo_read_pid(struct tomoyo_io_buffer *head)
domain->domainname->name); domain->domainname->name);
head->read_eof = true; head->read_eof = true;
} }
return 0;
} }
/** /**
...@@ -1238,11 +1227,9 @@ static int tomoyo_write_exception_policy(struct tomoyo_io_buffer *head) ...@@ -1238,11 +1227,9 @@ static int tomoyo_write_exception_policy(struct tomoyo_io_buffer *head)
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
* Returns 0 on success, -EINVAL otherwise.
*
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static int tomoyo_read_exception_policy(struct tomoyo_io_buffer *head) static void tomoyo_read_exception_policy(struct tomoyo_io_buffer *head)
{ {
if (!head->read_eof) { if (!head->read_eof) {
switch (head->read_step) { switch (head->read_step) {
...@@ -1302,11 +1289,8 @@ static int tomoyo_read_exception_policy(struct tomoyo_io_buffer *head) ...@@ -1302,11 +1289,8 @@ static int tomoyo_read_exception_policy(struct tomoyo_io_buffer *head)
case 11: case 11:
head->read_eof = true; head->read_eof = true;
break; break;
default:
return -EINVAL;
} }
} }
return 0;
} }
/** /**
...@@ -1560,17 +1544,15 @@ static int tomoyo_poll_query(struct file *file, poll_table *wait) ...@@ -1560,17 +1544,15 @@ static int tomoyo_poll_query(struct file *file, poll_table *wait)
* tomoyo_read_query - Read access requests which violated policy in enforcing mode. * tomoyo_read_query - Read access requests which violated policy in enforcing mode.
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
*
* Returns 0.
*/ */
static int tomoyo_read_query(struct tomoyo_io_buffer *head) static void tomoyo_read_query(struct tomoyo_io_buffer *head)
{ {
struct list_head *tmp; struct list_head *tmp;
int pos = 0; int pos = 0;
int len = 0; int len = 0;
char *buf; char *buf;
if (head->read_avail) if (head->read_avail)
return 0; return;
if (head->read_buf) { if (head->read_buf) {
kfree(head->read_buf); kfree(head->read_buf);
head->read_buf = NULL; head->read_buf = NULL;
...@@ -1590,11 +1572,11 @@ static int tomoyo_read_query(struct tomoyo_io_buffer *head) ...@@ -1590,11 +1572,11 @@ static int tomoyo_read_query(struct tomoyo_io_buffer *head)
spin_unlock(&tomoyo_query_list_lock); spin_unlock(&tomoyo_query_list_lock);
if (!len) { if (!len) {
head->read_step = 0; head->read_step = 0;
return 0; return;
} }
buf = kzalloc(len, GFP_NOFS); buf = kzalloc(len, GFP_NOFS);
if (!buf) if (!buf)
return 0; return;
pos = 0; pos = 0;
spin_lock(&tomoyo_query_list_lock); spin_lock(&tomoyo_query_list_lock);
list_for_each(tmp, &tomoyo_query_list) { list_for_each(tmp, &tomoyo_query_list) {
...@@ -1621,7 +1603,6 @@ static int tomoyo_read_query(struct tomoyo_io_buffer *head) ...@@ -1621,7 +1603,6 @@ static int tomoyo_read_query(struct tomoyo_io_buffer *head)
} else { } else {
kfree(buf); kfree(buf);
} }
return 0;
} }
/** /**
...@@ -1667,13 +1648,12 @@ static int tomoyo_write_answer(struct tomoyo_io_buffer *head) ...@@ -1667,13 +1648,12 @@ static int tomoyo_write_answer(struct tomoyo_io_buffer *head)
* *
* Returns version information. * Returns version information.
*/ */
static int tomoyo_read_version(struct tomoyo_io_buffer *head) static void tomoyo_read_version(struct tomoyo_io_buffer *head)
{ {
if (!head->read_eof) { if (!head->read_eof) {
tomoyo_io_printf(head, "2.3.0-pre"); tomoyo_io_printf(head, "2.3.0-pre");
head->read_eof = true; head->read_eof = true;
} }
return 0;
} }
/** /**
...@@ -1683,7 +1663,7 @@ static int tomoyo_read_version(struct tomoyo_io_buffer *head) ...@@ -1683,7 +1663,7 @@ static int tomoyo_read_version(struct tomoyo_io_buffer *head)
* *
* Returns the current process's domainname. * Returns the current process's domainname.
*/ */
static int tomoyo_read_self_domain(struct tomoyo_io_buffer *head) static void tomoyo_read_self_domain(struct tomoyo_io_buffer *head)
{ {
if (!head->read_eof) { if (!head->read_eof) {
/* /*
...@@ -1694,7 +1674,6 @@ static int tomoyo_read_self_domain(struct tomoyo_io_buffer *head) ...@@ -1694,7 +1674,6 @@ static int tomoyo_read_self_domain(struct tomoyo_io_buffer *head)
tomoyo_io_printf(head, "%s", tomoyo_domain()->domainname->name); tomoyo_io_printf(head, "%s", tomoyo_domain()->domainname->name);
head->read_eof = true; head->read_eof = true;
} }
return 0;
} }
/** /**
...@@ -1862,7 +1841,7 @@ int tomoyo_read_control(struct file *file, char __user *buffer, ...@@ -1862,7 +1841,7 @@ int tomoyo_read_control(struct file *file, char __user *buffer,
if (mutex_lock_interruptible(&head->io_sem)) if (mutex_lock_interruptible(&head->io_sem))
return -EINTR; return -EINTR;
/* Call the policy handler. */ /* Call the policy handler. */
len = head->read(head); head->read(head);
if (len < 0) if (len < 0)
goto out; goto out;
/* Write to buffer. */ /* Write to buffer. */
......
...@@ -526,7 +526,7 @@ struct tomoyo_mount_acl { ...@@ -526,7 +526,7 @@ struct tomoyo_mount_acl {
* is appended. * is appended.
*/ */
struct tomoyo_io_buffer { struct tomoyo_io_buffer {
int (*read) (struct tomoyo_io_buffer *); void (*read) (struct tomoyo_io_buffer *);
int (*write) (struct tomoyo_io_buffer *); int (*write) (struct tomoyo_io_buffer *);
int (*poll) (struct file *file, poll_table *wait); int (*poll) (struct file *file, poll_table *wait);
/* Exclusive lock for this structure. */ /* Exclusive lock for this structure. */
...@@ -900,7 +900,7 @@ void *tomoyo_commit_ok(void *data, const unsigned int size); ...@@ -900,7 +900,7 @@ void *tomoyo_commit_ok(void *data, const unsigned int size);
const struct tomoyo_path_info *tomoyo_get_name(const char *name); const struct tomoyo_path_info *tomoyo_get_name(const char *name);
/* Check for memory usage. */ /* Check for memory usage. */
int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head); void tomoyo_read_memory_counter(struct tomoyo_io_buffer *head);
/* Set memory quota. */ /* Set memory quota. */
int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head); int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head);
......
...@@ -184,7 +184,7 @@ unsigned int tomoyo_quota_for_query; ...@@ -184,7 +184,7 @@ unsigned int tomoyo_quota_for_query;
* *
* Returns memory usage. * Returns memory usage.
*/ */
int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head) void tomoyo_read_memory_counter(struct tomoyo_io_buffer *head)
{ {
if (!head->read_eof) { if (!head->read_eof) {
const unsigned int policy const unsigned int policy
...@@ -212,7 +212,6 @@ int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head) ...@@ -212,7 +212,6 @@ int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head)
tomoyo_io_printf(head, "Total: %10u\n", policy + query); tomoyo_io_printf(head, "Total: %10u\n", policy + query);
head->read_eof = true; head->read_eof = true;
} }
return 0;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment