Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a06a363 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds
Browse files

[PATCH] ipc/msg.c: clean up coding style



Clean up ipc/msg.c to conform to Documentation/CodingStyle.  (before it was
an inconsistent hodepodge of various coding styles)

Verified that the before/after .o's are identical.

Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 873302c7
Loading
Loading
Loading
Loading
+205 −184
Original line number Diff line number Diff line
@@ -41,7 +41,9 @@ int msg_ctlmax = MSGMAX;
int msg_ctlmnb = MSGMNB;
int msg_ctlmni = MSGMNI;

/* one msg_receiver structure for each sleeping receiver */
/*
 * one msg_receiver structure for each sleeping receiver:
 */
struct msg_receiver {
	struct list_head	r_list;
	struct task_struct	*r_tsk;
@@ -50,7 +52,7 @@ struct msg_receiver {
	long			r_msgtype;
	long			r_maxsize;

	struct msg_msg* volatile r_msg;
	volatile struct msg_msg	*r_msg;
};

/* one msg_sender for each sleeping sender */
@@ -72,10 +74,8 @@ static struct ipc_ids msg_ids;
#define msg_lock(id)		((struct msg_queue *)ipc_lock(&msg_ids, id))
#define msg_unlock(msq)		ipc_unlock(&(msq)->q_perm)
#define msg_rmid(id)		((struct msg_queue *)ipc_rmid(&msg_ids, id))
#define msg_checkid(msq, msgid)	\
	ipc_checkid(&msg_ids,&msq->q_perm,msgid)
#define msg_buildid(id, seq) \
	ipc_buildid(&msg_ids, id, seq)
#define msg_checkid(msq, msgid)	ipc_checkid(&msg_ids, &msq->q_perm, msgid)
#define msg_buildid(id, seq)	ipc_buildid(&msg_ids, id, seq)

static void freeque(struct msg_queue *msq, int id);
static int newque(key_t key, int msgflg);
@@ -94,15 +94,14 @@ void __init msg_init (void)

static int newque(key_t key, int msgflg)
{
	int id;
	int retval;
	struct msg_queue *msq;
	int id, retval;

	msq = ipc_rcu_alloc(sizeof(*msq));
	if (!msq)
		return -ENOMEM;

	msq->q_perm.mode = (msgflg & S_IRWXUGO);
	msq->q_perm.mode = msgflg & S_IRWXUGO;
	msq->q_perm.key = key;

	msq->q_perm.security = NULL;
@@ -178,6 +177,7 @@ static void expunge_all(struct msg_queue* msq, int res)
		msr->r_msg = ERR_PTR(res);
	}
}

/*
 * freeque() wakes up waiters on the sender and receiver waiting queue,
 * removes the message queue from message queue ID
@@ -198,6 +198,7 @@ static void freeque (struct msg_queue *msq, int id)
	tmp = msq->q_messages.next;
	while (tmp != &msq->q_messages) {
		struct msg_msg *msg = list_entry(tmp, struct msg_msg, m_list);

		tmp = tmp->next;
		atomic_dec(&msg_hdrs);
		free_msg(msg);
@@ -209,8 +210,8 @@ static void freeque (struct msg_queue *msq, int id)

asmlinkage long sys_msgget(key_t key, int msgflg)
{
	int id, ret = -EPERM;
	struct msg_queue *msq;
	int id, ret = -EPERM;
	
	mutex_lock(&msg_ids.mutex);
	if (key == IPC_PRIVATE) 
@@ -229,6 +230,7 @@ asmlinkage long sys_msgget (key_t key, int msgflg)
			ret = -EACCES;
		else {
			int qid = msg_buildid(id, msq->q_perm.seq);

			ret = security_msg_queue_associate(msq, msgflg);
			if (!ret)
				ret = qid;
@@ -236,10 +238,12 @@ asmlinkage long sys_msgget (key_t key, int msgflg)
		msg_unlock(msq);
	}
	mutex_unlock(&msg_ids.mutex);

	return ret;
}

static inline unsigned long copy_msqid_to_user(void __user *buf, struct msqid64_ds *in, int version)
static inline unsigned long
copy_msqid_to_user(void __user *buf, struct msqid64_ds *in, int version)
{
	switch(version) {
	case IPC_64:
@@ -290,7 +294,8 @@ struct msq_setbuf {
	mode_t		mode;
};

static inline unsigned long copy_msqid_from_user(struct msq_setbuf *out, void __user *buf, int version)
static inline unsigned long
copy_msqid_from_user(struct msq_setbuf *out, void __user *buf, int version)
{
	switch(version) {
	case IPC_64:
@@ -332,10 +337,10 @@ static inline unsigned long copy_msqid_from_user(struct msq_setbuf *out, void __

asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
{
	int err, version;
	struct msg_queue *msq;
	struct msq_setbuf setbuf;
	struct kern_ipc_perm *ipcp;
	struct msq_setbuf setbuf;
	struct msg_queue *msq;
	int err, version;

	if (msqid < 0 || cmd < 0)
		return -EINVAL;
@@ -348,13 +353,14 @@ asmlinkage long sys_msgctl (int msqid, int cmd, struct msqid_ds __user *buf)
	{
		struct msginfo msginfo;
		int max_id;

		if (!buf)
			return -EFAULT;
		/* We must not return kernel stack data.
		/*
		 * We must not return kernel stack data.
		 * due to padding, it's not enough
		 * to set all member fields.
		 */

		err = security_msg_queue_msgctl(NULL, cmd);
		if (err)
			return err;
@@ -386,6 +392,7 @@ asmlinkage long sys_msgctl (int msqid, int cmd, struct msqid_ds __user *buf)
	{
		struct msqid64_ds tbuf;
		int success_return;

		if (!buf)
			return -EFAULT;
		if (cmd == MSG_STAT && msqid >= msg_ids.entries->size)
@@ -454,7 +461,8 @@ asmlinkage long sys_msgctl (int msqid, int cmd, struct msqid_ds __user *buf)
	if (err)
		goto out_unlock_up;
	if (cmd==IPC_SET) {
		err = audit_ipc_set_perm(setbuf.qbytes, setbuf.uid, setbuf.gid, setbuf.mode);
		err = audit_ipc_set_perm(setbuf.qbytes, setbuf.uid, setbuf.gid,
					 setbuf.mode);
		if (err)
			goto out_unlock_up;
	}
@@ -539,10 +547,13 @@ static inline int pipelined_send(struct msg_queue* msq, struct msg_msg* msg)
	tmp = msq->q_receivers.next;
	while (tmp != &msq->q_receivers) {
		struct msg_receiver *msr;

		msr = list_entry(tmp, struct msg_receiver, r_list);
		tmp = tmp->next;
		if (testmsg(msg, msr->r_msgtype, msr->r_mode) &&
		   !security_msg_queue_msgrcv(msq, msg, msr->r_tsk, msr->r_msgtype, msr->r_mode)) {
		    !security_msg_queue_msgrcv(msq, msg, msr->r_tsk,
					       msr->r_msgtype, msr->r_mode)) {

			list_del(&msr->r_list);
			if (msr->r_maxsize < msg->m_ts) {
				msr->r_msg = NULL;
@@ -556,6 +567,7 @@ static inline int pipelined_send(struct msg_queue* msq, struct msg_msg* msg)
				wake_up_process(msr->r_tsk);
				smp_mb();
				msr->r_msg = msg;

				return 1;
			}
		}
@@ -563,7 +575,8 @@ static inline int pipelined_send(struct msg_queue* msq, struct msg_msg* msg)
	return 0;
}

asmlinkage long sys_msgsnd (int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
asmlinkage long
sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
{
	struct msg_queue *msq;
	struct msg_msg *msg;
@@ -667,7 +680,7 @@ static inline int convert_mode(long* msgtyp, int msgflg)
	if (*msgtyp == 0)
		return SEARCH_ANY;
	if (*msgtyp < 0) {
		*msgtyp=-(*msgtyp);
		*msgtyp = -*msgtyp;
		return SEARCH_LESSEQUAL;
	}
	if (msgflg & MSG_EXCEPT)
@@ -706,11 +719,15 @@ asmlinkage long sys_msgrcv (int msqid, struct msgbuf __user *msgp, size_t msgsz,
		tmp = msq->q_messages.next;
		while (tmp != &msq->q_messages) {
			struct msg_msg *walk_msg;

			walk_msg = list_entry(tmp, struct msg_msg, m_list);
			if (testmsg(walk_msg, msgtyp, mode) &&
			   !security_msg_queue_msgrcv(msq, walk_msg, current, msgtyp, mode)) {
			    !security_msg_queue_msgrcv(msq, walk_msg, current,
						       msgtyp, mode)) {

				msg = walk_msg;
				if(mode == SEARCH_LESSEQUAL && walk_msg->m_type != 1) {
				if (mode == SEARCH_LESSEQUAL &&
						walk_msg->m_type != 1) {
					msg = walk_msg;
					msgtyp = walk_msg->m_type - 1;
				} else {
@@ -721,7 +738,10 @@ asmlinkage long sys_msgrcv (int msqid, struct msgbuf __user *msgp, size_t msgsz,
			tmp = tmp->next;
		}
		if (!IS_ERR(msg)) {
			/* Found a suitable message. Unlink it from the queue. */
			/*
			 * Found a suitable message.
			 * Unlink it from the queue.
			 */
			if ((msgsz < msg->m_ts) && !(msgflg & MSG_NOERROR)) {
				msg = ERR_PTR(-E2BIG);
				goto out_unlock;
@@ -818,6 +838,7 @@ asmlinkage long sys_msgrcv (int msqid, struct msgbuf __user *msgp, size_t msgsz,
		msgsz = -EFAULT;
	}
	free_msg(msg);

	return msgsz;
}