提交 5d57e2ad 编写于 作者: S shenchai 提交者: guangshu.wgs

fix coverity problem

上级 de1c5e36
...@@ -107,7 +107,7 @@ static int copy_string(const ObObjCastParams &params, ...@@ -107,7 +107,7 @@ static int copy_string(const ObObjCastParams &params,
} else { } else {
int64_t zf = params.zf_info_->max_length_ - len; int64_t zf = params.zf_info_->max_length_ - len;
if (zf > 0) { if (zf > 0) {
MEMSET(buf, '0', zf); MEMSET(buf, 0, zf);
MEMCPY(buf + zf, str, len); MEMCPY(buf + zf, str, len);
len = str_len; // set string length len = str_len; // set string length
} else { } else {
......
...@@ -28,7 +28,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) ...@@ -28,7 +28,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
{ {
z_stream stream; z_stream stream;
int err; int err;
stream.total_out = 0;
stream.next_in = (z_const Bytef *)source; stream.next_in = (z_const Bytef *)source;
stream.avail_in = (uInt)sourceLen; stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K #ifdef MAXSEG_64K
......
...@@ -30,6 +30,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen) ...@@ -30,6 +30,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
z_stream stream; z_stream stream;
int err; int err;
stream.total_out = 0;
stream.next_in = (z_const Bytef *)source; stream.next_in = (z_const Bytef *)source;
stream.avail_in = (uInt)sourceLen; stream.avail_in = (uInt)sourceLen;
/* Check for source > 64K on 16-bit machine: */ /* Check for source > 64K on 16-bit machine: */
......
...@@ -417,6 +417,9 @@ public: ...@@ -417,6 +417,9 @@ public:
instance = NULL; instance = NULL;
ATOMIC_BCAS(&once_, 1, 0); ATOMIC_BCAS(&once_, 1, 0);
} else { } else {
if (instance_ != NULL) {
delete instance_;
}
instance_ = instance; instance_ = instance;
(void)ATOMIC_BCAS(&once_, 1, 2); (void)ATOMIC_BCAS(&once_, 1, 2);
} }
......
...@@ -1528,10 +1528,10 @@ void ObLogger::do_async_flush_to_file(ObLogItem **log_item, const int64_t count) ...@@ -1528,10 +1528,10 @@ void ObLogger::do_async_flush_to_file(ObLogItem **log_item, const int64_t count)
} }
} }
struct iovec vec[MAX_FD_FILE][GROUP_COMMIT_MAX_ITEM_COUNT]; struct iovec vec[MAX_FD_FILE][GROUP_COMMIT_MAX_ITEM_COUNT] = {0};
int iovcnt[MAX_FD_FILE] = {0}; int iovcnt[MAX_FD_FILE] = {0};
int large_iovcnt[MAX_FD_FILE] = {0}; int large_iovcnt[MAX_FD_FILE] = {0};
struct iovec wf_vec[MAX_FD_FILE][GROUP_COMMIT_MAX_ITEM_COUNT]; struct iovec wf_vec[MAX_FD_FILE][GROUP_COMMIT_MAX_ITEM_COUNT] = {0};
int wf_iovcnt[MAX_FD_FILE] = {0}; int wf_iovcnt[MAX_FD_FILE] = {0};
ObLogFDType fd_type = MAX_FD_FILE; ObLogFDType fd_type = MAX_FD_FILE;
......
...@@ -1230,7 +1230,7 @@ static int read_pid(const char *pidfile, long &pid) ...@@ -1230,7 +1230,7 @@ static int read_pid(const char *pidfile, long &pid)
pid = strtol(buf, NULL, 10); pid = strtol(buf, NULL, 10);
} }
if (fd > 0) { if (fd >= 0) {
close(fd); close(fd);
} }
......
...@@ -370,7 +370,17 @@ ObBaseSort::ObBaseSort(SortColumnArray &sort_columns, common::ObIAllocator &allo ...@@ -370,7 +370,17 @@ ObBaseSort::ObBaseSort(SortColumnArray &sort_columns, common::ObIAllocator &allo
*err_ = common::OB_SUCCESS; *err_ = common::OB_SUCCESS;
*sort_err_ = common::OB_SUCCESS; *sort_err_ = common::OB_SUCCESS;
} }
ObBaseSort::~ObBaseSort()
{
if (err_ != NULL) {
delete err_;
err_ = NULL;
}
if (sort_err_ != NULL) {
delete sort_err_;
sort_err_ = NULL;
}
}
bool ObBaseSort::compare_row(ResultRow &row1, ResultRow &row2, int &ret) //row1 <= row2 true, row1 > row2 false bool ObBaseSort::compare_row(ResultRow &row1, ResultRow &row2, int &ret) //row1 <= row2 true, row1 > row2 false
{ {
*err_ = common::OB_SUCCESS; *err_ = common::OB_SUCCESS;
......
...@@ -141,7 +141,7 @@ class ObBaseSort ...@@ -141,7 +141,7 @@ class ObBaseSort
{ {
public: public:
ObBaseSort(SortColumnArray &sort_columns, common::ObIAllocator &allocator_, ResultRows &sort_rows); ObBaseSort(SortColumnArray &sort_columns, common::ObIAllocator &allocator_, ResultRows &sort_rows);
virtual ~ObBaseSort() {}; virtual ~ObBaseSort();
virtual void set_sort_columns(SortColumnArray &sort_columns) virtual void set_sort_columns(SortColumnArray &sort_columns)
{ {
......
...@@ -358,7 +358,7 @@ int ObServerConnection::accept(ObConnection *c) ...@@ -358,7 +358,7 @@ int ObServerConnection::accept(ObConnection *c)
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
PROXY_SOCK_LOG(WARN, "invalid argument conn", K(c), K(ret)); PROXY_SOCK_LOG(WARN, "invalid argument conn", K(c), K(ret));
} else { } else {
int64_t sz = sizeof(c->addr_); int64_t sz = sizeof(c->addr_.sa_);
if (OB_FAIL(ObSocketManager::accept(fd_, &c->addr_.sa_, &sz, c->fd_))) { if (OB_FAIL(ObSocketManager::accept(fd_, &c->addr_.sa_, &sz, c->fd_))) {
if (OB_SYS_EAGAIN != ret) { if (OB_SYS_EAGAIN != ret) {
PROXY_SOCK_LOG(WARN, "fail to accept", K(fd_), K(ret)); PROXY_SOCK_LOG(WARN, "fail to accept", K(fd_), K(ret));
......
...@@ -544,6 +544,7 @@ inline bool ops_is_ip_any(const sockaddr &ip) ...@@ -544,6 +544,7 @@ inline bool ops_is_ip_any(const sockaddr &ip)
inline bool ops_ip_copy(sockaddr &dst, const sockaddr &src) inline bool ops_ip_copy(sockaddr &dst, const sockaddr &src)
{ {
int64_t n = 0; int64_t n = 0;
int64_t n2 = 0;
switch (src.sa_family) { switch (src.sa_family) {
case AF_INET: case AF_INET:
n = sizeof(sockaddr_in); n = sizeof(sockaddr_in);
...@@ -553,7 +554,16 @@ inline bool ops_ip_copy(sockaddr &dst, const sockaddr &src) ...@@ -553,7 +554,16 @@ inline bool ops_ip_copy(sockaddr &dst, const sockaddr &src)
n = sizeof(sockaddr_in6); n = sizeof(sockaddr_in6);
break; break;
} }
if (n) { switch (dst.sa_family) {
case AF_INET:
n2 = sizeof(sockaddr_in);
break;
case AF_INET6:
n2 = sizeof(sockaddr_in6);
break;
}
if (n && n <= n2) {
MEMCPY(&dst, &src, n); MEMCPY(&dst, &src, n);
#if HAVE_STRUCT_SOCKADDR_SA_LEN #if HAVE_STRUCT_SOCKADDR_SA_LEN
dst.sa_len = n; dst.sa_len = n;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册