build: encapsulate grep for local_miss_maps in a function

Message ID 20220308185243.3629626-1-usama.arif@bytedance.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series build: encapsulate grep for local_miss_maps in a function |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/github-robot: build success github build: passed

Commit Message

Usama Arif March 8, 2022, 6:52 p.m. UTC
  check-symbols-maps.sh runs with the -e option to exit as soon as
there is an error. Currently the build is failing as the search of
grep -L is empty (which is the case for all version.map files as
they have the local symbol) which causes the script to return
with an error.
This patch encapsulates the grep call in a function, so that only the function
errors out and the build is successful.

Fixes: b403498e14 ("build: hide local symbols in shared libraries")
Cc: stable@dpdk.org
Signed-off-by: Usama Arif <usama.arif@bytedance.com>
---
 devtools/check-symbol-maps.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon March 8, 2022, 9:05 p.m. UTC | #1
08/03/2022 19:52, Usama Arif:
> check-symbols-maps.sh runs with the -e option to exit as soon as
> there is an error. Currently the build is failing as the search of
> grep -L is empty (which is the case for all version.map files as
> they have the local symbol) which causes the script to return
> with an error.

It depends on the shell I guess because most machines run well.

> This patch encapsulates the grep call in a function, so that only the function
> errors out and the build is successful.

That's a strange workaround. I don't understand why it works.
I am submitting a simpler fix adding " || true"

> -local_miss_maps=$(grep -L 'local: \*;' $@)
> +find_local_miss_maps ()
> +{
> +    local local_miss_maps=$(grep -L 'local: \*;' $@)
> +    echo "$local_miss_maps"
> +
> +}
> +
> +local_miss_maps=$(find_local_miss_maps $@)

Thanks for raising the issue and proposing a solution.
  

Patch

diff --git a/devtools/check-symbol-maps.sh b/devtools/check-symbol-maps.sh
index 8266fdf9ea..96c479138f 100755
--- a/devtools/check-symbol-maps.sh
+++ b/devtools/check-symbol-maps.sh
@@ -53,7 +53,14 @@  if [ -n "$duplicate_symbols" ] ; then
     ret=1
 fi
 
-local_miss_maps=$(grep -L 'local: \*;' $@)
+find_local_miss_maps ()
+{
+    local local_miss_maps=$(grep -L 'local: \*;' $@)
+    echo "$local_miss_maps"
+
+}
+
+local_miss_maps=$(find_local_miss_maps $@)
 if [ -n "$local_miss_maps" ] ; then
     echo "Found maps without local catch-all:"
     echo "$local_miss_maps"