Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shellcheck check suspend resume with audio #1055

Conversation

greg-intel
Copy link
Contributor

Various shellcheck fixes, including quoting, source references and pgrep.

Work done under ticket #729

Signed-off-by: Greg Galloway [email protected]

Fix a variety of quote and quote-related issues per shellcheck's requests.

Signed-off-by: Greg Galloway <[email protected]>
The previous source reference for lib.sh triggers shellcheck errors.

Fixed a later BASH_SOURCE[0] reference to follow the same pattern.

Signed-off-by: Greg Galloway <[email protected]>
@greg-intel greg-intel requested a review from a team as a code owner June 12, 2023 22:29
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrote conditional of a sof-process-state.sh line (that was basically broken).

It's not obvious why and how it was broken; please explain in the commit message the bug and also update the commit title. When people read "shellcheck fixes" they assume barely any functional change and no bug fix.

Some projects even require an actual bug to be filed before submitting a fix but we're not that pedantic here :-)

fi
$(dirname ${BASH_SOURCE[0]})/check-suspend-resume.sh $(echo $opt) || die "suspend resume failed"
}
"$(dirname "${BASH_SOURCE[0]}")"/check-suspend-resume.sh "${opt_arr[@]}" || die "suspend resume failed"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please de-duplicate $(dirname "${BASH_SOURCE[0]}) with some new MYDIR variable like other scripts do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

fi
if [ ${OPT_VAL['r']} -eq 0 ]; then
opt="$opt -S ${OPT_VAL['S']} -w ${OPT_VAL['w']}"
opt_arr+=("-S" "${OPT_VAL['S']}" "-w" "${OPT_VAL['w']}")

This comment was marked as resolved.

else
opt="$opt -r"
opt_arr+=("-r")

This comment was marked as resolved.

@@ -78,57 +79,54 @@ fi

func_pipeline_export "$tplg" "type:${OPT_VAL['m']} & ${OPT_VAL['P']}"

opt_arr=("-l" "${OPT_VAL['l']}")

This comment was marked as resolved.

opt="-l ${OPT_VAL['l']} -T ${OPT_VAL['T']}"
else
opt="-l ${OPT_VAL['l']}"
opt_arr+=("-T" "${OPT_VAL['T']}")

This comment was marked as resolved.

@greg-intel greg-intel force-pushed the shellcheck-check-suspend-resume-with-audio branch 2 times, most recently from d7c4eb8 to 4e007b9 Compare June 13, 2023 23:04
@marc-hb
Copy link
Collaborator

marc-hb commented Jun 14, 2023

32c98bb8a2c56c removes quotes that are added by an earlier commit. Don't add them in the first place.

@greg-intel
Copy link
Contributor Author

32c98bb8a2c56c removes quotes that are added by an earlier commit. Don't add them in the first place.

There are many online examples that quote each element of arrays. Err'ing on the side of more quotes rather than less didn't seem like a serious problem.

http://mywiki.wooledge.org/BashGuide/Arrays for example has this:
names=("Bob" "Peter" "$USER" "Big Bad John")

Where the only elements that would otherwise require quotes are "$USER" and "Big Bad John".

Also the first search hit for "Bash arrays" is https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays
And one of their early examples is this:
myArray+=( "newElement1" "newElement2" )

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 14, 2023

There are many online examples that quote each element of arrays. Err'ing on the side of more quotes rather than less didn't seem like a serious problem.

This is a debatable code style question, I agree it can be subjective.

In any case:

  • Never fix code that was just changed in a previous commit in the same PR. Do it right in the first and only commit.
  • Don't do pure quoting fixes in lines that shellcheck had nothing to say about; I mean not in a "shellcheck" pull request.

Rewrote 'opt' to be an array.  Quoting opt as an argument

caused issues that won't manifest when it's an array.

Removed unnecessary quoting from array assignments.

Signed-off-by: Greg Galloway <[email protected]>
Replaced ps -ef | grep lines with pgrep.

Rewrote conditional of a sof-process-state.sh line (that was basically broken).
The script had 'set -e' so the command would fail and exit the script.
This prevented the follow-up lines, which were checking exit status ($?), from
ever being run if the command failed.

Removed unused variable assignment pcm).

Signed-off-by: Greg Galloway <[email protected]>
There were two references to $(dirname "${BASH_SOURCE[0]}),
so a temp variable was created to hold this reference.  The
two references were then re-written.

Signed-off-by: Greg Galloway <[email protected]>
@greg-intel greg-intel force-pushed the shellcheck-check-suspend-resume-with-audio branch from 4e007b9 to 1e7f1e2 Compare June 14, 2023 22:48
@greg-intel
Copy link
Contributor Author

@marc-hb are there further opens on this PR? I believe I've satisfied all the requests.

@greg-intel
Copy link
Contributor Author

SOFCI TEST

@marc-hb marc-hb requested a review from a team June 26, 2023 20:34
@marc-hb marc-hb merged commit 7be8beb into thesofproject:main Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants