[hackers] [PATCH 4/4] Localize running and failure inside readpw()

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Thu, 1 Sep 2016 13:47:19 +0200

They are only needed there, so don't make them global.
---
 slock.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/slock.c b/slock.c
index 0682279..83d426a 100644
--- a/slock.c
+++ b/slock.c
_AT_@ -46,8 +46,6 @@ typedef struct {
 
 static Lock **locks;
 static int nscreens;
-static Bool running = True;
-static Bool failure = False;
 static Bool rr;
 static int rrevbase;
 static int rrerrbase;
_AT_@ -132,14 +130,15 @@ readpw(Display *dpy, const char *pws)
 #endif
 {
 	char buf[32], passwd[256], *encrypted;
-	int num, screen;
+	int num, screen, running, failure;
 	unsigned int len, color;
 	KeySym ksym;
 	XEvent ev;
 	static int oldc = INIT;
 
 	len = 0;
-	running = True;
+	running = 1;
+	failure = 0;
 
 	/* As "slock" stands for "Simple X display locker", the DPMS settings
 	 * had been removed and you can set it with "xset" or some other
_AT_@ -253,7 +252,7 @@ lockscreen(Display *dpy, int screen)
 	XSetWindowAttributes wa;
 	Cursor invisible;
 
-	if (!running || dpy == NULL || screen < 0 || !(lock = malloc(sizeof(Lock))))
+	if (dpy == NULL || screen < 0 || !(lock = malloc(sizeof(Lock))))
 		return NULL;
 
 	lock->screen = screen;
_AT_@ -376,7 +375,6 @@ main(int argc, char **argv) {
 
 	/* did we manage to lock everything? */
 	if (nlocks != nscreens) {
-		running = 0;
 		cleanup(dpy);
 		return 1;
 	}
-- 
2.9.3
Received on Thu Sep 01 2016 - 13:47:19 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 01 2016 - 13:48:41 CEST