linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipc: Assign value when defining variables
@ 2021-05-18  7:08 zuoqilin1
  0 siblings, 0 replies; only message in thread
From: zuoqilin1 @ 2021-05-18  7:08 UTC (permalink / raw)
  To: unixbhaskar, adobriyan, gustavoars, akpm; +Cc: linux-kernel, zuoqilin

From: zuoqilin <zuoqilin@yulong.com>

When defining variables and assigning values can be done at the same time.

Signed-off-by: zuoqilin <zuoqilin@yulong.com>
---
 ipc/sem.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/ipc/sem.c b/ipc/sem.c
index e0ec239..475d5bf 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1104,9 +1104,8 @@ static int count_semcnt(struct sem_array *sma, ushort semnum,
 {
 	struct list_head *l;
 	struct sem_queue *q;
-	int semcnt;
+	int semcnt = 0;
 
-	semcnt = 0;
 	/* First: check the simple operations. They are easy to evaluate */
 	if (count_zero)
 		l = &sma->sems[semnum].pending_const;
@@ -1986,7 +1985,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
 	struct sembuf fast_sops[SEMOPM_FAST];
 	struct sembuf *sops = fast_sops, *sop;
 	struct sem_undo *un;
-	int max, locknum;
+	int max = 0, locknum;
 	bool undos = false, alter = false, dupsop = false;
 	struct sem_queue queue;
 	unsigned long dup = 0, jiffies_left = 0;
@@ -2018,7 +2017,6 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
 		jiffies_left = timespec64_to_jiffies(timeout);
 	}
 
-	max = 0;
 	for (sop = sops; sop < sops + nsops; sop++) {
 		unsigned long mask = 1ULL << ((sop->sem_num) % BITS_PER_LONG);
 
-- 
1.9.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-18  7:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18  7:08 [PATCH] ipc: Assign value when defining variables zuoqilin1

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).