Found using Coverity Scanner. The first is a bug, the other just
silences a dead-code warning.
Committed as Rev. 196603 after build + regtest.
Tobias
2013-03-11 Tobias Burnus <bur...@net-b.de>
* io/transfer.c (read_block_direct): Correct condition.
* intrinsics/execute_command_line.c (execute_command_line):
Remove dead code for the HAVE_FORK case.
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 515c34f..d97a325 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -641,7 +641,7 @@ read_block_direct (st_parameter_dt *dtp, void *buf, size_t nbytes)
have_read_subrecord = sread (dtp->u.p.current_unit->s,
buf + have_read_record, to_read_subrecord);
- if (unlikely (have_read_subrecord) < 0)
+ if (unlikely (have_read_subrecord < 0))
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return;
diff --git a/libgfortran/intrinsics/execute_command_line.c b/libgfortran/intrinsics/execute_command_line.c
index d0f812d..fa6ea9f 100644
--- a/libgfortran/intrinsics/execute_command_line.c
+++ b/libgfortran/intrinsics/execute_command_line.c
@@ -72,52 +72,54 @@ execute_command_line (const char *command, bool wait, int *exitstat,
#if defined(HAVE_FORK)
if (!wait)
{
/* Asynchronous execution. */
pid_t pid;
set_cmdstat (cmdstat, EXEC_NOERROR);
if ((pid = fork()) < 0)
set_cmdstat (cmdstat, EXEC_CHILDFAILED);
else if (pid == 0)
{
/* Child process. */
int res = system (cmd);
_exit (WIFEXITED(res) ? WEXITSTATUS(res) : res);
}
}
else
#endif
{
/* Synchronous execution. */
int res = system (cmd);
if (res == -1)
set_cmdstat (cmdstat, EXEC_SYSTEMFAILED);
+#ifndef HAVE_FORK
else if (!wait)
set_cmdstat (cmdstat, EXEC_SYNCHRONOUS);
+#endif
else
set_cmdstat (cmdstat, EXEC_NOERROR);
if (res != -1)
{
#if defined(WEXITSTATUS) && defined(WIFEXITED)
*exitstat = WIFEXITED(res) ? WEXITSTATUS(res) : res;
#else
*exitstat = res;
#endif
}
}
/* Now copy back to the Fortran string if needed. */
if (cmdstat && *cmdstat > EXEC_NOERROR)
{
if (cmdmsg)
fstrcpy (cmdmsg, cmdmsg_len, cmdmsg_values[*cmdstat],
strlen (cmdmsg_values[*cmdstat]));
else
runtime_error ("Failure in EXECUTE_COMMAND_LINE: %s",
cmdmsg_values[*cmdstat]);
}
}