Skip to content

Commit 4ff493f

Browse files
committed
rewrite if-else flow
1 parent 15a983c commit 4ff493f

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

flang/runtime/execute.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,6 @@ int TerminationCheck(int status, const Descriptor *cmdstat,
6969
int exitStatusVal{status};
7070
#else
7171
int exitStatusVal{WEXITSTATUS(status)};
72-
#endif
73-
if (exitStatusVal != 0) {
74-
if (!cmdstat) {
75-
terminator.Crash(
76-
"Invalid command quit with exit status code: %d", exitStatusVal);
77-
} else {
78-
StoreIntToDescriptor(cmdstat, INVALID_CL_ERR, terminator);
79-
CheckAndCopyCharsToDescriptor(cmdmsg, "Invalid command line");
80-
}
81-
}
82-
83-
#ifndef _WIN32
8472
if (exitStatusVal == 1) {
8573
if (!cmdstat) {
8674
terminator.Crash("General Error with exit status code: 1");
@@ -107,8 +95,17 @@ int TerminationCheck(int status, const Descriptor *cmdstat,
10795
CheckAndCopyCharsToDescriptor(cmdmsg,
10896
"Command not found: command was not found in the system's PATH");
10997
}
110-
}
98+
} else
11199
#endif
100+
if (exitStatusVal != 0) {
101+
if (!cmdstat) {
102+
terminator.Crash(
103+
"Invalid command quit with exit status code: %d", exitStatusVal);
104+
} else {
105+
StoreIntToDescriptor(cmdstat, INVALID_CL_ERR, terminator);
106+
CheckAndCopyCharsToDescriptor(cmdmsg, "Invalid command line");
107+
}
108+
}
112109

113110
if (status == -1) {
114111
if (!cmdstat) {

flang/unittests/Runtime/CommandTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ TEST_F(ZeroArguments, ECLValidCommandStatusSetSync) {
340340
}
341341

342342
TEST_F(ZeroArguments, ECLGeneralErrorCommandErrorSync) {
343-
OwningPtr<Descriptor> command{CharDescriptor("cat general-error")};
343+
OwningPtr<Descriptor> command{CharDescriptor("cat GeneralErrorCommand")};
344344
bool wait{true};
345345
OwningPtr<Descriptor> exitStat{IntDescriptor(404)};
346346
OwningPtr<Descriptor> cmdStat{IntDescriptor(202)};

0 commit comments

Comments
 (0)