From f5734067a3705d6d645f2a2ff08a9ec1f7839588 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Wed, 1 Nov 2023 18:24:07 +0100 Subject: [PATCH] Update properties file for inquiry mode --- cpp/scsidump/scsidump_core.cpp | 8 +++++--- cpp/test/scsidump_test.cpp | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cpp/scsidump/scsidump_core.cpp b/cpp/scsidump/scsidump_core.cpp index 097e2e929b..a913f41687 100644 --- a/cpp/scsidump/scsidump_core.cpp +++ b/cpp/scsidump/scsidump_core.cpp @@ -698,9 +698,11 @@ void ScsiDump::inquiry_info::GeneratePropertiesFile(const string& property_file) out << "{" << endl << " \"vendor\": \"" << vendor << "\"," << endl << " \"product\": \"" << product << "\"," << endl - << " \"revision\": \"" << revision << "\"," << endl - << " \"block_size\": \"" << sector_size << "\"" << endl - << "}" << endl; + << " \"revision\": \"" << revision << "\""; + if (sector_size) { + out << "," << endl << " \"block_size\": \"" << sector_size << "\""; + } + out << endl << "}" << endl; if (out.fail()) { cerr << "Error: Can't create properties file '" + property_file + "'" << endl; diff --git a/cpp/test/scsidump_test.cpp b/cpp/test/scsidump_test.cpp index 2e055157c9..5ad413365a 100644 --- a/cpp/test/scsidump_test.cpp +++ b/cpp/test/scsidump_test.cpp @@ -58,8 +58,7 @@ TEST(ScsiDumpTest, GeneratePropertiesFile) expected_str = "{\n" " \"vendor\": \"\",\n" " \"product\": \"\",\n" - " \"revision\": \"\",\n" - " \"block_size\": \"0\"\n" + " \"revision\": \"\"\n" "}\n"; EXPECT_EQ(expected_str, ReadTempFileToString(filename)); remove(filename);