Fu Juntang
2021-09-06 f453059448d883c1a54b2b53147715de38f872f4
Fix the return condition.
1个文件已修改
30 ■■■■ 已修改文件
src/bh_api.cpp 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/bh_api.cpp
@@ -154,6 +154,7 @@
    memset(errString, 0x00, sizeof(errString));
    strncpy(errString, bus_strerror(rv), sizeof(errString));
    
    return false;
  }
#if defined(PRO_DE_SERIALIZE)
@@ -174,10 +175,8 @@
    
#endif 
  
  if (rv == 0)
    return true;
  return false;
}
int BHUnregister(const void *proc_info, const int proc_info_len, void **reply, int *reply_len, const int timeout_ms)
@@ -256,6 +255,8 @@
    rv = EBUS_RES_BUSY;
    memset(errString, 0x00, sizeof(errString));
    strncpy(errString, bus_strerror(rv), sizeof(errString));
    return false;
  }
  
#if defined(PRO_DE_SERIALIZE)
@@ -275,10 +276,8 @@
  *reply_len = min;
#endif 
  
  if (rv == 0)
    return true;
  return false;
}
int BHRegisterTopics(const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms)
@@ -392,6 +391,8 @@
    rv = EBUS_RES_BUSY;
    memset(errString, 0x00, sizeof(errString));
    strncpy(errString, bus_strerror(rv), sizeof(errString));
    return false;
  }
#if defined(PRO_DE_SERIALIZE)
@@ -411,10 +412,8 @@
  *reply_len = len;
#endif 
  
  if (rv == 0)
    return true;
  return false;
}
int BHQueryTopicAddress(const void *remote, const int remote_len, const void *topic, const int topic_len, void **reply, int *reply_len, const int timeout_ms)
@@ -499,6 +498,8 @@
    rv = EBUS_RES_BUSY;
    memset(errString, 0x00, sizeof(errString));
    strncpy(errString, bus_strerror(rv), sizeof(errString));
    return false;
  }
    
#if defined(PRO_DE_SERIALIZE)
@@ -565,10 +566,8 @@
  
#endif 
  
  if (rv == 0)
    return true;
  return false;
}
int BHQueryProcs(const void *remote, const int remote_len, const void *query, const int query_len, void **reply, int *reply_len, const int timeout_ms)
@@ -646,6 +645,8 @@
    rv = EBUS_RES_BUSY;
    memset(errString, 0x00, sizeof(errString));
    strncpy(errString, bus_strerror(rv), sizeof(errString));
    return false;
  }
  
#if defined(PRO_DE_SERIALIZE)
@@ -730,10 +731,7 @@
  }
#endif 
    if (rv == 0)
    return true;
  return false;
}
@@ -860,6 +858,8 @@
    rv = EBUS_RES_BUSY;
    memset(errString, 0x00, sizeof(errString));
    strncpy(errString, bus_strerror(rv), sizeof(errString));
    return false;
  }
#if defined(PRO_DE_SERIALIZE)
@@ -879,10 +879,7 @@
  *reply_len = len;
#endif 
  
  if (rv == 0)
    return true;
  return false;
}
@@ -1521,7 +1518,6 @@
      
      free(buf);
      
      printf("BHRequest finished_7\n");
    }
    
    pthread_mutex_unlock(&mutex);
@@ -1534,6 +1530,7 @@
  }
#if defined(PRO_DE_SERIALIZE)   
  if (rv == 0) {
  ::bhome_msg::MsgRequestTopicReply mrt; 
  mrt.mutable_errmsg()->set_errcode(::bhome_msg::ErrorCode(rv));
  mrt.mutable_errmsg()->set_errstring(errString);
@@ -1541,8 +1538,9 @@
  *reply_len = mrt.ByteSizeLong();
  *reply = malloc(*reply_len);
  mrt.SerializePartialToArray(*reply, *reply_len);
  }
#else 
  if (rv > 0) {
  if (rv == 0) {
    min = strlen(errString) + 1;
    buf = malloc(min);
    memcpy(buf, errString, strlen(errString));