From 08af9d05165b9750ee8729cdb3399d779fc6c7a8 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 4 Feb 2014 15:18:16 -0700 Subject: [PATCH] Use bool for function return values instead of 1 or 0. --- common/term.c | 46 ++++++++++++++++++++++----------------------- include/sudo_util.h | 10 +++++----- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/common/term.c b/common/term.c index 588dc2ddc..b534c2982 100644 --- a/common/term.c +++ b/common/term.c @@ -88,33 +88,33 @@ tcsetattr_nointr(int fd, int flags, struct termios *tp) /* * Restore saved terminal settings. - * Returns 1 on success or 0 on failure. + * Returns true on success or false on failure. */ -int -term_restore(int fd, int flush) +bool +term_restore(int fd, bool flush) { debug_decl(term_restore, SUDO_DEBUG_UTIL) if (changed) { const int flags = flush ? (TCSASOFT|TCSAFLUSH) : (TCSASOFT|TCSADRAIN); if (tcsetattr_nointr(fd, flags, &oterm) != 0) - debug_return_int(0); + debug_return_bool(false); changed = 0; } - debug_return_int(1); + debug_return_bool(true); } /* * Disable terminal echo. - * Returns 1 on success or 0 on failure. + * Returns true on success or false on failure. */ -int +bool term_noecho(int fd) { debug_decl(term_noecho, SUDO_DEBUG_UTIL) if (!changed && tcgetattr(fd, &oterm) != 0) - debug_return_int(0); + debug_return_bool(false); (void) memcpy(&term, &oterm, sizeof(term)); CLR(term.c_lflag, ECHO|ECHONL); #ifdef VSTATUS @@ -122,16 +122,16 @@ term_noecho(int fd) #endif if (tcsetattr_nointr(fd, TCSADRAIN|TCSASOFT, &term) == 0) { changed = 1; - debug_return_int(1); + debug_return_bool(true); } - debug_return_int(0); + debug_return_bool(false); } /* * Set terminal to raw mode. - * Returns 1 on success or 0 on failure. + * Returns true on success or false on failure. */ -int +bool term_raw(int fd, int isig) { struct termios term; @@ -150,16 +150,16 @@ term_raw(int fd, int isig) SET(term.c_lflag, ISIG); if (tcsetattr_nointr(fd, TCSADRAIN|TCSASOFT, &term) == 0) { changed = 1; - debug_return_int(1); + debug_return_bool(true); } - debug_return_int(0); + debug_return_bool(false); } /* * Set terminal to cbreak mode. - * Returns 1 on success or 0 on failure. + * Returns true on success or false on failure. */ -int +bool term_cbreak(int fd) { debug_decl(term_cbreak, SUDO_DEBUG_UTIL) @@ -181,24 +181,24 @@ term_cbreak(int fd) term_erase = term.c_cc[VERASE]; term_kill = term.c_cc[VKILL]; changed = 1; - debug_return_int(1); + debug_return_bool(true); } - debug_return_int(0); + debug_return_bool(false); } /* * Copy terminal settings from one descriptor to another. - * Returns 1 on success or 0 on failure. + * Returns true on success or false on failure. */ -int +bool term_copy(int src, int dst) { struct termios tt; debug_decl(term_copy, SUDO_DEBUG_UTIL) if (tcgetattr(src, &tt) != 0) - debug_return_int(0); + debug_return_bool(false); if (tcsetattr_nointr(dst, TCSANOW|TCSASOFT, &tt) != 0) - debug_return_int(0); - debug_return_int(1); + debug_return_bool(false); + debug_return_bool(true); } diff --git a/include/sudo_util.h b/include/sudo_util.h index 519d84490..c1ded741f 100644 --- a/include/sudo_util.h +++ b/include/sudo_util.h @@ -163,11 +163,11 @@ void initprogname(const char *); int sudo_setgroups(int ngids, const GETGROUPS_T *gids); /* term.c */ -int term_cbreak(int); -int term_copy(int, int); -int term_noecho(int); -int term_raw(int, int); -int term_restore(int, int); +bool term_cbreak(int); +bool term_copy(int, int); +bool term_noecho(int); +bool term_raw(int, int); +bool term_restore(int, bool); /* ttysize.c */ void get_ttysize(int *rowp, int *colp); -- 2.40.0