commit:     f8669c1089dd9962d946c7be46a17fdd1cd2ebd8
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 14 23:17:27 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sat Mar 14 23:17:58 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f8669c10

flag-o-matic.eclass: add assertions around argument counts

Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 eclass/flag-o-matic.eclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 79f825222a2..39dae290af0 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -392,6 +392,7 @@ filter-mfpmath() {
 # Strip *FLAGS of everything except known good/safe flags.  This runs over all
 # flags returned by all_flag_vars().
 strip-flags() {
+       [[ $# -ne 0 ]] && die "strip-flags takes no arguments"
        local x y var
 
        local ALLOWED_FLAGS
@@ -618,6 +619,7 @@ test_version_info() {
 # @DESCRIPTION:
 # Strip {C,CXX,F,FC}FLAGS of any flags not supported by the active toolchain.
 strip-unsupported-flags() {
+       [[ $# -ne 0 ]] && die "strip-unsupported-flags takes no arguments"
        export CFLAGS=$(test-flags-CC ${CFLAGS})
        export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
        export FFLAGS=$(test-flags-F77 ${FFLAGS})
@@ -630,6 +632,7 @@ strip-unsupported-flags() {
 # @DESCRIPTION:
 # Find and echo the value for a particular flag.  Accepts shell globs.
 get-flag() {
+       [[ $# -ne 1 ]] && die "usage: <flag>"
        local f var findflag="$1"
 
        # this code looks a little flaky but seems to work for
@@ -652,6 +655,7 @@ get-flag() {
 # @DESCRIPTION:
 # Sets mcpu to v8 and uses the original value as mtune if none specified.
 replace-sparc64-flags() {
+       [[ $# -ne 0 ]] && die "replace-sparc64-flags takes no arguments"
        local SPARC64_CPUS="ultrasparc3 ultrasparc v9"
 
        if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
@@ -735,6 +739,7 @@ raw-ldflags() {
 # @FUNCTION: no-as-needed
 # @RETURN: Flag to disable asneeded behavior for use with append-ldflags.
 no-as-needed() {
+       [[ $# -ne 0 ]] && die "no-as-needed takes no arguments"
        case $($(tc-getLD) -v 2>&1 </dev/null) in
                *GNU*) # GNU ld
                echo "-Wl,--no-as-needed" ;;

Reply via email to