smbios-mdr: Clean up warnings from newer compiler
No functional change. Cleaned up appropriate code to work around
compiler warnings. The switch to Meson also entails a newer compiler
version, which gives more warnings than before.
Due to the trivial nature of this change, it was requested that it be
merged into a previous patch instead of creating a new patch.
Tested: It builds and it runs, as expected.
Google-Bug-Id: 298750329
Change-Id: I90de0a4e34a3b6a888ecd1d3c7589e68b5791f2b
Signed-off-by: Josh Lehan <krellan@google.com>
diff --git a/recipes-phosphor/smbios/smbios-mdr/0006-Update-gRPC-blobs-to-make-use-of-file-support.patch b/recipes-phosphor/smbios/smbios-mdr/0006-Update-gRPC-blobs-to-make-use-of-file-support.patch
index 412a9ce..9c8c336 100644
--- a/recipes-phosphor/smbios/smbios-mdr/0006-Update-gRPC-blobs-to-make-use-of-file-support.patch
+++ b/recipes-phosphor/smbios/smbios-mdr/0006-Update-gRPC-blobs-to-make-use-of-file-support.patch
@@ -1,7 +1,7 @@
-From 3225ebb73d5609a8c0ad728ba880ebbd047b644d Mon Sep 17 00:00:00 2001
+From fc7d7a5524f0db536b9d7667bcbda4b2b224fa1d Mon Sep 17 00:00:00 2001
From: Josh Lehan <krellan@google.com>
Date: Thu, 10 Aug 2023 14:06:24 +0000
-Subject: [PATCH 6/6] Update gRPC blobs to make use of file support
+Subject: [PATCH] Update gRPC blobs to make use of file support
Updating the gRPC handler, and surrounding code, to make use of the
smbios_file module just added. The actual gRPC call remains unchanged.
@@ -23,11 +23,11 @@
Signed-off-by: Josh Lehan <krellan@google.com>
---
- src/smbios-grpc-blobs/smbios_grpc.cpp | 94 +++++++++++++++++++++++----
- 1 file changed, 82 insertions(+), 12 deletions(-)
+ src/smbios-grpc-blobs/smbios_grpc.cpp | 111 ++++++++++++++++++++++----
+ 1 file changed, 95 insertions(+), 16 deletions(-)
diff --git a/src/smbios-grpc-blobs/smbios_grpc.cpp b/src/smbios-grpc-blobs/smbios_grpc.cpp
-index bf86eb7..83e1474 100644
+index bf86eb7..bcf4d0a 100644
--- a/src/smbios-grpc-blobs/smbios_grpc.cpp
+++ b/src/smbios-grpc-blobs/smbios_grpc.cpp
@@ -2,6 +2,8 @@
@@ -49,7 +49,24 @@
class SmbiosTransferServiceImpl final :
public phosphor::smbios::SmbiosTransferService::Service
{
-@@ -41,15 +40,63 @@ class SmbiosTransferServiceImpl final :
+@@ -27,9 +26,14 @@ class SmbiosTransferServiceImpl final :
+ grpc::Status SmbiosTransfer(
+ grpc::ServerContext* context,
+ const phosphor::smbios::SmbiosTransferRequest* request,
+- phosphor::smbios::SmbiosTransferResponse* response) override
++ [[maybe_unused]] phosphor::smbios::SmbiosTransferResponse* response)
++ override
+ {
+- lg2::info("SMBIOS gRPC server: Received transfer");
++ lg2::info("SMBIOS gRPC server: Received transfer request");
++
++ std::string peer = context->peer();
++
++ lg2::info("Received peer identifies as: {PEER}", "PEER", peer);
+
+ std::string entryPoint = request->smbios_entry_point();
+ std::string structureTable = request->smbios_structure_table();
+@@ -41,15 +45,63 @@ class SmbiosTransferServiceImpl final :
lg2::info("Received SMBIOS structure table: {SIZE} bytes", "SIZE",
structureTable.size());
@@ -114,7 +131,7 @@
{
return instanceNumber;
}
-@@ -61,7 +108,7 @@ class SmbiosTransferServiceImpl final :
+@@ -61,7 +113,7 @@ class SmbiosTransferServiceImpl final :
class SmbiosGrpcInstance
{
public:
@@ -123,21 +140,21 @@
{
std::stringstream ss;
-@@ -70,21 +117,38 @@ class SmbiosGrpcInstance
+@@ -70,21 +122,38 @@ class SmbiosGrpcInstance
return ss.str();
}
- void start(int instance)
+ void prepareInstance(int instance)
-+ {
+ {
+- int port = basePort + instance;
+ service.setInstance(instance);
+
+ service.restoreFromFile();
+ }
+
+ void start()
- {
-- int port = basePort + instance;
++ {
+ int instance = service.getInstance();
+
+ // Bias, because port number range 1-based but instances are 0-based
@@ -167,24 +184,35 @@
server = builder.BuildAndStart();
lg2::info("Starting thread: {INSTANCE}", "INSTANCE", instance);
-@@ -134,9 +198,15 @@ class SmbiosGrpcDetails
+@@ -134,22 +203,32 @@ class SmbiosGrpcDetails
public:
void start()
{
+- for (int i = 0; i < instances.size(); ++i)
++ auto size = static_cast<int>(instances.size());
++
+ // Avoid race condition by doing preparations as separate step first
-+ for (int i = 0; i < instances.size(); ++i)
-+ {
++ for (int i = 0; i < size; ++i)
+ {
+- instances[i].start(i);
+ instances[i].prepareInstance(i);
+ }
+
- for (int i = 0; i < instances.size(); ++i)
- {
-- instances[i].start(i);
++ for (int i = 0; i < size; ++i)
++ {
+ instances[i].start();
}
}
-@@ -149,7 +219,7 @@ class SmbiosGrpcDetails
+ void stop()
+ {
+- for (int i = 0; i < instances.size(); ++i)
++ auto size = static_cast<int>(instances.size());
++
++ for (int i = 0; i < size; ++i)
+ {
+ instances[i].stop();
+ }
}
private:
@@ -194,5 +222,5 @@
SmbiosGrpcServer::SmbiosGrpcServer(
--
-2.41.0.640.ga95def55d0-goog
+2.42.0.283.g2d96d420d3-goog