hsci: fix wrong return code

In the current code, after the function check_pnetids() and the function
verify_precon() are called, $? from each function is used twice
successively. It is used for the first time in the condition of the IF
statement, while for the second time as return code of the current
function. In bash, $? can be used to get the return code, but only for
the first time directly after the previous function is called.
Afterwards, $? will be reset to "0". Thus, the right return code can not
be get, if $? is used second time.

To solve the problem, using $? for the second time should be avoided.

Signed-off-by: Wenjia Zhang <wenjia@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Wenjia Zhang
2021-01-21 17:43:27 +01:00
committed by Jan Höppner
parent 42889edc0c
commit 522252d18a

View File

@@ -146,7 +146,7 @@ function verify_precon {
#Check PNETIDs
check_pnetids
if [ $? -ne 0 ]; then
return $?
return 1
fi
return 0
@@ -175,7 +175,7 @@ function add_hsci {
#### Verify preconditions
verify_precon
if [ $? -ne 0 ]; then
return $?
return 1
fi
hsci_postfix="$(readlink /sys/class/net/$hsdev/device/cdev0 | tail -c5)"