[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/4] xen/scripts: add cppcheck tool to the xen-analysis.py script


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Fri, 2 Dec 2022 13:09:42 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JSPYDTL9Z7qKEwIBGGIqNGW++lPeTNR8PmK7I4zYk3E=; b=B08tKjSQkR9OOs+qweQ8zg6Cw0giywNsSl4L4CEcrLPydk2S5PqeEAeVIkbX51bxK7dalyxytpPjykUeMf7b/l0QNPjhLyT59Faw8VK+1euE90/brzQ5FTR7hZZ7m7gNtG58bMLBksgWjVMePgVvAt2lPNz85SNh9ptSCdTHZyy2hC9+UQqM8nvLT1Lc26Qh3kao34tfOAKeONznXxrXeriKVNGxf0c32TK9y1Dca9MAOl3h8rHHXZtTD0/dYPaNMgHvJ2DptOtlk77xqfAI21ysH4TFt0IIJnQKhfdvWXZPEVP+4O6ES7cWW6FEZFUeOXiV7NE/phui1b9z59kpjg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RRHC+NlTZjUkbk0Nzp8Yjbg8dQd6vbMdfLFHYyFhmF/d7D+BTOFaEfPavSSEM4ZP6VfkaHTCnxyFn9Dh7grWZFjg4Iq1NFtGimqgBep7CRqGF+k/4inovixBk7kkoHyIJKaBbvisiudYBto/4I5Z/22QWqayhfUo7kdrUUC47muSL0lcOWjICsf8tu4LZ0YBhTPdF1YkOyrs669lownFn48l9vASnS/+OcgIKPc/CzrcE5yvpLubQfssVBSsGxjgykpY1ZaSUvzXj9GTdfh3EuXXYJNI4MC1etLaU26oGaVw2IT/SLQHSoVPKvWVFpCOLrCOdghimnLu42u8iC8dDQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 02 Dec 2022 13:10:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHZAzNLrQ+cdSzeJ02hq/RTLwHjha5WqVKAgAC2sICAAI2ugIABQKAAgABQ4YCAARkTgA==
  • Thread-topic: [PATCH 2/4] xen/scripts: add cppcheck tool to the xen-analysis.py script


> On 1 Dec 2022, at 20:23, Stefano Stabellini <sstabellini@xxxxxxxxxx> wrote:
> 
> On Thu, 1 Dec 2022, Luca Fancellu wrote:
>> Hi Stefano,
>> 
>>>>> 
>>>>> 
>>>>>> +            sm_tool_args="n"
>>>>>> +            ;;
>>>>>> +        --cppcheck-cmd=*)
>>>>>> +            CPPCHECK_TOOL="$(eval echo "${OPTION#*=}")"
>>>>>> +            sm_tool_args="y"
>>>>>> +            ;;
>>>>>> +        --cppcheck-html)
>>>>>> +            CPPCHECK_HTML="y"
>>>>>> +            sm_tool_args="n"
>>>>>> +            ;;
>>>>>> +        --cppcheck-plat=*)
>>>>>> +            CPPCHECK_PLAT_PATH="$(eval echo "${OPTION#*=}")"
>>>>>> +            sm_tool_args="n"
>>>>>> +            ;;
>>>>>> +        --ignore-path=*)
>>>>>> +            IGNORE_PATH_LIST="${IGNORE_PATH_LIST} $(eval echo 
>>>>>> "${OPTION#*=}")"
>>>>>> +            sm_tool_args="n"
>>>>>> +            ;;
>>>>>> +        --)
>>>>>> +            forward_to_cc="y"
>>>>>> +            sm_tool_args="n"
>>>>>> +            ;;
>>>>>> +        *)
>>>>>> +            if [ "${sm_tool_args}" = "y" ]; then
>>>>>> +                CPPCHECK_TOOL_ARGS="${CPPCHECK_TOOL_ARGS} ${OPTION}"
>>>>>> +            else
>>>>>> +                echo "Invalid option ${OPTION}"
>>>>>> +                exit 1
>>>>> 
>>>>> It doesn't look like sm_tool_args is really needed? It is only set to
>>>>> 'y' in the case of --cppcheck-cmd, and in that case we also set
>>>>> CPPCHECK_TOOL. CPPCHECK_TOOL is the variable used below. Am I missing
>>>>> something?
>>>> 
>>>> We use sm_tool_args to fill CPPCHECK_TOOL_ARGS, basically it’s a state 
>>>> machine where
>>>> when we find --cppcheck-cmd=<xxx> we expect that every other space 
>>>> separated arguments
>>>> passed afterwards are the args for cppcheck, so we append to 
>>>> CPPCHECK_TOOL_ARGS
>>>> until we find an argument that is supposed to be only for this script.
>>> 
>>> That seems a bit unnecessary: if the user wants to pass arguments to
>>> cppcheck, the user would do --cppcheck-cmd="cppcheck arg1 arg2" with ""
>>> quotes. Doing that should make --cppcheck-cmd="cppcheck arg1 arg2" be
>>> seen as a single argument from this script point of view. CPPCHECK_TOOL
>>> would end up being set to "cppcheck arg1 arg2" which is what we want
>>> anyway? And if we need to distinguish between the cppcheck binary and
>>> its argument we could use "cut" to extract "cppcheck", "arg1", and
>>> "arg2" from CPPCHECK_TOOL.  Would that work?
>>> 
>> 
>> I gave a try for the quotes, the problem is that we need to have quotes in 
>> CC=“...”, so adding
>> quotes also to --cppcheck-cmd= which is inside CC=“...” is preventing the 
>> Makefile to work,
>> I tried escaping etc but I didn’t manage to have it working, so would you 
>> agree on keeping it
>> like that?
> 
> Is the problem coming from the following?
> 
>    cppcheck_cc_flags = """--compiler={} --cppcheck-cmd={} {}
> --cppcheck-plat={}/cppcheck-plat --ignore-path=tools/
> """.format(xen_cc, settings.cppcheck_binpath, cppcheck_flags,
>           settings.tools_dir)
> 
>    if settings.cppcheck_html:
>        cppcheck_cc_flags = cppcheck_cc_flags + " --cppcheck-html"
> 
>    # Generate the extra make argument to pass the cppcheck-cc.sh wrapper as CC
>    cppcheck_extra_make_args = "CC=\"{}/cppcheck-cc.sh {} --\"".format(
>                                        settings.tools_dir,
>                                        cppcheck_cc_flags
>                                    ).replace("\n", "")
> 
> 
> Wouldn't something like the following solve the issue?
> 
>    settings.cppcheck_binpath = settings.cppcheck_binpath + " " + 
> cppcheck_cc_flags
> 
>    cppcheck_cc_flags = """--compiler={} --cppcheck-cmd=\"{}\"
> --cppcheck-plat={}/cppcheck-plat --ignore-path=tools/
> """.format(xen_cc, settings.cppcheck_binpath, settings.tools_dir)
> 
>    if settings.cppcheck_html:
>        cppcheck_cc_flags = cppcheck_cc_flags + " --cppcheck-html"
> 
>    # Generate the extra make argument to pass the cppcheck-cc.sh wrapper as CC
>    cppcheck_extra_make_args = "CC=\"{}/cppcheck-cc.sh {} --\"".format(
>                                        settings.tools_dir,
>                                        cppcheck_cc_flags
>                                    ).replace("\n", "")

No unfortunately not, Makefile is very sensitive to quotes, I’ve tried with 
many combination of single/double quotes but nothing worked




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.