From 876ddc1adbb24de48bf977e4c601ab246323ebf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
Date: Sun, 23 Oct 2022 19:10:04 +0200
Subject: [PATCH] mountvolume: return type of ContentName() is now BString
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

fixes #18011

Change-Id: Ie8dda950005c191c843535b12f7cf8f9819bdcfb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5757
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
---
 src/bin/mountvolume.cpp | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/bin/mountvolume.cpp b/src/bin/mountvolume.cpp
index 43c4c5aebc..db983dd8d0 100644
--- a/src/bin/mountvolume.cpp
+++ b/src/bin/mountvolume.cpp
@@ -163,19 +163,19 @@ struct MountVisitor : public BDiskDeviceVisitor {
 	virtual bool Visit(BPartition* partition, int32 level)
 	{
 		// get name and type
-		const char* name = partition->ContentName();
-		if (!name)
+		BString name = partition->ContentName();
+		if (name.IsEmpty())
 			name = partition->Name();
 		const char* type = partition->ContentType();
 
 		// check whether to mount
 		bool mount = false;
-		if (name && toMount.find(name) != toMount.end()) {
-			toMount.erase(name);
+		if (name && toMount.find(name.String()) != toMount.end()) {
+			toMount.erase(name.String());
 			if (!partition->IsMounted())
 				mount = true;
 			else if (!silent)
-				fprintf(stderr, "Volume `%s' already mounted.\n", name);
+				fprintf(stderr, "Volume `%s' already mounted.\n", name.String());
 		} else if (mountAll) {
 			mount = true;
 		} else if (mountBFS && type != NULL
@@ -196,13 +196,13 @@ struct MountVisitor : public BDiskDeviceVisitor {
 
 		// check whether to unmount
 		bool unmount = false;
-		if (name && toUnmount.find(name) != toUnmount.end()) {
-			toUnmount.erase(name);
+		if (name && toUnmount.find(name.String()) != toUnmount.end()) {
+			toUnmount.erase(name.String());
 			if (partition->IsMounted()) {
 				unmount = true;
 				mount = false;
 			} else if (!silent)
-				fprintf(stderr, "Volume `%s' not mounted.\n", name);
+				fprintf(stderr, "Volume `%s' not mounted.\n", name.String());
 		}
 
 		// mount/unmount
@@ -213,11 +213,11 @@ struct MountVisitor : public BDiskDeviceVisitor {
 				if (error >= B_OK) {
 					BPath mountPoint;
 					partition->GetMountPoint(&mountPoint);
-					printf("Volume `%s' mounted successfully at '%s'.\n", name,
+					printf("Volume `%s' mounted successfully at '%s'.\n", name.String(),
 						mountPoint.Path());
 				} else {
 					fprintf(stderr, "Failed to mount volume `%s': %s\n",
-						name, strerror(error));
+						name.String(), strerror(error));
 				}
 			}
 			if (openInTracker && error == B_OK)
@@ -226,10 +226,10 @@ struct MountVisitor : public BDiskDeviceVisitor {
 			status_t error = partition->Unmount();
 			if (!silent) {
 				if (error == B_OK) {
-					printf("Volume `%s' unmounted successfully.\n", name);
+					printf("Volume `%s' unmounted successfully.\n", name.String());
 				} else {
 					fprintf(stderr, "Failed to unmount volume `%s': %s\n",
-						name, strerror(error));
+						name.String(), strerror(error));
 				}
 			}
 		}
@@ -269,10 +269,10 @@ struct PrintPartitionsVisitor : public BDiskDeviceVisitor {
 	virtual bool Visit(BPartition* partition, int32 level)
 	{
 		// get name and type
-		const char* name = partition->ContentName();
-		if (name == NULL || name[0] == '\0') {
+		BString name = partition->ContentName();
+		if (name.IsEmpty()) {
 			name = partition->Name();
-			if (name == NULL || name[0] == '\0') {
+			if (name.IsEmpty()) {
 				if (partition->ContainsFileSystem())
 					name = "<unnamed>";
 				else
@@ -301,7 +301,7 @@ struct PrintPartitionsVisitor : public BDiskDeviceVisitor {
 		if (partition->IsMounted())
 			partition->GetMountPoint(&mountPoint);
 
-		printf("%-*s %-*s %8s %s%s(%s)\n", sVolumeNameWidth, name,
+		printf("%-*s %-*s %8s %s%s(%s)\n", sVolumeNameWidth, name.String(),
 			sFSNameWidth, type, size_string(partition->Size()),
 			partition->IsMounted() ? mountPoint.Path() : "",
 			partition->IsMounted() ? "  " : "",