mirror of
				https://github.com/smaeul/u-boot.git
				synced 2025-11-03 21:48:15 +00:00 
			
		
		
		
	num_entries should be unsigned to avoid warnings. As the target field is
u16 we should use this type.
    lib/efi_loader/efi_conformance.c: In function ‘efi_ecpt_register’:
    lib/efi_loader/efi_conformance.c:30:33: warning:
    conversion to ‘long unsigned int’ from ‘int’ may change
    the sign of the result [-Wsign-conversion]
       30 |         ecpt_size = num_entries * sizeof(efi_guid_t)
          |                                 ^
    lib/efi_loader/efi_conformance.c:46:36: warning:
    conversion from ‘int’ to ‘u16’ {aka ‘short unsigned int’}
    may change value [-Wconversion]
       46 |         ecpt->number_of_profiles = num_entries;
          |                                    ^~~~~~~~~~~
Fixes: 6b92c1735205 ("efi: Create ECPT table")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
		
	
			
		
			
				
	
	
		
			61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
// SPDX-License-Identifier: GPL-2.0-only
 | 
						|
/*
 | 
						|
 *  EFI conformance profile table
 | 
						|
 *
 | 
						|
 *  Copyright (C) 2022 Arm Ltd.
 | 
						|
 */
 | 
						|
 | 
						|
#include <common.h>
 | 
						|
#include <efi_loader.h>
 | 
						|
#include <log.h>
 | 
						|
#include <efi_api.h>
 | 
						|
#include <malloc.h>
 | 
						|
 | 
						|
static const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
 | 
						|
static const efi_guid_t efi_ebbr_2_1_guid =
 | 
						|
	EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID;
 | 
						|
 | 
						|
/**
 | 
						|
 * efi_ecpt_register() - Install the ECPT system table.
 | 
						|
 *
 | 
						|
 * Return: status code
 | 
						|
 */
 | 
						|
efi_status_t efi_ecpt_register(void)
 | 
						|
{
 | 
						|
	u16 num_entries = 0;
 | 
						|
	struct efi_conformance_profiles_table *ecpt;
 | 
						|
	efi_status_t ret;
 | 
						|
	size_t ecpt_size;
 | 
						|
 | 
						|
	ecpt_size = num_entries * sizeof(efi_guid_t)
 | 
						|
		+ sizeof(struct efi_conformance_profiles_table);
 | 
						|
	ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size,
 | 
						|
				(void **)&ecpt);
 | 
						|
 | 
						|
	if (ret != EFI_SUCCESS) {
 | 
						|
		log_err("Out of memory\n");
 | 
						|
 | 
						|
		return ret;
 | 
						|
	}
 | 
						|
 | 
						|
	if (CONFIG_IS_ENABLED(EFI_EBBR_2_1_CONFORMANCE))
 | 
						|
		guidcpy(&ecpt->conformance_profiles[num_entries++],
 | 
						|
			&efi_ebbr_2_1_guid);
 | 
						|
 | 
						|
	ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION;
 | 
						|
	ecpt->number_of_profiles = num_entries;
 | 
						|
 | 
						|
	/* Install the ECPT in the system configuration table. */
 | 
						|
	ret = efi_install_configuration_table(&efi_ecpt_guid, (void *)ecpt);
 | 
						|
	if (ret != EFI_SUCCESS) {
 | 
						|
		log_err("Failed to install ECPT\n");
 | 
						|
		efi_free_pool(ecpt);
 | 
						|
 | 
						|
		return ret;
 | 
						|
	}
 | 
						|
 | 
						|
	log_debug("ECPT created\n");
 | 
						|
 | 
						|
	return EFI_SUCCESS;
 | 
						|
}
 |