Module Name:    src
Committed By:   jmcneill
Date:           Thu May 14 23:09:29 UTC 2020

Modified Files:
        src/sys/stand/efiboot: efirng.c

Log Message:
Make efi_rng_show return early if RNG protocol is not available. While
here, use efi_rng_available() consistently, prefix all show messages with
"RNG: ", and use sizeof(foo) instead of sizeof foo.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efirng.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/stand/efiboot/efirng.c
diff -u src/sys/stand/efiboot/efirng.c:1.1 src/sys/stand/efiboot/efirng.c:1.2
--- src/sys/stand/efiboot/efirng.c:1.1	Thu May 14 19:19:08 2020
+++ src/sys/stand/efiboot/efirng.c	Thu May 14 23:09:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: efirng.c,v 1.1 2020/05/14 19:19:08 riastradh Exp $	*/
+/*	$NetBSD: efirng.c,v 1.2 2020/05/14 23:09:29 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -79,13 +79,16 @@ void
 efi_rng_show(void)
 {
 	EFI_RNG_ALGORITHM alglist[10];
-	UINTN i, j, alglistsz = sizeof alglist;
+	UINTN i, j, alglistsz = sizeof(alglist);
 	EFI_STATUS status;
 
+	if (!efi_rng_available())
+		return;
+
 	/* Query the list of supported algorithms.  */
 	status = uefi_call_wrapper(rng->GetInfo, 3, rng, &alglistsz, alglist);
 	if (EFI_ERROR(status)) {
-		Print(L"efirng: GetInfo: %r\n", status);
+		Print(L"RNG: GetInfo: %r\n", status);
 		return;
 	}
 
@@ -115,7 +118,7 @@ efi_rng(void *buf, UINTN len)
 {
 	EFI_STATUS status;
 
-	if (rng == NULL)
+	if (!efi_rng_available())
 		return EIO;
 
 	status = uefi_call_wrapper(rng->GetRNG, 3, rng, &RngAlgorithmRawGuid,

Reply via email to