Skip to contentSkip to conversation

pty: set tty on error

PATCH In review Serge E. Hallyn 2 participants 3 messages Sep 18, 2009 1 message not in the archive Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pty: set tty on error

we always return tty expecting it to hold the error code.

---
 drivers/char/tty_io.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/char/tty_io.c +5 -1
index 1729b2f..ee95938 100644
@@ -3033,8 +3033,12 @@ static struct tty_struct *do_restore_tty(struct ckpt_ctx *ctx)
 	 */
 	if (master) {
 		file = pty_open_by_index("/dev/ptmx", h->index);
-		if (IS_ERR(file))
+		if (IS_ERR(file)) {
+			ckpt_write_err(ctx, "TE", "Error %d opening /dev/ptmx",
+				PTR_ERR(file));
+			tty = ERR_PTR(PTR_ERR(file));
 			goto out;
+		}
 
 		/*
 		 * Add file to objhash to ensure proper cleanup later
Signature · 1 line
1.6.1
#2 lore raw
In reply to a message not in the archive

got it, thanks.

Quoted 25 lines · Serge E. Hallyn

we always return tty expecting it to hold the error code.

---
 drivers/char/tty_io.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/char/tty_io.c +5 -1
index 1729b2f..ee95938 100644
@@ -3033,8 +3033,12 @@ static struct tty_struct *do_restore_tty(struct ckpt_ctx *ctx)
 	 */
 	if (master) {
 		file = pty_open_by_index("/dev/ptmx", h->index);
-		if (IS_ERR(file))
+		if (IS_ERR(file)) {
+			ckpt_write_err(ctx, "TE", "Error %d opening /dev/ptmx",
+				PTR_ERR(file));
+			tty = ERR_PTR(PTR_ERR(file));
 			goto out;
+		}
 
 		/*
 		 * Add file to objhash to ensure proper cleanup later
#3 lore raw
In reply to a message not in the archive
Quoted 12 lines · Serge E. Hallyn

we always return tty expecting it to hold the error code.

---
 drivers/char/tty_io.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/char/tty_io.c +0 -0
index 1729b2f..ee95938 100644

drivers/char/tty_io.c static struct tty_struct *do_restore_tty(struct ckpt_ctx *ctx) · line 3038

Quoted 7 lines
drivers/char/tty_io.c +3 -1
@@ -3033,8 +3033,12 @@ static struct tty_struct *do_restore_tty(struct ckpt_ctx *ctx)
 	 */
 	if (master) {
 		file = pty_open_by_index("/dev/ptmx", h->index);
-		if (IS_ERR(file))
+		if (IS_ERR(file)) {
+			ckpt_write_err(ctx, "TE", "Error %d opening /dev/ptmx",
+				PTR_ERR(file));

The 'E' in the first format string already geenrates "err %d" and the integer PTR_ERR(file). The explicit "Error %d" is redundant (and requires another integer).

See (now added) documentation to __ckpt_generate_err() in the code.

Oren.

Quoted 6 lines
drivers/char/tty_io.c +2 -0
+			tty = ERR_PTR(PTR_ERR(file));
 			goto out;
+		}
 
 		/*
 		 * Add file to objhash to ensure proper cleanup later