mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
examples/pipe/interlock_test.c: fix the uses of uninitialized variables
found by clang warnings.
This commit is contained in:
parent
b73adbe56b
commit
da615bf5a6
1 changed files with 14 additions and 11 deletions
|
|
@ -155,7 +155,7 @@ int interlock_test(void)
|
|||
void *value;
|
||||
char data[16];
|
||||
ssize_t nbytes;
|
||||
int fd;
|
||||
int fd = -1;
|
||||
int ret;
|
||||
|
||||
/* Create a FIFO */
|
||||
|
|
@ -208,7 +208,7 @@ int interlock_test(void)
|
|||
fprintf(stderr, \
|
||||
"interlock_test: read failed, errno=%d\n", errno);
|
||||
ret = 4;
|
||||
goto errout_with_file;
|
||||
goto errout_with_null_writer_thread;
|
||||
}
|
||||
else if (ret != 0)
|
||||
{
|
||||
|
|
@ -216,7 +216,7 @@ int interlock_test(void)
|
|||
"interlock_test: Read %ld bytes of data -- aborting: %d\n",
|
||||
(long)nbytes, errno);
|
||||
ret = 5;
|
||||
goto errout_with_file;
|
||||
goto errout_with_null_writer_thread;
|
||||
}
|
||||
|
||||
printf("interlock_test: read returned\n");
|
||||
|
|
@ -229,6 +229,8 @@ int interlock_test(void)
|
|||
fprintf(stderr, "interlock_test: close failed: %d\n", errno);
|
||||
}
|
||||
|
||||
fd = -1;
|
||||
|
||||
/* Wait for null_writer thread to complete */
|
||||
|
||||
printf("interlock_test: Waiting for null_writer thread\n");
|
||||
|
|
@ -290,7 +292,7 @@ int interlock_test(void)
|
|||
fprintf(stderr, \
|
||||
"interlock_test: write failed, errno=%d\n", errno);
|
||||
ret = 10;
|
||||
goto errout_with_file;
|
||||
goto errout_with_null_reader_thread;
|
||||
}
|
||||
else if (ret != 0)
|
||||
{
|
||||
|
|
@ -298,7 +300,7 @@ int interlock_test(void)
|
|||
"interlock_test: Wrote %ld bytes of data -- aborting: %d\n",
|
||||
(long)nbytes, errno);
|
||||
ret = 11;
|
||||
goto errout_with_file;
|
||||
goto errout_with_null_reader_thread;
|
||||
}
|
||||
|
||||
printf("interlock_test: write returned\n");
|
||||
|
|
@ -311,6 +313,8 @@ int interlock_test(void)
|
|||
fprintf(stderr, "interlock_test: close failed: %d\n", errno);
|
||||
}
|
||||
|
||||
fd = -1;
|
||||
|
||||
/* Wait for null_reader thread to complete */
|
||||
|
||||
printf("interlock_test: Waiting for null_reader thread\n");
|
||||
|
|
@ -335,12 +339,6 @@ int interlock_test(void)
|
|||
ret = 0;
|
||||
goto errout_with_fifo;
|
||||
|
||||
errout_with_file:
|
||||
if (close(fd) != 0)
|
||||
{
|
||||
fprintf(stderr, "interlock_test: close failed: %d\n", errno);
|
||||
}
|
||||
|
||||
errout_with_null_reader_thread:
|
||||
pthread_detach(readerid);
|
||||
pthread_cancel(readerid);
|
||||
|
|
@ -351,6 +349,11 @@ errout_with_null_writer_thread:
|
|||
|
||||
errout_with_fifo:
|
||||
|
||||
if (fd != -1 && close(fd) != 0)
|
||||
{
|
||||
fprintf(stderr, "interlock_test: close failed: %d\n", errno);
|
||||
}
|
||||
|
||||
ret = remove(FIFO_PATH2);
|
||||
if (ret != 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue