fix coverity

This commit is contained in:
nroskill 2024-03-14 02:16:16 +00:00 committed by ob-robot
parent 3d8640c594
commit cff976601e
4 changed files with 7 additions and 6 deletions

View File

@ -66,15 +66,16 @@ void flush_trace()
int ret = OB_SUCCESS;
ObTagCtxBase* tag = span->tags_;
bool first = true;
char tagstr[] = "\"tags\":[";
INIT_SPAN(span);
while (OB_SUCC(ret) && OB_NOT_NULL(tag)) {
if (pos + 10 >= MAX_TRACE_LOG_SIZE) {
if (pos + sizeof(tagstr) + 1 >= MAX_TRACE_LOG_SIZE) {
ret = OB_BUF_NOT_ENOUGH;
} else {
buf[pos++] = ',';
if (first) {
strcpy(buf + pos, "\"tags\":[");
pos += 8;
strncpy(buf + pos, tagstr, MAX_TRACE_LOG_SIZE - pos);
pos += sizeof(tagstr) - 1;
first = false;
}
ret = tag->tostring(buf, MAX_TRACE_LOG_SIZE, pos);

View File

@ -151,7 +151,7 @@ struct ObTagCtxBase
} else {
buf[pos++] = '{';
buf[pos++] = '\"';
IGNORE_RETURN strcpy(buf + pos, __tag_name_mapper[tag_type_]);
IGNORE_RETURN strncpy(buf + pos, __tag_name_mapper[tag_type_], buf_len - pos);
pos += l;
buf[pos++] = '\"';
buf[pos++] = ':';

View File

@ -1217,7 +1217,7 @@ int select_sql_workarea_active(lua_State *L)
lua_pushnil(L);
} else {
ObArray<uint64_t> ids;
common::ObSEArray<sql::ObSqlWorkareaProfileInfo, 32> wa_actives;
common::ObSEArray<sql::ObSqlWorkareaProfileInfo, 20> wa_actives;
std::vector<const char*> columns = {
"plan_id",
"sql_id",

View File

@ -282,7 +282,7 @@ void ObTaskController::calc_log_rate()
{
const double total = std::accumulate(
rate_pctgs_, rate_pctgs_ + MAX_TASK_ID, .0);
for (int i = 0; total != 0 && i < MAX_TASK_ID; i++) {
for (int i = 0; total > 0 && i < MAX_TASK_ID; i++) {
limiters_[i]->set_rate(
static_cast<int64_t>(
rate_pctgs_[i]/total * static_cast<double>(log_rate_limit_)));