Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F859C433F5 for ; Fri, 26 Nov 2021 20:21:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 57FA3834AC; Fri, 26 Nov 2021 21:20:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="NFCSTvA0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C55D683230; Fri, 26 Nov 2021 21:20:57 +0100 (CET) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 34B0C830F6 for ; Fri, 26 Nov 2021 21:20:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 8876F3F1E5 for ; Fri, 26 Nov 2021 20:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1637958053; bh=6+nd12jxQPLC8xXoZ4HWDLRstcWf0AK1rC+/HHhV6HU=; h=Message-ID:Date:MIME-Version:To:From:Cc:Subject:Content-Type; b=NFCSTvA0xEtjOpI3/9G/nQbyliPuF+E6A3xTX0Q2OpmOiJpXsNsQcKlosWye/5t3a bNqp0xOlYD7TzeFJ0Zk11We/BSjcmgB+X8NdwNgHWydcEyCvywA3r/vOw8bQf4GAKo um40hTzQ27RIBP+MM0OjqOISOJ3Jg20L9s99byT00EcLusKsHKkl6jnJkX6ifr2TKo FUj6W6NbbkWjW/sArFE5ptVpfePnd2et/9AisxCyrsfgPwMdv9ihbtDmb3rb/qvu92 4POQ8n7wjggbLTuhiyM1vXbSE26S9JxKTgC4k7fmVoXx2iUw8Yn9rJI+vOqf2RfXiO T4L4a8dMwjqig== Received: by mail-wm1-f72.google.com with SMTP id 145-20020a1c0197000000b0032efc3eb9bcso7438439wmb.0 for ; Fri, 26 Nov 2021 12:20:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:from:cc:subject:content-transfer-encoding; bh=6+nd12jxQPLC8xXoZ4HWDLRstcWf0AK1rC+/HHhV6HU=; b=CqpqPL/Vg71qD0ly2YCzK0cInWdDsVBcHE0u86PzOTIOjTgX4+l/66a/D4mXxydyO0 e+3bZQhZrDMDXK1wrEX1Q6HEsK9OrY1FpXdgLSgsdLj1IXnx/U2JwTIKUh/mjXCilaNZ x1lg4fycSNizjS4PhscimFObLWl/hSv4w14SgT606Db3NwGKTqGEeIwLECeN914BwFrQ W+aWHIvnjsB80qTi/P34ODcrxGmZhEn6+fE73VZPSGrtESu2KH/YFIm3J/j1drRH65oK yzzjeyXvnGS8U/Qt2SEmV2IcBDb6tzP9gY7ZGTsS2UHPaCIu3U8deG+V0up1K9KuX4Xw tOuA== X-Gm-Message-State: AOAM533GrGmHp97Qvk+m9KmmaMh4pCXwaL0k4off9uXsKEFPT3tkF4TN E1IULKGWzmweRxQutx4oArncKsAXjGFTOHWyRHlxKcRCQ5eDmvU32SOWiJbt9Dhsj5gKscE56WT hHkAw4NWe1swio5et9jbKJ6F0/5T6Es4= X-Received: by 2002:a7b:c934:: with SMTP id h20mr18751138wml.94.1637958053195; Fri, 26 Nov 2021 12:20:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGFbeboFI9jb45jRJNwKZLXNQ0ao1X0/F7BxdSmsnU7+R2tksXxulI5gF6nbRcKYfW2hAr5A== X-Received: by 2002:a7b:c934:: with SMTP id h20mr18751119wml.94.1637958052985; Fri, 26 Nov 2021 12:20:52 -0800 (PST) Received: from [192.168.123.55] (ip-88-152-144-157.hsi03.unitymediagroup.de. [88.152.144.157]) by smtp.gmail.com with ESMTPSA id y15sm8137235wry.72.2021.11.26.12.20.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Nov 2021 12:20:52 -0800 (PST) Message-ID: <29c2900d-c2f5-2c21-86fc-520ec19187f5@canonical.com> Date: Fri, 26 Nov 2021 21:20:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Content-Language: en-US To: Masahisa Kojima , Ruchika Gupta , Ilias Apalodimas From: Heinrich Schuchardt Cc: U-Boot Mailing List Subject: [BUG] cppcheck results for efi_tcg2.c Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hello Masahisa, Ilias, Ruchika, please, have a look at the cppcheck results for efi_tcg2.c. [unusedFunction] may be due to checking a single file. [arithOperationsOnVoidPointer] you might ignore. But the rest should be addressed. Best regards Heinrich $ cppcheck lib/efi_loader/efi_tcg2.c --enable=all --std=c11 Checking lib/efi_loader/efi_tcg2.c ... Checking lib/efi_loader/efi_tcg2.c: __ASSEMBLY__... lib/efi_loader/efi_tcg2.c:1537:6: style: Local variable 'buffer' shadows outer variable [shadowVariable] u8 buffer[TPM2_SHA512_DIGEST_SIZE] = { 0 }; ^ lib/efi_loader/efi_tcg2.c:1497:8: note: Shadowed declaration void *buffer; ^ lib/efi_loader/efi_tcg2.c:1537:6: note: Shadow variable u8 buffer[TPM2_SHA512_DIGEST_SIZE] = { 0 }; ^ include/efi_api.h:991:23: portability: '(void*)blk' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] return ((void *)blk) + sizeof(*blk) + ^ include/efi_api.h:991:38: portability: '((void*)blk)+sizeof(*blk)' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] return ((void *)blk) + sizeof(*blk) + ^ lib/efi_loader/efi_tcg2.c:858:55: portability: 'event_log.buffer' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] *event_log_last_entry = (uintptr_t)(event_log.buffer + event_log.pos - ^ lib/efi_loader/efi_tcg2.c:858:71: portability: 'event_log.buffer+event_log.pos' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] *event_log_last_entry = (uintptr_t)(event_log.buffer + event_log.pos - ^ lib/efi_loader/efi_tcg2.c:1016:34: portability: 'efi' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] nt = (IMAGE_NT_HEADERS32 *)(efi + dos->e_lfanew); ^ lib/efi_loader/efi_tcg2.c:1644:16: portability: 'buffer' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] memset(buffer + spec_event_size, 0, 1); ^ Heinrich: For writing a single byte you should use an assignment after converting to u8* instead of calling a library function. lib/efi_loader/efi_tcg2.c:1359:11: style: Variable 'hash_sz' is assigned a value that is never used. [unreadVariable] hash_sz = ^ lib/efi_loader/efi_tcg2.c:1439:13: style: Variable 'event_type' is assigned a value that is never used. [unreadVariable] event_type = get_unaligned_le32(&event->event_type); ^ lib/efi_loader/efi_tcg2.c:2223:0: style: The function 'efi_tcg2_measure_efi_app_exit' is never used. [unusedFunction] ^ lib/efi_loader/efi_tcg2.c:2170:0: style: The function 'efi_tcg2_measure_efi_app_invocation' is never used. [unusedFunction] ^ lib/efi_loader/efi_tcg2.c:2277:0: style: The function 'efi_tcg2_notify_exit_boot_services_failed' is never used. [unusedFunction] ^ lib/efi_loader/efi_tcg2.c:2358:0: style: The function 'efi_tcg2_register' is never used. [unusedFunction] ^ lib/efi_loader/efi_tcg2.c:951:0: style: The function 'tcg2_measure_pe_image' is never used. [unusedFunction]