Module Name:    src
Committed By:   martin
Date:           Wed Jul 14 18:56:05 UTC 2021

Modified Files:
        src/usr.sbin/sysinst: disks.c

Log Message:
When converting partitions from one scheme to another, never fail
without providing (if requested) a proper error message.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/usr.sbin/sysinst/disks.c

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

Modified files:

Index: src/usr.sbin/sysinst/disks.c
diff -u src/usr.sbin/sysinst/disks.c:1.72 src/usr.sbin/sysinst/disks.c:1.73
--- src/usr.sbin/sysinst/disks.c:1.72	Sun Jan 31 22:45:46 2021
+++ src/usr.sbin/sysinst/disks.c	Wed Jul 14 18:56:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: disks.c,v 1.72 2021/01/31 22:45:46 rillig Exp $ */
+/*	$NetBSD: disks.c,v 1.73 2021/07/14 18:56:05 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -754,17 +754,23 @@ convert_scheme(struct pm_devs *p, bool i
 	new_scheme = select_part_scheme(p, old_parts->pscheme,
 	    false, MSG_select_other_partscheme);
 
-	if (new_scheme == NULL)
+	if (new_scheme == NULL) {
+		if (err_msg)
+			*err_msg = INTERNAL_ERROR;
 		return false;
+	}
 
 	new_parts = new_scheme->create_new_for_disk(p->diskdev,
 	    0, p->dlsize, is_boot_drive, NULL);
-	if (new_parts == NULL)
+	if (new_parts == NULL) {
+		if (err_msg)
+			*err_msg = MSG_out_of_memory;
 		return false;
+	}
 
 	convert_copy(old_parts, new_parts);
 
-	if (new_parts->num_part == 0) {
+	if (new_parts->num_part == 0 && old_parts->num_part != 0) {
 		/* need to cleanup */
 		new_parts->pscheme->free(new_parts);
 		return false;

Reply via email to