Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Nov 2017 12:07:57 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r325641 - in head/sys/boot/efi: include libefi
Message-ID:  <201711101207.vAAC7voR067326@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Fri Nov 10 12:07:56 2017
New Revision: 325641
URL: https://svnweb.freebsd.org/changeset/base/325641

Log:
  loader.efi: efi_devpath_is_prefix should return bool
  
  efi_devpath_is_prefix() is currently returning values 0 or 1, which means
  it really should return bool.
  
  Additionally, use unsigned len, because we only get unsigned values from
  DevicePathNodeLength().

Modified:
  head/sys/boot/efi/include/efilib.h
  head/sys/boot/efi/libefi/devpath.c

Modified: head/sys/boot/efi/include/efilib.h
==============================================================================
--- head/sys/boot/efi/include/efilib.h	Fri Nov 10 11:19:47 2017	(r325640)
+++ head/sys/boot/efi/include/efilib.h	Fri Nov 10 12:07:56 2017	(r325641)
@@ -82,7 +82,7 @@ EFI_HANDLE efi_devpath_handle(EFI_DEVICE_PATH *);
 EFI_DEVICE_PATH *efi_devpath_last_node(EFI_DEVICE_PATH *);
 EFI_DEVICE_PATH *efi_devpath_trim(EFI_DEVICE_PATH *);
 bool efi_devpath_match(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
-int efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
+bool efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
 CHAR16 *efi_devpath_name(EFI_DEVICE_PATH *);
 void efi_free_devpath_name(CHAR16 *);
 

Modified: head/sys/boot/efi/libefi/devpath.c
==============================================================================
--- head/sys/boot/efi/libefi/devpath.c	Fri Nov 10 11:19:47 2017	(r325640)
+++ head/sys/boot/efi/libefi/devpath.c	Fri Nov 10 12:07:56 2017	(r325641)
@@ -167,13 +167,13 @@ efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVIC
 	return (true);
 }
 
-int
+bool
 efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEVICE_PATH *path)
 {
-	int len;
+	size_t len;
 
 	if (prefix == NULL || path == NULL)
-		return (0);
+		return (false);
 
 	while (1) {
 		if (IsDevicePathEnd(prefix))
@@ -181,17 +181,17 @@ efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEV
 
 		if (DevicePathType(prefix) != DevicePathType(path) ||
 		    DevicePathSubType(prefix) != DevicePathSubType(path))
-			return (0);
+			return (false);
 
 		len = DevicePathNodeLength(prefix);
 		if (len != DevicePathNodeLength(path))
-			return (0);
+			return (false);
 
-		if (memcmp(prefix, path, (size_t)len) != 0)
-			return (0);
+		if (memcmp(prefix, path, len) != 0)
+			return (false);
 
 		prefix = NextDevicePathNode(prefix);
 		path = NextDevicePathNode(path);
 	}
-	return (1);
+	return (true);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711101207.vAAC7voR067326>