[PATCH] ipc: Assign value when defining variables

From: zuoqilin1
Date: Tue May 18 2021 - 03:09:14 EST


From: zuoqilin <zuoqilin@xxxxxxxxxx>

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

Signed-off-by: zuoqilin <zuoqilin@xxxxxxxxxx>
---
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