[v6,3/6] linux ttyname: Change return type of is_pty from int to bool

Message ID 20171110200827.32265-4-lukeshu@lukeshu.com
State New
Headers show
Series
  • Fixup linux ttyname and ttyname_r [BZ #22145]
Related show

Commit Message

Luke Shumaker Nov. 10, 2017, 8:08 p.m.
From: Luke Shumaker <lukeshu@parabola.nu>

is_pty returning a bool is fine since there's no possible outcome other
than true or false, and bool is used throughout the codebase.

v2:
 - Introduce as part of another commit
v3:
 - Split into a separate commit
---
 ChangeLog                         | 3 +++
 sysdeps/unix/sysv/linux/ttyname.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Christian Brauner Nov. 11, 2017, 11:04 p.m. | #1
On Fri, Nov 10, 2017 at 03:08:24PM -0500, Luke Shumaker wrote:
> From: Luke Shumaker <lukeshu@parabola.nu>
> 
> is_pty returning a bool is fine since there's no possible outcome other
> than true or false, and bool is used throughout the codebase.
> 
> v2:
>  - Introduce as part of another commit
> v3:
>  - Split into a separate commit
> ---
>  ChangeLog                         | 3 +++
>  sysdeps/unix/sysv/linux/ttyname.h | 2 +-
>  2 files changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>

> 
> diff --git a/ChangeLog b/ChangeLog
> index 095baf9eb6..11709a01ac 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,8 @@
>  2017-11-07  Luke Shumaker  <lukeshu@parabola.nu>
>  
> +	* sysdeps/unix/sysv/linux/ttyname.h (is_pty): Change return type from
> +	int to bool.
> +
>  	* sysdeps/unix/sysv/linux/ttyname.h (is_pty): Update doc reference.
>  
>  	* manual/terminal.texi (Is It a Terminal):
> diff --git a/sysdeps/unix/sysv/linux/ttyname.h b/sysdeps/unix/sysv/linux/ttyname.h
> index cbcdbab607..ce4845a587 100644
> --- a/sysdeps/unix/sysv/linux/ttyname.h
> +++ b/sysdeps/unix/sysv/linux/ttyname.h
> @@ -23,7 +23,7 @@
>  /* Return true if this is a UNIX98 pty device, as defined in
>     linux/Documentation/devices.txt (on linux < 4.10) or
>     linux/Documentation/admin-guide/devices.txt (on linux >= 4.10).  */
> -static inline int
> +static inline bool
>  is_pty (struct stat64 *sb)
>  {
>  #ifdef _STATBUF_ST_RDEV
> -- 
> 2.15.0
>
Florian Weimer Nov. 12, 2017, 7:38 a.m. | #2
* Luke Shumaker:

> --- a/sysdeps/unix/sysv/linux/ttyname.h
> +++ b/sysdeps/unix/sysv/linux/ttyname.h
> @@ -23,7 +23,7 @@
>  /* Return true if this is a UNIX98 pty device, as defined in
>     linux/Documentation/devices.txt (on linux < 4.10) or
>     linux/Documentation/admin-guide/devices.txt (on linux >= 4.10).  */
> -static inline int
> +static inline bool
>  is_pty (struct stat64 *sb)
>  {
>  #ifdef _STATBUF_ST_RDEV

The file does not include <stdbool.h>, so bool might not be available.
Either include it, or use _Bool.

Patch

diff --git a/ChangeLog b/ChangeLog
index 095baf9eb6..11709a01ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@ 
 2017-11-07  Luke Shumaker  <lukeshu@parabola.nu>
 
+	* sysdeps/unix/sysv/linux/ttyname.h (is_pty): Change return type from
+	int to bool.
+
 	* sysdeps/unix/sysv/linux/ttyname.h (is_pty): Update doc reference.
 
 	* manual/terminal.texi (Is It a Terminal):
diff --git a/sysdeps/unix/sysv/linux/ttyname.h b/sysdeps/unix/sysv/linux/ttyname.h
index cbcdbab607..ce4845a587 100644
--- a/sysdeps/unix/sysv/linux/ttyname.h
+++ b/sysdeps/unix/sysv/linux/ttyname.h
@@ -23,7 +23,7 @@ 
 /* Return true if this is a UNIX98 pty device, as defined in
    linux/Documentation/devices.txt (on linux < 4.10) or
    linux/Documentation/admin-guide/devices.txt (on linux >= 4.10).  */
-static inline int
+static inline bool
 is_pty (struct stat64 *sb)
 {
 #ifdef _STATBUF_ST_RDEV