diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2018-07-10 14:20:43 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2020-07-14 15:52:40 +0200 |
commit | 82550d3e45c4df951eb7fc669e6b2d55037cc629 (patch) | |
tree | e073f0e3304ea18da7d885551beccc4872122ffa | |
parent | 21a8da6e18e1b45112fce3520ff91d0fd70813ba (diff) |
Consistant use of bool whenever possible.
-rw-r--r-- | greeter/greet.c | 8 | ||||
-rw-r--r-- | include/dm.h | 10 | ||||
-rw-r--r-- | include/dm_auth.h | 4 | ||||
-rw-r--r-- | xenodm/auth.c | 40 | ||||
-rw-r--r-- | xenodm/dm.c | 14 | ||||
-rw-r--r-- | xenodm/dpylist.c | 2 | ||||
-rw-r--r-- | xenodm/server.c | 26 | ||||
-rw-r--r-- | xenodm/session.c | 6 |
8 files changed, 55 insertions, 55 deletions
diff --git a/greeter/greet.c b/greeter/greet.c index 51dec78..6f17175 100644 --- a/greeter/greet.c +++ b/greeter/greet.c @@ -327,7 +327,7 @@ greet_user_rtn GreetUser( if (code != 0) { CloseGreet (d); - SessionExit (d, code, FALSE); + SessionExit (d, code, false); } /* * Verify user @@ -351,7 +351,7 @@ greet_user_rtn GreetUser( { Debug ("Startup program %s exited with non-zero status\n", d->startup); - SessionExit (d, OBEYSESS_DISPLAY, FALSE); + SessionExit (d, OBEYSESS_DISPLAY, false); } return Greet_Success; } @@ -365,7 +365,7 @@ greet_user_rtn AutoLogin( if (!autoLoginEnv(d, verify, greet)) { LogError("Autologin %s failed\n", d->autoLogin); - SessionExit(d, UNMANAGE_DISPLAY, TRUE); + SessionExit(d, UNMANAGE_DISPLAY, true); } /* @@ -375,7 +375,7 @@ greet_user_rtn AutoLogin( { Debug ("Startup program %s exited with non-zero status\n", d->startup); - SessionExit (d, OBEYSESS_DISPLAY, FALSE); + SessionExit (d, OBEYSESS_DISPLAY, false); } return Greet_Success; } diff --git a/include/dm.h b/include/dm.h index 0fdacc4..45c6aa2 100644 --- a/include/dm.h +++ b/include/dm.h @@ -53,7 +53,7 @@ from The Open Group. # include <time.h> # define Time_t time_t # include <stdlib.h> - +# include <stdbool.h> # include <X11/Xdmcp.h> @@ -97,7 +97,7 @@ struct display { int openTimeout; /* abort open attempt timeout */ int startAttempts; /* number of attempts at starting */ int reservAttempts; /* allowed start-IO error sequences */ - int terminateServer;/* restart for each session */ + bool terminateServer;/* restart for each session */ int grabServer; /* keep server grabbed for Login */ int grabTimeout; /* time to wait for grab */ int resetSignal; /* signal to reset server */ @@ -118,7 +118,7 @@ struct display { char *failsafeClient;/* a client to start when the session fails */ /* authorization resources */ - int authorize; /* enable authorization */ + bool authorize; /* enable authorization */ char **authNames; /* authorization protocol names */ unsigned short *authNameLens; /* authorization protocol name lens */ char *clientAuthFile;/* client specified auth file */ @@ -230,14 +230,14 @@ extern void DeleteXloginResources (struct display *d, Display *dpy); extern void LoadXloginResources (struct display *d); extern __dead void ManageSession (struct display *d); extern void SecureDisplay (struct display *d, Display *dpy); -extern __dead void SessionExit (struct display *d, int status, int removeAuth); +extern __dead void SessionExit (struct display *d, int status, bool removeAuth); extern void SetupDisplay (struct display *d); extern void UnsecureDisplay (struct display *d, Display *dpy); extern void execute(char **argv, char **environ); /* server.c */ extern const char *_SysErrorMsg (int n); -extern int StartServer (struct display *d); +extern bool StartServer (struct display *d); extern int WaitForServer (struct display *d); extern void ResetServer (struct display *d); diff --git a/include/dm_auth.h b/include/dm_auth.h index 533f67d..dfde859 100644 --- a/include/dm_auth.h +++ b/include/dm_auth.h @@ -39,10 +39,10 @@ extern void MitInitAuth (unsigned short name_len, char *name); extern Xauth *MitGetAuth (unsigned short namelen, char *name); /* auth.c */ -extern int ValidAuthorization (unsigned short name_length, char *name); +extern bool ValidAuthorization (unsigned short name_length, char *name); -extern int SaveServerAuthorizations (struct display *d, Xauth **auths, int count); +extern bool SaveServerAuthorizations (struct display *d, Xauth **auths, int count); extern void CleanUpFileName (char *src, char *dst, int len); extern void RemoveUserAuthorization (struct display *d, struct verify_info *verify); extern void SetAuthorization (struct display *d); diff --git a/xenodm/auth.c b/xenodm/auth.c index a5ca43e..7f022ec 100644 --- a/xenodm/auth.c +++ b/xenodm/auth.c @@ -87,12 +87,10 @@ findProtocol (unsigned short name_length, char *name) return (struct AuthProtocol *) 0; } -int +bool ValidAuthorization (unsigned short name_length, char *name) { - if (findProtocol (name_length, name)) - return TRUE; - return FALSE; + return findProtocol (name_length, name) != NULL; } static Xauth * @@ -110,7 +108,7 @@ GenerateAuthorization (unsigned short name_length, char *name) if (!a->inited) { (*a->InitAuth) (name_length, name); - a->inited = TRUE; + a->inited = true; } auth = (*a->GetAuth) (name_length, name); if (auth) @@ -189,7 +187,7 @@ CheckServerAuthDir (const char *path, struct stat *statb, int mode) static char authdir1[] = "authdir"; static char authdir2[] = "authfiles"; -static int +static bool MakeServerAuthFile (struct display *d, FILE ** file, uid_t uid, gid_t gid) { int len; @@ -209,21 +207,21 @@ MakeServerAuthFile (struct display *d, FILE ** file, uid_t uid, gid_t gid) if (d->clientAuthFile && *d->clientAuthFile) { d->authFile = strdup(d->clientAuthFile); if (!d->authFile) - return FALSE; + return false; } else { CleanUpFileName (d->name, cleanname, NAMELEN - 8); /* Make authDir if it doesn't already exist */ r = CheckServerAuthDir(authDir, &statb, 0755); if (r < 0) { - return FALSE; + return false; } len = strlen (authDir) + strlen (authdir1) + strlen (authdir2) + strlen (cleanname) + 14; d->authFile = malloc (len); if (!d->authFile) - return FALSE; + return false; snprintf (d->authFile, len, "%s/%s", authDir, authdir1); r = CheckServerAuthDir(d->authFile, &statb, 0700); @@ -235,7 +233,7 @@ MakeServerAuthFile (struct display *d, FILE ** file, uid_t uid, gid_t gid) } else if (r < 0) { free (d->authFile); d->authFile = NULL; - return FALSE; + return false; } else { (void) chown(d->authFile, uid, gid); } @@ -246,7 +244,7 @@ MakeServerAuthFile (struct display *d, FILE ** file, uid_t uid, gid_t gid) if (r < 0) { free (d->authFile); d->authFile = NULL; - return FALSE; + return false; } else { (void) chown(d->authFile, uid, gid); } @@ -258,22 +256,22 @@ MakeServerAuthFile (struct display *d, FILE ** file, uid_t uid, gid_t gid) d->authFile, _SysErrorMsg (errno)); free (d->authFile); d->authFile = NULL; - return FALSE; + return false; } *file = fdopen(fd, "w"); if (!*file) (void) close (fd); - return TRUE; + return true; } } (void) unlink (d->authFile); *file = fopen (d->authFile, "w"); - return TRUE; + return true; } -int +bool SaveServerAuthorizations ( struct display *d, Xauth **auths, @@ -305,17 +303,17 @@ SaveServerAuthorizations ( ret = MakeServerAuthFile(d, &auth_file, uid, gid); umask (mask); if (!ret) - return FALSE; + return false; if (!auth_file) { LogError ("cannot open server authorization file %s: %s\n", d->authFile, _SysErrorMsg (errno)); - ret = FALSE; + ret = false; } else { fchown(fileno(auth_file), uid, gid); Debug ("File: %s auth: %p\n", d->authFile, auths); - ret = TRUE; + ret = true; if (count == 0) { /* @@ -333,7 +331,7 @@ SaveServerAuthorizations ( if (ferror (auth_file)) { err = errno; - ret = FALSE; + ret = false; } /* * Rewind so that the garbage data is overwritten later. @@ -357,7 +355,7 @@ SaveServerAuthorizations ( if (ferror (auth_file)) { err = errno; - ret = FALSE; + ret = false; } } } @@ -371,7 +369,7 @@ SaveServerAuthorizations ( fclose (auth_file); } - if (ret == FALSE) + if (ret == false) { LogError ("Cannot write to server authorization file %s%s%s\n", d->authFile, diff --git a/xenodm/dm.c b/xenodm/dm.c index 41aeefb..8700592 100644 --- a/xenodm/dm.c +++ b/xenodm/dm.c @@ -52,7 +52,7 @@ from The Open Group. static void StopAll (int n), RescanNotify (int n); static void RescanServers (void); -static void RestartDisplay (struct display *d, int forceReserver); +static void RestartDisplay (struct display *d, bool forceReserver); static void ScanServers (void); static void SetConfigFileTime (void); static void StartDisplays (void); @@ -329,7 +329,7 @@ WaitForChild (void) if (d->status == zombie) StopDisplay (d); else - RestartDisplay (d, FALSE); + RestartDisplay (d, false); break; case OPENFAILED_DISPLAY: Debug ("Display exited with OPENFAILED_DISPLAY, try %d of %d\n", @@ -347,7 +347,7 @@ WaitForChild (void) } else { - RestartDisplay (d, TRUE); + RestartDisplay (d, true); } break; case RESERVER_DISPLAY: @@ -389,7 +389,7 @@ WaitForChild (void) */ StopDisplay(d); } else { - RestartDisplay(d, TRUE); + RestartDisplay(d, true); } d->lastReserv = now; } @@ -411,7 +411,7 @@ WaitForChild (void) LogError ("display %s is being disabled\n", d->name); StopDisplay(d); } else - RestartDisplay (d, TRUE); + RestartDisplay (d, true); break; case REMANAGE_DISPLAY: d->startTries = 0; @@ -423,7 +423,7 @@ WaitForChild (void) if (d->status == zombie) StopDisplay(d); else - RestartDisplay (d, FALSE); + RestartDisplay (d, false); break; default: Debug ("Display exited with unknown status %d\n", waitVal(status)); @@ -631,7 +631,7 @@ StopDisplay (struct display *d) */ static void -RestartDisplay (struct display *d, int forceReserver) +RestartDisplay (struct display *d, bool forceReserver) { if (d->serverPid != -1 && (forceReserver || d->terminateServer)) { diff --git a/xenodm/dpylist.c b/xenodm/dpylist.c index da77927..32adbfa 100644 --- a/xenodm/dpylist.c +++ b/xenodm/dpylist.c @@ -188,7 +188,7 @@ NewDisplay (char *name, char *class) d->systemPath = NULL; d->systemShell = NULL; d->failsafeClient = NULL; - d->authorize = FALSE; + d->authorize = false; d->authorizations = NULL; d->authNum = 0; d->authNameNum = 0; diff --git a/xenodm/server.c b/xenodm/server.c index 5452401..a7b548f 100644 --- a/xenodm/server.c +++ b/xenodm/server.c @@ -47,7 +47,7 @@ from The Open Group. static int receivedUsr1; -static int serverPause (unsigned t, pid_t serverPid); +static bool serverPause (unsigned t, pid_t serverPid); /* ARGSUSED */ static void @@ -66,7 +66,8 @@ const char *_SysErrorMsg (int n) return (s ? s : "unknown error"); } -static int +/* true if server successufully started */ +static bool StartServerOnce (struct display *d) { char **f; @@ -106,28 +107,28 @@ StartServerOnce (struct display *d) exit (REMANAGE_DISPLAY); case -1: LogError ("fork failed, sleeping\n"); - return 0; + return false; default: break; } Debug ("Server Started %d\n", pid); d->serverPid = pid; if (serverPause ((unsigned) d->openDelay, pid)) - return FALSE; - return TRUE; + return false; + return true; } -int +bool StartServer (struct display *d) { int i; - int ret = FALSE; + bool ret = false; i = 0; while (d->serverAttempts == 0 || i < d->serverAttempts) { Debug("Starting X server attempt %d of %d\n", i, d->serverAttempts); - if ((ret = StartServerOnce (d)) == TRUE) + if ((ret = StartServerOnce (d)) == true) break; sleep (d->openDelay); i++; @@ -147,9 +148,10 @@ chldHandler(int num) return; } -static int serverPauseRet; +static bool serverPauseRet; -static int +/* true if server died */ +static bool serverPause (unsigned t, pid_t serverPid) { struct timespec timeout; @@ -157,7 +159,7 @@ serverPause (unsigned t, pid_t serverPid) int result; pid_t pid; - serverPauseRet = 0; + serverPauseRet = false; for (;;) { timeout.tv_sec = t; @@ -179,7 +181,7 @@ serverPause (unsigned t, pid_t serverPid) if (pid == serverPid || (pid == -1 && errno == ECHILD)) { Debug ("Server dead\n"); - serverPauseRet = 1; + serverPauseRet = true; break; } if (pid == 0) { diff --git a/xenodm/session.c b/xenodm/session.c index f7eeea0..0ce4ae3 100644 --- a/xenodm/session.c +++ b/xenodm/session.c @@ -192,7 +192,7 @@ ManageSession (struct display *d) login_fbtab(d->windowPath, 0, 0); Debug ("Source reset program %s\n", d->reset); source (verify.systemEnviron, d->reset); - SessionExit (d, OBEYSESS_DISPLAY, TRUE); + SessionExit (d, OBEYSESS_DISPLAY, true); } void @@ -248,7 +248,7 @@ SecureDisplay (struct display *d, Display *dpy) GrabModeAsync, CurrentTime) != GrabSuccess) { LogError ("WARNING: keyboard on display %s could not be secured\n", d->name); - SessionExit (d, RESERVER_DISPLAY, FALSE); + SessionExit (d, RESERVER_DISPLAY, false); } Debug ("XGrabKeyboard succeeded %s\n", d->name); pseudoReset (dpy); @@ -270,7 +270,7 @@ UnsecureDisplay (struct display *d, Display *dpy) } __dead void -SessionExit (struct display *d, int status, int removeAuth) +SessionExit (struct display *d, int status, bool removeAuth) { /* make sure the server gets reset after the session is over */ |