GBE: fix a errMsg uninitialized build warning.

Submitted by Yang, Rong R on July 27, 2017, 5:46 a.m.

Details

Message ID 1501134371-21917-1-git-send-email-rong.r.yang@intel.com
State New
Series "GBE: fix a errMsg uninitialized build warning."
Headers show

Commit Message

Yang, Rong R July 27, 2017, 5:46 a.m.
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
---
 backend/src/backend/gen_program.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
index e7a88b4..f767b6b 100644
--- a/backend/src/backend/gen_program.cpp
+++ b/backend/src/backend/gen_program.cpp
@@ -510,7 +510,7 @@  namespace gbe {
   {
 #ifdef GBE_COMPILER_AVAILABLE
     using namespace gbe;
-    char* errMsg;
+    char* errMsg = NULL;
     if(((GenProgram*)dst_program)->module == NULL){
 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
       ((GenProgram*)dst_program)->module = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module).release();
@@ -518,7 +518,7 @@  namespace gbe {
       ((GenProgram*)dst_program)->module = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module);
 #endif
       errSize = 0;
-    }else{
+    } else {
 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
       // Src now will be removed automatically. So clone it.
       llvm::Module* src = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module).release();
@@ -534,7 +534,7 @@  namespace gbe {
 #else
       if (LLVMLinkModules(wrap(dst), wrap(src), LLVMLinkerPreserveSource, &errMsg)) {
 #endif
-        if (err != NULL && errSize != NULL && stringSize > 0u) {
+        if (err != NULL && errSize != NULL && stringSize > 0u && errMsg) {
           strncpy(err, errMsg, stringSize-1);
           err[stringSize-1] = '\0';
           *errSize = strlen(err);

Comments

Song, Ruiling July 27, 2017, 3:16 a.m.
LGTM

Ruiling

> -----Original Message-----

> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf Of

> Yang Rong

> Sent: Thursday, July 27, 2017 1:46 PM

> To: beignet@lists.freedesktop.org

> Cc: Yang, Rong R <rong.r.yang@intel.com>

> Subject: [Beignet] [PATCH] GBE: fix a errMsg uninitialized build warning.

> 

> Signed-off-by: Yang Rong <rong.r.yang@intel.com>

> ---

>  backend/src/backend/gen_program.cpp | 6 +++---

>  1 file changed, 3 insertions(+), 3 deletions(-)

> 

> diff --git a/backend/src/backend/gen_program.cpp

> b/backend/src/backend/gen_program.cpp

> index e7a88b4..f767b6b 100644

> --- a/backend/src/backend/gen_program.cpp

> +++ b/backend/src/backend/gen_program.cpp

> @@ -510,7 +510,7 @@ namespace gbe {

>    {

>  #ifdef GBE_COMPILER_AVAILABLE

>      using namespace gbe;

> -    char* errMsg;

> +    char* errMsg = NULL;

>      if(((GenProgram*)dst_program)->module == NULL){

>  #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38

>        ((GenProgram*)dst_program)->module =

> llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)-

> >module).release();

> @@ -518,7 +518,7 @@ namespace gbe {

>        ((GenProgram*)dst_program)->module =

> llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module);

>  #endif

>        errSize = 0;

> -    }else{

> +    } else {

>  #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39

>        // Src now will be removed automatically. So clone it.

>        llvm::Module* src =

> llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)-

> >module).release();

> @@ -534,7 +534,7 @@ namespace gbe {

>  #else

>        if (LLVMLinkModules(wrap(dst), wrap(src), LLVMLinkerPreserveSource,

> &errMsg)) {

>  #endif

> -        if (err != NULL && errSize != NULL && stringSize > 0u) {

> +        if (err != NULL && errSize != NULL && stringSize > 0u && errMsg) {

>            strncpy(err, errMsg, stringSize-1);

>            err[stringSize-1] = '\0';

>            *errSize = strlen(err);

> --

> 2.1.4

> 

> _______________________________________________

> Beignet mailing list

> Beignet@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/beignet