From d141d8bfc7a602b0f139bef42a1c73dc673687de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AD=A6=E7=A7=AF=E8=B6=85?= <wujichao1@huawei.com>
Date: Mon, 21 Oct 2024 19:39:38 +0800
Subject: [PATCH] fix-clang-build-error

---
 src/daemon/common/cri/cri_helpers.cc                   |  4 ++--
 src/daemon/entry/cri/streams/stream_server.h           |  4 ++--
 .../entry/cri/v1/v1_cri_container_manager_service.cc   |  2 +-
 .../entry/cri/v1/v1_cri_image_manager_service_impl.cc  |  2 +-
 .../entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc | 10 +++++-----
 src/daemon/entry/cri/v1/v1_cri_runtime_service_impl.h  |  2 +-
 .../entry/cri/v1alpha/cri_container_manager_service.cc |  2 +-
 .../cri/v1alpha/cri_pod_sandbox_manager_service.cc     |  6 +++---
 src/daemon/sandbox/sandbox.cc                          |  2 +-
 src/daemon/sandbox/sandbox_ops.cc                      |  2 +-
 10 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/daemon/common/cri/cri_helpers.cc b/src/daemon/common/cri/cri_helpers.cc
index 8117403c..a8cbd996 100644
--- a/src/daemon/common/cri/cri_helpers.cc
+++ b/src/daemon/common/cri/cri_helpers.cc
@@ -525,8 +525,8 @@ void RemoveContainerLogSymlink(const std::string &containerID, Errors &error)
     if (!path.empty()) {
         // Only remove the symlink when container log path is specified.
         if (util_path_remove(path.c_str()) != 0 && errno != ENOENT) {
-            SYSERROR("Failed to remove container %s log symlink %s.", containerID.c_str(), path);
-            error.Errorf("Failed to remove container %s log symlink %s.", containerID.c_str(), path);
+            SYSERROR("Failed to remove container %s log symlink %s.", containerID.c_str(), path.c_str());
+            error.Errorf("Failed to remove container %s log symlink %s.", containerID.c_str(), path.c_str());
         }
     }
 }
diff --git a/src/daemon/entry/cri/streams/stream_server.h b/src/daemon/entry/cri/streams/stream_server.h
index 81aa9987..028dfc84 100644
--- a/src/daemon/entry/cri/streams/stream_server.h
+++ b/src/daemon/entry/cri/streams/stream_server.h
@@ -17,6 +17,8 @@
 #include "errors.h"
 #include "url.h"
 
+url::URLDatum cri_stream_server_url(void);
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -27,8 +29,6 @@ void cri_stream_server_wait(void);
 
 void cri_stream_server_shutdown(void);
 
-url::URLDatum cri_stream_server_url(void);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc b/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
index d3fdd76a..1e84d14c 100644
--- a/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
+++ b/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
@@ -744,7 +744,7 @@ void ContainerManagerService::ListContainersToGRPC(container_list_response *resp
             CRIHelpersV1::ContainerStatusToRuntime(Container_Status(response->containers[i]->status));
         container->set_state(state);
 
-        containers.push_back(move(container));
+        containers.push_back(std::move(container));
     }
 }
 
diff --git a/src/daemon/entry/cri/v1/v1_cri_image_manager_service_impl.cc b/src/daemon/entry/cri/v1/v1_cri_image_manager_service_impl.cc
index 71918706..561a40d5 100644
--- a/src/daemon/entry/cri/v1/v1_cri_image_manager_service_impl.cc
+++ b/src/daemon/entry/cri/v1/v1_cri_image_manager_service_impl.cc
@@ -149,7 +149,7 @@ void ImageManagerServiceImpl::list_images_to_grpc(im_list_response *response,
 
         imagetool_image_summary *element = list_images->images[i];
         conv_image_to_grpc(element, image);
-        images.push_back(move(image));
+        images.push_back(std::move(image));
     }
 }
 
diff --git a/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc b/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc
index b629b1c3..a5f98619 100644
--- a/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc
+++ b/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc
@@ -536,7 +536,7 @@ auto PodSandboxManagerService::GetContainerListResponse(const std::string &readS
     if (CRIHelpers::FiltersAddLabel(list_request->filters, CRIHelpers::Constants::SANDBOX_ID_LABEL_KEY,
                                     readSandboxID) != 0) {
         std::string tmp_errmsg = "Failed to add label in sandbox" + readSandboxID;
-        ERROR(tmp_errmsg.c_str());
+        ERROR("%s", tmp_errmsg.c_str());
         errors.push_back(tmp_errmsg);
         return nullptr;
     }
@@ -551,7 +551,7 @@ auto PodSandboxManagerService::GetContainerListResponse(const std::string &readS
     }
     if (ret != 0) {
         if (list_response != nullptr && list_response->errmsg != nullptr) {
-            ERROR(list_response->errmsg);
+            ERROR("%s", list_response->errmsg);
             errors.push_back(list_response->errmsg);
         } else {
             ERROR("Failed to call list container callback");
@@ -1218,7 +1218,7 @@ void PodSandboxManagerService::PodSandboxStatsToGRPC(const std::string &id, cons
         return;
     }
 
-    podStats = move(podStatsPtr);
+    podStats = std::move(podStatsPtr);
     return;
 }
 
@@ -1227,7 +1227,7 @@ auto PodSandboxManagerService::PodSandboxStats(const std::string &podSandboxID,
                                                Errors &error) -> std::unique_ptr<runtime::v1::PodSandboxStats>
 {
     Errors tmpErr;
-    cgroup_metrics_t cgroupMetrics { 0 };
+    cgroup_metrics_t cgroupMetrics {{ 0 }};
     std::vector<Network::NetworkInterfaceStats> netMetrics;
     std::map<std::string, std::string> annotations;
     std::unique_ptr<runtime::v1::PodSandboxStats> podStats { nullptr };
@@ -1368,7 +1368,7 @@ void PodSandboxManagerService::ListPodSandboxStats(const runtime::v1::PodSandbox
             continue;
         }
 
-        podsStats.push_back(move(podStats));
+        podsStats.push_back(std::move(podStats));
     }
 }
 
diff --git a/src/daemon/entry/cri/v1/v1_cri_runtime_service_impl.h b/src/daemon/entry/cri/v1/v1_cri_runtime_service_impl.h
index 3d93c7bb..33539a32 100644
--- a/src/daemon/entry/cri/v1/v1_cri_runtime_service_impl.h
+++ b/src/daemon/entry/cri/v1/v1_cri_runtime_service_impl.h
@@ -104,7 +104,7 @@ protected:
 private:
     std::string m_podSandboxImage;
     std::shared_ptr<Network::PluginManager> m_pluginManager { nullptr };
-    bool m_enablePodEvents;
+    [[maybe_unused]] bool m_enablePodEvents;
 };
 } // namespace CRIV1
 #endif // DAEMON_ENTRY_CRI_V1_CRI_RUNTIME_SERVICE_IMPL_H
diff --git a/src/daemon/entry/cri/v1alpha/cri_container_manager_service.cc b/src/daemon/entry/cri/v1alpha/cri_container_manager_service.cc
index dbefa143..97acecd9 100644
--- a/src/daemon/entry/cri/v1alpha/cri_container_manager_service.cc
+++ b/src/daemon/entry/cri/v1alpha/cri_container_manager_service.cc
@@ -687,7 +687,7 @@ void ContainerManagerService::ListContainersToGRPC(container_list_response *resp
             CRIHelpersV1Alpha::ContainerStatusToRuntime(Container_Status(response->containers[i]->status));
         container->set_state(state);
 
-        pods.push_back(move(container));
+        pods.push_back(std::move(container));
     }
 }
 
diff --git a/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc b/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc
index 1c343cda..3c128645 100644
--- a/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc
+++ b/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc
@@ -1573,7 +1573,7 @@ void PodSandboxManagerService::PodSandboxStatsToGRPC(const std::string &id, cons
         return;
     }
 
-    podStats = move(podStatsPtr);
+    podStats = std::move(podStatsPtr);
     return;
 }
 
@@ -1583,7 +1583,7 @@ auto PodSandboxManagerService::PodSandboxStats(const std::string &podSandboxID,
 {
     Errors tmpErr;
     container_inspect *inspectData { nullptr };
-    cgroup_metrics_t cgroupMetrics { 0 };
+    cgroup_metrics_t cgroupMetrics {{ 0 }};
     std::vector<Network::NetworkInterfaceStats> netMetrics;
     std::map<std::string, std::string> annotations;
     std::unique_ptr<runtime::v1alpha2::PodSandboxStats> podStats { nullptr };
@@ -1733,7 +1733,7 @@ void PodSandboxManagerService::ListPodSandboxStats(const runtime::v1alpha2::PodS
             continue;
         }
 
-        podsStats.push_back(move(podStats));
+        podsStats.push_back(std::move(podStats));
     }
 }
 
diff --git a/src/daemon/sandbox/sandbox.cc b/src/daemon/sandbox/sandbox.cc
index d44abb99..dec082bc 100644
--- a/src/daemon/sandbox/sandbox.cc
+++ b/src/daemon/sandbox/sandbox.cc
@@ -847,7 +847,7 @@ auto Sandbox::SaveState(Errors &error) -> bool
 
     nret = util_atomic_write_file(path.c_str(), stateJson.c_str(), stateJson.length(), CONFIG_FILE_MODE, false);
     if (nret != 0) {
-        SYSERROR("Failed to write file %s");
+        SYSERROR("Failed to write file %s", path.c_str());
         error.Errorf("Failed to write file %s", path.c_str());
         return false;
     }
diff --git a/src/daemon/sandbox/sandbox_ops.cc b/src/daemon/sandbox/sandbox_ops.cc
index b7fb40bf..22cfea95 100644
--- a/src/daemon/sandbox/sandbox_ops.cc
+++ b/src/daemon/sandbox/sandbox_ops.cc
@@ -72,7 +72,7 @@ static int do_sandbox_prepare(const container_config_v2_common_config *config,
 
     params.containerId = config->id;
     params.execId = (nullptr == exec_id) ? "" : exec_id;
-    params.spec = std::move(std::unique_ptr<std::string>(new std::string(oci_spec)));
+    params.spec = std::unique_ptr<std::string>(new std::string(oci_spec));
 
     if (generate_ctrl_rootfs(params, config) != 0) {
         ERROR("Invalid rootfs");
-- 
2.25.1

