(UsdLoader) Fix coverity issues 45/323545/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 30 Apr 2025 02:13:24 +0000 (11:13 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 30 Apr 2025 02:14:22 +0000 (11:14 +0900)
1. We were used moved imagePath string for log
2. We need to check GetShaderId's return value

Change-Id: Ie59d3c0253b27749aa6d53d935bf2b8cc6567109
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-usd-loader/internal/usd-texture-converter.cpp

index 6ec9439adb3d99106fcd853c9cfa34538fda1321..6be16e53fe6b0d7b3567d9138eb55cb8d9558d90 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
-* Copyright (c) 2024 Samsung Electronics Co., Ltd.
+* Copyright (c) 2025 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -64,13 +64,15 @@ bool UsdTextureConverter::ConvertTexture(const UsdShadeMaterial& usdMaterial, co
   for(const auto& d : deps)
   {
     TfToken tokenId;
-    d.GetShaderId(&tokenId);
-    std::string depsId = tokenId.GetString();
-
-    // Use the shader ID to find the appropriate processor and call it
-    if(shaderProcessors.find(depsId) != shaderProcessors.end())
+    if(d.GetShaderId(&tokenId))
     {
-      shaderProcessors[depsId](d);
+      std::string depsId = tokenId.GetString();
+
+      // Use the shader ID to find the appropriate processor and call it
+      if(shaderProcessors.find(depsId) != shaderProcessors.end())
+      {
+        shaderProcessors[depsId](d);
+      }
     }
   }
 
@@ -237,18 +239,20 @@ bool UsdTextureConverter::ProcessImageBuffer(MaterialDefinition& materialDefinit
 
   if(imageBuffer.size() > 0)
   {
+    DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Image Buffer Processed: semantic: %u", semantic);
+
     // If the image buffer is valid, push it to the material definition as a texture stage
     materialDefinition.mTextureStages.push_back({semantic, TextureDefinition{std::move(imageBuffer), SamplerFlags::DEFAULT, metaData.mMinSize, metaData.mSamplingMode}});
     materialDefinition.mFlags |= semantic;
-    DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Image Buffer Processed: semantic: %u", semantic);
     return true;
   }
   else if(!imagePath.empty())
   {
+    DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Image Path Processed: semantic: %u, imagePath: %s", semantic, imagePath.c_str());
+
     // If we have a valid image path, push it to the material definition
     materialDefinition.mTextureStages.push_back({semantic, TextureDefinition{std::move(imagePath), SamplerFlags::DEFAULT, metaData.mMinSize, metaData.mSamplingMode}});
     materialDefinition.mFlags |= semantic;
-    DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Image Path Processed: semantic: %u, imagePath: %s", semantic, imagePath.c_str());
     return true;
   }