PTY: Fix a few errors from early testing

This commit is contained in:
Gregory Nutt 2016-07-15 14:09:14 -06:00
parent e3d0c6f15a
commit 552d3c4712
2 changed files with 13 additions and 9 deletions

View File

@ -6,6 +6,8 @@
config EXAMPLES_PTYTEST config EXAMPLES_PTYTEST
bool "Pseudo Terminal test example" bool "Pseudo Terminal test example"
default n default n
depends on PSEUDOTERM
select PSEUDOTERM_SUSV1
---help--- ---help---
Enable the PTY example Enable the PTY example

View File

@ -71,18 +71,18 @@ int pty_test_main(int argc, char *argv[])
/* Grant access and unlock the slave device */ /* Grant access and unlock the slave device */
ret = grantpt(fd); ret = grantpt(fd);
if (fd < 0) if (ret < 0)
{ {
fprintf(stderr, "ERROR: grantpt() failed: %d\n", errno); fprintf(stderr, "ERROR: grantpt() failed: %d\n", errno);
fclose(fd); close(fd);
return -1; return -1;
} }
ret = unlockpt(fd); ret = unlockpt(fd);
if (fd < 0) if (ret < 0)
{ {
fprintf(stderr, "ERROR: unlockpt() failed: %d\n", errno); fprintf(stderr, "ERROR: unlockpt() failed: %d\n", errno);
fclose(fd); close(fd);
return -1; return -1;
} }
@ -95,12 +95,14 @@ int pty_test_main(int argc, char *argv[])
for (; ; ) for (; ; )
{ {
char buffer; ssize_t nread;
int in; char ch;
in = read(fd, &buffer, 1); nread = read(fd, &ch, 1);
putchar(buffer); UNUSED(nread);
buffer = '\0';
putchar(ch);
ch = '\0';
} }
return 0; return 0;