]> git.ipfire.org Git - thirdparty/linux.git/commit - scripts/ver_linux
ver_linux: Drop redundant calls to system() to test if file is readable
authorAlexander Kapshuk <alexander.kapshuk@gmail.com>
Sat, 12 May 2018 09:02:31 +0000 (12:02 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 May 2018 14:36:39 +0000 (16:36 +0200)
commit1c9a4be514e7a946f7811f10d6d0ebab1ec6dd56
treeab1c1efd3a31b5fa6288b18990cfa49d412f4300
parent4169bc43dbdd6c08436a7d794844b1f09a6367ae
ver_linux: Drop redundant calls to system() to test if file is readable

Running 'test -r' on an awk variable name whose value is an empty
string results in test being run with no arguments, and causes system()
to return 0, which indicates success when used to test values returned
by function calls. This results in code within the if blocks being run
when it should not be.
Instead of testing if a file is accessible and readable via calls to
system("test -r " file), rely on the value returned by getline to perform
this kind of testing. Getline returns -1 on error, with the code within
the while loops not being run.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
scripts/ver_linux